[VOL-4632] Adding NniDhcpTrapVid to support FTTB usecase

Change-Id: I3e7c4fdb7cc3872a489faa4ef1de80d51bc56887
diff --git a/internal/bbsim/api/grpc_api_server.go b/internal/bbsim/api/grpc_api_server.go
index 2500cdd..20fc525 100644
--- a/internal/bbsim/api/grpc_api_server.go
+++ b/internal/bbsim/api/grpc_api_server.go
@@ -117,13 +117,14 @@
 	}
 
 	res := bbsim.Olt{
-		ID:            int32(olt.ID),
-		SerialNumber:  olt.SerialNumber,
-		OperState:     olt.OperState.Current(),
-		InternalState: olt.InternalState.Current(),
-		IP:            oltAddress,
-		NNIPorts:      nnis,
-		PONPorts:      pons,
+		ID:             int32(olt.ID),
+		SerialNumber:   olt.SerialNumber,
+		OperState:      olt.OperState.Current(),
+		InternalState:  olt.InternalState.Current(),
+		IP:             oltAddress,
+		NNIPorts:       nnis,
+		PONPorts:       pons,
+		NniDhcpTrapVid: int32(olt.NniDhcpTrapVid),
 	}
 	return &res, nil
 }
diff --git a/internal/bbsim/devices/olt.go b/internal/bbsim/devices/olt.go
index 9b99c79..1d61773 100644
--- a/internal/bbsim/devices/olt.go
+++ b/internal/bbsim/devices/olt.go
@@ -77,6 +77,7 @@
 	NumOnuPerPon         int
 	NumUni               int
 	NumPots              int
+	NniDhcpTrapVid       int
 	InternalState        *fsm.FSM
 	channel              chan types.Message
 	dhcpServer           dhcp.DHCPServerIf
@@ -117,13 +118,14 @@
 
 func CreateOLT(options common.GlobalConfig, services []common.ServiceYaml, isMock bool) *OltDevice {
 	oltLogger.WithFields(log.Fields{
-		"ID":           options.Olt.ID,
-		"NumNni":       options.Olt.NniPorts,
-		"NniSpeed":     options.Olt.NniSpeed,
-		"NumPon":       options.Olt.PonPorts,
-		"NumOnuPerPon": options.Olt.OnusPonPort,
-		"NumUni":       options.Olt.UniPorts,
-		"NumPots":      options.Olt.PotsPorts,
+		"ID":             options.Olt.ID,
+		"NumNni":         options.Olt.NniPorts,
+		"NniSpeed":       options.Olt.NniSpeed,
+		"NumPon":         options.Olt.PonPorts,
+		"NumOnuPerPon":   options.Olt.OnusPonPort,
+		"NumUni":         options.Olt.UniPorts,
+		"NumPots":        options.Olt.PotsPorts,
+		"NniDhcpTrapVid": options.Olt.NniDhcpTrapVid,
 	}).Debug("CreateOLT")
 
 	olt = OltDevice{
@@ -138,6 +140,7 @@
 		NumOnuPerPon:        int(options.Olt.OnusPonPort),
 		NumUni:              int(options.Olt.UniPorts),
 		NumPots:             int(options.Olt.PotsPorts),
+		NniDhcpTrapVid:      int(options.Olt.NniDhcpTrapVid),
 		Pons:                []*PonPort{},
 		Nnis:                []*NniPort{},
 		Delay:               options.BBSim.Delay,
diff --git a/internal/bbsim/devices/onu_test.go b/internal/bbsim/devices/onu_test.go
index 35f0c28..8a5ba0a 100644
--- a/internal/bbsim/devices/onu_test.go
+++ b/internal/bbsim/devices/onu_test.go
@@ -27,9 +27,10 @@
 	nextStag := map[string]int{}
 
 	olt := OltDevice{
-		ID:      0,
-		NumUni:  4,
-		NumPots: 1,
+		ID:             0,
+		NumUni:         4,
+		NumPots:        1,
+		NniDhcpTrapVid: 60,
 	}
 	pon := PonPort{
 		ID:  1,
@@ -41,4 +42,6 @@
 	assert.Equal(t, "BBSM00000101", onu.Sn())
 	assert.Equal(t, 4, len(onu.UniPorts))
 	assert.Equal(t, 1, len(onu.PotsPorts))
+	assert.Equal(t, 60, olt.NniDhcpTrapVid)
+
 }
diff --git a/internal/bbsim/responders/sadis/sadis.go b/internal/bbsim/responders/sadis/sadis.go
index ce73b1b..98000ff 100644
--- a/internal/bbsim/responders/sadis/sadis.go
+++ b/internal/bbsim/responders/sadis/sadis.go
@@ -90,6 +90,7 @@
 	IPAddress          string `json:"ipAddress"`
 	NasID              string `json:"nasId"`
 	UplinkPort         int    `json:"uplinkPort"`
+	NniDhcpTrapVid     int    `json:"nniDhcpTrapVid,omitempty"`
 }
 
 type SadisOnuEntryV2 struct {
@@ -178,6 +179,7 @@
 		IPAddress:          ip,
 		NasID:              olt.SerialNumber,
 		UplinkPort:         16777216, // TODO currently assumes we only have one NNI port
+		NniDhcpTrapVid:     olt.NniDhcpTrapVid,
 	}
 	return solt, nil
 }
diff --git a/internal/bbsimctl/commands/olt.go b/internal/bbsimctl/commands/olt.go
index d2e72a5..f64f16b 100644
--- a/internal/bbsimctl/commands/olt.go
+++ b/internal/bbsimctl/commands/olt.go
@@ -33,7 +33,7 @@
 )
 
 const (
-	DEFAULT_OLT_DEVICE_HEADER_FORMAT    = "table{{ .ID }}\t{{ .SerialNumber }}\t{{ .OperState }}\t{{ .InternalState }}\t{{ .IP }}"
+	DEFAULT_OLT_DEVICE_HEADER_FORMAT    = "table{{ .ID }}\t{{ .SerialNumber }}\t{{ .OperState }}\t{{ .InternalState }}\t{{ .IP }}\t{{ .NniDhcpTrapVid }}"
 	DEFAULT_OLT_RESOURCES_HEADER_FORMAT = "table{{ .Type }}\t{{ .PonPortId }}\t{{ .OnuId }}\t{{ .PortNo }}\t{{ .ResourceId }}\t{{ .FlowId }}"
 	DEFAULT_NNI_PORT_HEADER_FORMAT      = "table{{ .ID }}\t{{ .OperState }}\t{{ .InternalState }}\t{{ .PacketCount }}"
 	DEFAULT_PON_PORT_HEADER_FORMAT      = "table{{ .ID }}\t{{ .Technology }}\t{{ .OperState }}\t{{ .InternalState }}\t{{ .PacketCount }}\t{{ .AllocatedOnuIds }}\t{{ .AllocatedGemPorts }}\t{{ .AllocatedAllocIds }}"
diff --git a/internal/common/options.go b/internal/common/options.go
index 494473c..44b571a 100644
--- a/internal/common/options.go
+++ b/internal/common/options.go
@@ -94,6 +94,7 @@
 	OmciResponseRate   uint8  `yaml:"omci_response_rate"`
 	UniPorts           uint32 `yaml:"uni_ports"`
 	PotsPorts          uint32 `yaml:"pots_ports"`
+	NniDhcpTrapVid     uint32 `yaml:"nni_dhcp_trap_vid"`
 }
 
 type PonPortsConfig struct {
@@ -333,6 +334,7 @@
 	onu := flag.Int("onu", int(conf.Olt.OnusPonPort), "Number of ONU devices per PON port to be emulated")
 	uni := flag.Int("uni", int(conf.Olt.UniPorts), "Number of Ethernet UNI Ports per ONU device to be emulated")
 	pots := flag.Int("pots", int(conf.Olt.PotsPorts), "Number of POTS UNI Ports per ONU device to be emulated")
+	NniDchpTrapVid := flag.Int("nni_dhcp_trap_vid", int(conf.Olt.NniDhcpTrapVid), "Vlan to trap the DHCP packets on")
 
 	oltRebootDelay := flag.Int("oltRebootDelay", conf.Olt.OltRebootDelay, "Time that BBSim should before restarting after a reboot")
 	omci_response_rate := flag.Int("omci_response_rate", int(conf.Olt.OmciResponseRate), "Amount of OMCI messages to respond to")
@@ -367,6 +369,7 @@
 	conf.Olt.UniPorts = uint32(*uni)
 	conf.Olt.PotsPorts = uint32(*pots)
 	conf.Olt.OnusPonPort = uint32(*onu)
+	conf.Olt.NniDhcpTrapVid = uint32(*NniDchpTrapVid)
 	conf.Olt.OltRebootDelay = *oltRebootDelay
 	conf.Olt.OmciResponseRate = uint8(*omci_response_rate)
 	conf.BBSim.ConfigFile = *configFile
@@ -450,6 +453,7 @@
 			OmciResponseRate:   10,
 			UniPorts:           4,
 			PotsPorts:          0,
+			NniDhcpTrapVid:     0,
 		},
 		BBRConfig{
 			LogLevel:  "debug",