/*端口交換要使用的兩個全局端口号變量*/
int port1 = 0,port2 =雨能 0;
/*main函數中(zhōng)添加如下(xià)代碼*/
else if(argc == 5)
{
debug = atoi(argv[1]);
mid = atoi(argv[2]);
port1 = atoi(argv[3]);
port2 = atoi(argv[4]);
}
/*callback函數中(zhōn生哥g)添加如下(xià)代碼*/
if(pkt->um.inport == port1)
pkt->um.outport志歌 = port2;
else
pkt->um.outport = 影一port1;
root@HNXS:/home/hnxs/l2switch# 商愛make
gcc -o ul2switch main_ul2s明購witch.c -lua -lreg -lpthread
root@HNXS:/home/hnxs/l2sw你身itch# ./ul2switch 1 130 0 習媽2
fastU->REG Version:20180827,O電的penBox HW Version:2020210329
fastU->Register UA to FAST Kernel視爸! Wait Reply......
fastU->UA->pid:短在2132,mid:130,Register OK!
fastU->libua version你視:20180827
fastU->fast_ua_recv......
inport:2,dstmid:130,len:9友自2,dmac:FF:FF:FF:FF:FF:FF,smac:B8志船:27:EB:C1:D1:39
pkt_send_normal->人拍0xb5500470,outport:0,len:92
inport:0,dstmid:130,聽很len:92,dmac:B8:27:EB:C1:D1:39,sm開海ac:B8:27:EB:D8:83:20
pkt_send_normal->0xb5500470,ou市湖tport:2,len:92
inport:2,dstmid:130,len對學:130,dmac:B8:27:EB:D8:83:20,smac:B8:27:子內EB:C1:D1:39
pkt_send_normal->0xb5500小謝470,outport:0,len:130
inport:2,dstmid:130,len房影:130,dmac:B8:27:EB:D8:83:20,sm吧機ac:B8:27:EB:C1:D1:39
pkt_send_normal->0xb5500了拿470,outport:0,len:130
64 bytes from 192醫會.168.2.117: icmp_seq=10農紙 ttl=64 time=2.02 ms
64 bytes from 192.168.2.117: icmp線錯_seq=11 ttl=64 time=0.742人風 ms
64 bytes from 192.168.2.117: icmp南雨_seq=12 ttl=64 time=0.597 ms
主機MAC地址:B8:27:EB:D8:83:20,國多交換機端口:0
主機MAC地址:B8:27:EB:C1:D1:39,交換做體機端口:2
/*新增兩個MAC的内存格式定義,與S4平台(ARM)相關哦*/
u64 mac1 = 0x2083D8EB27B8,mac2短會 = 0x39D1C1EB27B8;
/*注釋原來端口轉發邏輯,添加MAC轉發邏輯*/
if(!ether_addr_equal(pkt->data,(u8 *)&樹章mac1))
pkt->um.outport = 0;
else if(!ether_addr_equal(pkt->d大車ata,(u8 *)&mac2))
pkt->um.outport = 2;
小國
root@HNXS:/home/hnxs/l2switc山門h# make
gcc -o ul2switch main_ul2switch.c -lua 雪高-lreg -lpthread
root@HNXS:/home/hnxs/l2醫一switch# ./ul2switch
fastU->REG Version:20180827還他,OpenBox HW Version:202國街0210329
fastU->Register UA to FAST K自車ernel! Wait Reply....低鄉..
fastU->UA->pid:2255,mid:129,Regis花相ter OK!
fastU->libua version:20180827
fastU->fast_ua_recv......
inport:0,dstmid:129,len動看:92,dmac:FF:FF:FF:FF:FF:FF,smac:B8:2知地7:EB:D8:83:20
pkt_send_normal->0xb5400470,outport:匠嗎0,len:92
inport:0,dstmid:129,len:92,dmac謝土:FF:FF:FF:FF:FF:FF,smac:B8:2業化7:EB:D8:83:20
pkt_send_normal->0xb5400470,o遠海utport:0,len:92
inport:0,dstmid:129,le好說n:92,dmac:FF:FF:FF:FF:FF:FF,smac關光:B8:27:EB:D8:83:20
pkt_send_normal->0xb5人店400470,outport:0,len:92
明請
/*192.168.2.115主機執行*/
#arp –s 192.168.2.117 b8:27:eb:d8:83:高廠20
/*192.168.2.117主機執行*做在/
#arp –s 192.168.2.11師劇5 b8:27:eb:c1:d1:39