X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=tests%2Fdata_plane%2Fvpp_lite_topo%2Fscripts%2Fdhcp_client.py;fp=tests%2Fdata_plane%2Fvpp_lite_topo%2Fscripts%2Fdhcp_client.py;h=8e49426ed16ec96a715b0767287fd3f2385c6d90;hb=0b237f3cd02f6c59252e8270c97c015c7a148cd2;hp=0000000000000000000000000000000000000000;hpb=9047c7fbf1c811f07c69f778914d25d2652651f3;p=one.git diff --git a/tests/data_plane/vpp_lite_topo/scripts/dhcp_client.py b/tests/data_plane/vpp_lite_topo/scripts/dhcp_client.py new file mode 100644 index 0000000..8e49426 --- /dev/null +++ b/tests/data_plane/vpp_lite_topo/scripts/dhcp_client.py @@ -0,0 +1,31 @@ +import sys +from scapy.all import * + +def p(s): + print 'DHCP client: {}'.format(s) + +def main(argv): + src_mac = argv[1] + dhcp_src = argv[2] + + # needed for scapy not to match replies since DHCP uses broadcast addresses + # which wouldn't work + conf.checkIPaddr = False + + while True: + discover = Ether(dst='ff:ff:ff:ff:ff:ff', src=src_mac)/ \ + IP(src='0.0.0.0', dst='255.255.255.255')/ \ + UDP(dport=67,sport=68)/ \ + BOOTP(op=1, chaddr=src_mac)/ \ + DHCP(options=[('message-type', 'discover'), ('end')]) + + ans,unans = srp(discover, timeout=3) + for snd,rcv in ans: + if rcv[IP].src == dhcp_src: + exit(0) + else: + p('Unexpected DHCP packet source address! ({})'.format(rcv[IP].src)) + exit(1) + +if __name__ == "__main__": + main(sys.argv)