/*端口交換要使用的兩個全局影筆端口号變量*/
int port1 = 0,port2 = 0;
林麗
/*main函數中添加如(rú)下代碼*/
else if(argc == 5)
{
debug = atoi(argv[1]);
mid = atoi(argv紅金[2]);
port1 = atoi(argv很關[3]);
port2 = atoi(ar老麗gv[4]);
}
/*callback函數中添加如(rú)下代碼*/房師
if(pkt->um.inport低上 == port1)
pkt->um.outport = port2;
else
pkt->um.outport 月線= port1;
root@HNXS:/home男謝/hnxs/l2switch# make
gcc -o ul2switch main時房_ul2switch.c -lua -lreg -車南lpthread
root@HNXS:/home/hnxs/l2switch# ./子照ul2switch 1 130 0 2
fastU->REG Version藍冷:20180827,OpenBox HW Version:20202103間黃29
fastU->Register UA to FAST K麗紅ernel! Wait Reply......
fastU->UA->pid:21內場32,mid:130,Register OK!
fastU->libua version:票呢20180827
fastU->fast_ua_recv......
inport:2,dstmid:130,l新不en:92,dmac:FF:FF:FF:FF:FF:FF,sm子身ac:B8:27:EB:C1:D1:39
pkt_send_normal->0xb55麗慢00470,outport:0,len:92
inport:0,dstmid:130,le輛理n:92,dmac:B8:27:EB:C1:D1:39,smac:B8工話:27:EB:D8:83:20
pkt_send_normal->0xb5500470,outpo為生rt:2,len:92
inport:2,dstmid:130,len:130請路,dmac:B8:27:EB:D8:83:20,s視術mac:B8:27:EB:C1:D1:39
pkt_send_normal->0友器xb5500470,outport:0,len:130
inport:2,dstmid:130,len:商自130,dmac:B8:27:EB:D8:83:20,smac:坐電B8:27:EB:C1:D1:39
pkt_send_normal->0鐵有xb5500470,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=6店得4 time=0.742 ms
64 bytes from 192.海業168.2.117: icmp_seq=12 ttl=64 tim生可e=0.597 ms
主機MAC地址:B8:27:EB:D8:83:20,交換機端口:0
主機MAC地址:B8:27:EB:C票又1: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-鐵唱>data,(u8 *)&mac2))
pkt->um.outport = 2;
能能
root@HNXS:/home市做/hnxs/l2switch# make
gcc -o ul2switch mai懂媽n_ul2switch.c -lua -lreg -lpthrea說務d
root@HNXS:/home/hnxs/l2switch# ./匠音ul2switch
fastU->REG Version:20180827,OpenBox 大小HW Version:2020210329
fastU->Register UA t不秒o FAST Kernel! Wait Reply..舞理....
fastU->UA->pid:2255,mid:刀國129,Register OK!
fastU->libua version:20180827
fastU->fast_ua_recv......
inport:0,dstmid:129,len:92,dm銀雪ac:FF:FF:FF:FF:FF:FF,smac:B8:27:EB:D8:線大83:20
pkt_send_normal->0xb5師西400470,outport:0,len:92
inport:0,dstmid:129,len:92,dmac:FF:FF兒家:FF:FF:FF:FF,smac:B8:27:EB:D8:8票票3:20
pkt_send_normal->0xb5400470,outpor紅你t:0,len:92
inport:0,dstmid:129,len:92,dmac:FF:FF那坐:FF:FF:FF:FF,smac:B8:27:EB:D8:83:20友紙
pkt_send_normal->0xb5400470,outp靜船ort: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.115 b8:27:eb:c1:d1:39銀上