Extensions to support ONU reboot functionality in BBSim.

Change-Id: I967c569a40162672870021910238a49fe23dc85f
diff --git a/omci_defs.go b/omci_defs.go
index 06f22dd..594ab00 100644
--- a/omci_defs.go
+++ b/omci_defs.go
@@ -60,6 +60,7 @@
 const (
 	// Managed Entity Class values
 	GEMPortNetworkCTP OmciClass = 268
+	ONUG              OmciClass = 256
 )
 
 // OMCI Managed Entity Class
@@ -91,10 +92,10 @@
 		return 0, 0, 0, 0, 0, OmciContent{}, errors.New("binary.Read failed")
 	}
 	/*    Message Type = Set
-        0... .... = Destination Bit: 0x0
-        .1.. .... = Acknowledge Request: 0x1
-        ..0. .... = Acknowledgement: 0x0
-        ...0 1000 = Message Type: Set (8)
+	      0... .... = Destination Bit: 0x0
+	      .1.. .... = Acknowledge Request: 0x1
+	      ..0. .... = Acknowledgement: 0x0
+	      ...0 1000 = Message Type: Set (8)
 	*/
 	log.Printf("OmciRun - TransactionId: %d MessageType: %d, ME Class: %d, ME Instance: %d, Content: %x",
 		m.TransactionId, m.MessageType&0x1F, m.MessageId.Class, m.MessageId.Instance, m.Content)
diff --git a/omci_handlers.go b/omci_handlers.go
index d5ce6d7..e9847ca 100644
--- a/omci_handlers.go
+++ b/omci_handlers.go
@@ -36,6 +36,7 @@
 	GetAllAlarmsNext: getAllAlarmsNext,
 	SynchronizeTime:  syncTime,
 	Delete:           delete,
+	Reboot:           reboot,
 }
 
 func mibReset(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
@@ -80,11 +81,14 @@
 
 	state := OnuOmciStateMap[key]
 
-	log.Printf("%v - Omci MibUploadNext %d", key, state.mibUploadCtr)
+	// commandNumber is the "Command number" attribute received in "MIB Upload Next" OMCI message
+	commandNumber := ( (uint16(content[1])) | (uint16(content[0])<<8) )
+	log.Printf("%v - Omci MibUploadNext %d", key, commandNumber)
 
-	switch state.mibUploadCtr {
+	switch commandNumber {
 	case 0:
 		// ONT Data (2)
+		log.Println("ONT DATA")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
@@ -94,6 +98,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 1:
 		// Circuit Pack (6) - #1
+		log.Println("Circuit Pack")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x01, 0xf0, 0x00, 0x2f, 0x04,
@@ -103,6 +108,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 2:
 		// Circuit Pack (6) - #2
+		log.Println("Circuit Pack")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x01, 0x0f, 0x00, 0x42, 0x52,
@@ -112,6 +118,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 3:
 		// Circuit Pack (6) - #3
+		log.Println("Circuit Pack")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x01, 0x00, 0xf8, 0x20, 0x20,
@@ -121,6 +128,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 4:
 		// Circuit Pack (6) - #4
+		log.Println("Circuit Pack")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x01, 0x00, 0x04, 0x00, 0x00,
@@ -130,6 +138,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 5:
 		// Circuit Pack (6) - #5
+		log.Println("Circuit Pack")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x80, 0xf0, 0x00, 0xee, 0x01,
@@ -139,6 +148,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 6:
 		// Circuit Pack (6) - #6
+		log.Println("Circuit Pack")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x80, 0x0f, 0x00, 0x42, 0x52,
@@ -148,6 +158,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 7:
 		// Circuit Pack (6) - #7
+		log.Println("Circuit Pack")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x80, 0x00, 0xf8, 0x20, 0x20,
@@ -157,6 +168,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 8:
 		// Circuit Pack (6) - #8
+		log.Println("Circuit Pack")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x06, 0x01, 0x80, 0x00, 0x04, 0x00, 0x00,
@@ -166,6 +178,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 9, 10, 11, 12:
 		// PPTP (11)
+		log.Println("PPTP")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x00, 0x0b, 0x01, 0x01, 0xff, 0xfe, 0x00, 0x2f,
@@ -177,6 +190,7 @@
 		state.pptpInstance++
 	case 13, 14, 15, 16, 17, 18, 19, 20:
 		// T-CONT (262)
+		log.Println("T-CONT")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x01, 0x06, 0x80, 0x00, 0xe0, 0x00, 0xff, 0xff,
@@ -188,6 +202,7 @@
 		state.tcontInstance++
 	case 21:
 		// ANI-G (263)
+		log.Println("ANI-G")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x01, 0x07, 0x80, 0x01, 0xff, 0xff, 0x01, 0x00,
@@ -197,6 +212,7 @@
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	case 22, 23, 24, 25:
 		// UNI-G (264)
+		log.Println("UNI-G")
 		pkt = []byte{
 			0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
 			0x01, 0x08, 0x01, 0x01, 0xf8, 0x00, 0x00, 0x00,
@@ -431,3 +447,17 @@
 
 	return pkt, nil
 }
+
+func reboot(class OmciClass, content OmciContent, key OnuKey) ([]byte, error) {
+	var pkt []byte
+	pkt = []byte{
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+
+	log.Printf("%v - Omci Reboot", key)
+	return pkt, nil
+}
diff --git a/omci_sim.go b/omci_sim.go
index 2d723c0..b6ebe30 100644
--- a/omci_sim.go
+++ b/omci_sim.go
@@ -54,7 +54,6 @@
 
 	// for create, get and set
 	if ((msgType & 0xFF) != MibUploadNext) && ((msgType & 0xFF) != MibReset) && ((msgType & 0xFF) != MibUpload) {
-		log.Println("CREATE GET OR SET OPERATION")
 		// Common fields for create, get, and set
 		resp[4] = byte(class >> 8)
 		resp[5] = byte(class & 0xFF)