Merge "Adding PPPoE and MacLearning to sadis"
diff --git a/internal/bbsim/devices/service_test.go b/internal/bbsim/devices/service_test.go
index 12ea230..fbc2bb3 100644
--- a/internal/bbsim/devices/service_test.go
+++ b/internal/bbsim/devices/service_test.go
@@ -64,7 +64,7 @@
 
 	uni := UniPort{ID: 1, Onu: onu}
 	return NewService(0, "testService", mac, &uni, 900, 900,
-		needsEapol, needsDchp, false, 64, 0, false,
+		needsEapol, needsDchp, false, false, 64, 0, false, false,
 		7, 7, 7, 7)
 }
 
diff --git a/internal/bbsim/devices/services.go b/internal/bbsim/devices/services.go
index 3546e91..b5645b8 100644
--- a/internal/bbsim/devices/services.go
+++ b/internal/bbsim/devices/services.go
@@ -70,9 +70,11 @@
 	NeedsEapol          bool
 	NeedsDhcp           bool
 	NeedsIgmp           bool
+	NeedsPPPoE          bool
 	TechnologyProfileID int
 	UniTagMatch         int
 	ConfigureMacAddress bool
+	EnableMacLearning   bool
 	UsPonCTagPriority   uint8
 	UsPonSTagPriority   uint8
 	DsPonCTagPriority   uint8
@@ -90,8 +92,9 @@
 }
 
 func NewService(id uint32, name string, hwAddress net.HardwareAddr, uni *UniPort, cTag int, sTag int,
-	needsEapol bool, needsDchp bool, needsIgmp bool, tpID int, uniTagMatch int, configMacAddress bool,
-	usPonCTagPriority uint8, usPonSTagPriority uint8, dsPonCTagPriority uint8, dsPonSTagPriority uint8) (*Service, error) {
+	needsEapol bool, needsDchp bool, needsIgmp bool, needsPPPoE bool, tpID int, uniTagMatch int, configMacAddress bool,
+	enableMacLearning bool, usPonCTagPriority uint8, usPonSTagPriority uint8, dsPonCTagPriority uint8,
+	dsPonSTagPriority uint8) (*Service, error) {
 
 	service := Service{
 		Id:                  id,
@@ -103,9 +106,11 @@
 		NeedsEapol:          needsEapol,
 		NeedsDhcp:           needsDchp,
 		NeedsIgmp:           needsIgmp,
+		NeedsPPPoE:          needsPPPoE,
 		TechnologyProfileID: tpID,
 		UniTagMatch:         uniTagMatch,
 		ConfigureMacAddress: configMacAddress,
+		EnableMacLearning:   enableMacLearning,
 		UsPonCTagPriority:   usPonCTagPriority,
 		UsPonSTagPriority:   usPonSTagPriority,
 		DsPonCTagPriority:   dsPonCTagPriority,
diff --git a/internal/bbsim/devices/uni_port.go b/internal/bbsim/devices/uni_port.go
index c60ed7a..8934efb 100644
--- a/internal/bbsim/devices/uni_port.go
+++ b/internal/bbsim/devices/uni_port.go
@@ -173,8 +173,9 @@
 
 		mac := net.HardwareAddr{0x2e, byte(olt.ID), byte(onu.PonPortID), byte(onu.ID), byte(uni.ID), byte(k)}
 		service, err := NewService(uint32(k), s.Name, mac, &uni, nextCtag[s.Name], nextStag[s.Name],
-			s.NeedsEapol, s.NeedsDhcp, s.NeedsIgmp, s.TechnologyProfileID, s.UniTagMatch,
-			s.ConfigureMacAddress, s.UsPonCTagPriority, s.UsPonSTagPriority, s.DsPonCTagPriority, s.DsPonSTagPriority)
+			s.NeedsEapol, s.NeedsDhcp, s.NeedsIgmp, s.NeedsPPPoE, s.TechnologyProfileID, s.UniTagMatch,
+			s.ConfigureMacAddress, s.EnableMacLearning, s.UsPonCTagPriority, s.UsPonSTagPriority,
+			s.DsPonCTagPriority, s.DsPonSTagPriority)
 
 		if err != nil {
 			oltLogger.WithFields(log.Fields{
diff --git a/internal/bbsim/devices/uni_port_test.go b/internal/bbsim/devices/uni_port_test.go
index 4311e80..74c0866 100644
--- a/internal/bbsim/devices/uni_port_test.go
+++ b/internal/bbsim/devices/uni_port_test.go
@@ -116,6 +116,21 @@
 				expectedStags: map[string]int{hsia: 900, voip: 333, vod: 555},
 			},
 		},
+		{"newUniPort-tt-maclearning-pppoe",
+			args{
+				services: []common.ServiceYaml{
+					{Name: hsia, CTag: 900, CTagAllocation: common.TagAllocationUnique.String(), STag: 900, STagAllocation: common.TagAllocationShared.String(), UniTagMatch: 35, TechnologyProfileID: 64},
+					{Name: voip, CTag: 444, CTagAllocation: common.TagAllocationShared.String(), STag: 333, STagAllocation: common.TagAllocationShared.String(), UniTagMatch: 65, TechnologyProfileID: 65, EnableMacLearning: true, UsPonCTagPriority: 7, UsPonSTagPriority: 7, DsPonCTagPriority: 7, DsPonSTagPriority: 7},
+					{Name: vod, CTag: 55, CTagAllocation: common.TagAllocationShared.String(), STag: 555, STagAllocation: common.TagAllocationShared.String(), UniTagMatch: 55, TechnologyProfileID: 66, NeedsDhcp: true, NeedsIgmp: true, NeedsPPPoE: true, EnableMacLearning: true, UsPonCTagPriority: 5, UsPonSTagPriority: 5, DsPonCTagPriority: 5, DsPonSTagPriority: 5},
+				},
+				nextCtag: map[string]int{hsia: 920},
+				nextStag: map[string]int{hsia: 900},
+			},
+			wants{
+				expectedCtags: map[string]int{hsia: 921, voip: 444, vod: 55},
+				expectedStags: map[string]int{hsia: 900, voip: 333, vod: 555},
+			},
+		},
 	}
 
 	for _, tt := range tests {
@@ -144,9 +159,11 @@
 				assert.Equal(t, configuredService.NeedsEapol, service.NeedsEapol)
 				assert.Equal(t, configuredService.NeedsDhcp, service.NeedsDhcp)
 				assert.Equal(t, configuredService.NeedsIgmp, service.NeedsIgmp)
+				assert.Equal(t, configuredService.NeedsPPPoE, service.NeedsPPPoE)
 				assert.Equal(t, configuredService.UniTagMatch, service.UniTagMatch)
 				assert.Equal(t, configuredService.TechnologyProfileID, service.TechnologyProfileID)
 				assert.Equal(t, configuredService.ConfigureMacAddress, service.ConfigureMacAddress)
+				assert.Equal(t, configuredService.EnableMacLearning, service.EnableMacLearning)
 				assert.Equal(t, configuredService.UsPonCTagPriority, service.UsPonCTagPriority)
 				assert.Equal(t, configuredService.DsPonCTagPriority, service.DsPonCTagPriority)
 				assert.Equal(t, configuredService.UsPonSTagPriority, service.UsPonSTagPriority)
diff --git a/internal/bbsim/responders/sadis/sadis.go b/internal/bbsim/responders/sadis/sadis.go
index 784a3fa..ce73b1b 100644
--- a/internal/bbsim/responders/sadis/sadis.go
+++ b/internal/bbsim/responders/sadis/sadis.go
@@ -109,7 +109,9 @@
 	DownstreamBandwidthProfile string `json:"downstreamBandwidthProfile,omitempty"`
 	IsDhcpRequired             bool   `json:"isDhcpRequired,omitempty"`
 	IsIgmpRequired             bool   `json:"isIgmpRequired,omitempty"`
+	IsPPPoERequired            bool   `json:"isPppoeRequired,omitempty"`
 	ConfiguredMacAddress       string `json:"configuredMacAddress,omitempty"`
+	EnableMacLearning          bool   `json:"enableMacLearning,omitempty"`
 	UsPonCTagPriority          uint8  `json:"usPonCTagPriority,omitempty"`
 	UsPonSTagPriority          uint8  `json:"usPonSTagPriority,omitempty"`
 	DsPonCTagPriority          uint8  `json:"dsPonCTagPriority,omitempty"`
@@ -208,9 +210,11 @@
 			ServiceName:                service.Name,
 			IsIgmpRequired:             service.NeedsIgmp,
 			IsDhcpRequired:             service.NeedsDhcp,
+			IsPPPoERequired:            service.NeedsPPPoE,
 			TechnologyProfileID:        service.TechnologyProfileID,
 			UpstreamBandwidthProfile:   "User_Bandwidth1",
 			DownstreamBandwidthProfile: "User_Bandwidth2",
+			EnableMacLearning:          service.EnableMacLearning,
 			PonCTag:                    service.CTag,
 			PonSTag:                    service.STag,
 		}
diff --git a/internal/common/options.go b/internal/common/options.go
index 0919de8..000a8dc 100644
--- a/internal/common/options.go
+++ b/internal/common/options.go
@@ -135,11 +135,13 @@
 	NeedsEapol          bool   `yaml:"needs_eapol"`
 	NeedsDhcp           bool   `yaml:"needs_dhcp"`
 	NeedsIgmp           bool   `yaml:"needs_igmp"`
+	NeedsPPPoE          bool   `yaml:"needs_pppoe"`
 	CTagAllocation      string `yaml:"c_tag_allocation"`
 	STagAllocation      string `yaml:"s_tag_allocation"`
 	TechnologyProfileID int    `yaml:"tp_id"`
 	UniTagMatch         int    `yaml:"uni_tag_match"`
 	ConfigureMacAddress bool   `yaml:"configure_mac_address"`
+	EnableMacLearning   bool   `yaml:"enable_mac_learning"`
 	UsPonCTagPriority   uint8  `yaml:"us_pon_c_tag_priority"`
 	UsPonSTagPriority   uint8  `yaml:"us_pon_s_tag_priority"`
 	DsPonCTagPriority   uint8  `yaml:"ds_pon_c_tag_priority"`