VOL-1119 BBSim - DHCP emulation

Change-Id: Iaa1a046715c7de99297246b4842784ef16c57acb
diff --git a/core/core_server.go b/core/core_server.go
index 39f4ca7..9e609c5 100644
--- a/core/core_server.go
+++ b/core/core_server.go
@@ -198,6 +198,31 @@
 				errchan <- err
 				return
 			}
+
+			if s.Mode == BOTH {
+				go func() {
+					defer func() {
+						log.Println("exeDHCPTest Done")
+					}()
+					info, err := s.identifyNniIoinfo("outside")
+					setup.ActivateDHCPServer(info.name, s.DhcpServerIP)
+
+					infos, err := s.getUniIoinfos("outside")
+					if err != nil {
+						errchan <- err
+						return
+					}
+					univeths := []string{}
+					for _, info := range infos {
+						univeths = append(univeths, info.name)
+					}
+					err = s.exeDHCPTest(univeths)
+					if err != nil {
+						errchan <- err
+						return
+					}
+				}()
+			}
 		}()
 		wg.Wait()
 		tearDown(vethenv) // Grace teardown
@@ -315,6 +340,25 @@
 	return nil
 }
 
+func (s *Server) exeDHCPTest(vethenv []string) error {
+	log.Println("exeDHCPTest Start")
+	for i := 0; i < s.DhcpWait; i++ {
+		select {
+		case <-s.Endchan:
+			log.Println("exeDHCPTest thread receives close !")
+			return nil
+		default:
+			log.Println("exeDHCPTest is now sleeping....")
+			time.Sleep(time.Second)
+		}
+	}
+	err := setup.ActivateDHCPClients(vethenv)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
 func (s *Server) onuPacketOut(intfid uint32, onuid uint32, rawpkt gopacket.Packet) error {
 	layerEth := rawpkt.Layer(layers.LayerTypeEthernet)
 	if layerEth != nil {