当前位置: 技术问答>linux和unix
关于 linux socket的绑定出口的问题,希望高手帮忙解决
来源: 互联网 发布时间:2016-07-05
本文导语: 我的程序时这样的 socket注册: struct sockaddr_ll l_addr; socket_ID=socket(AF_PACKET, SOCK_RAW, htons(ETH_P_IP)); memset(&l_addr, 0 , sizeof(l_addr)); l_addr.sll_family = AF_PACKET; l_addr.sll_ifindex = dev->ifindex; l_addr.sll_protocol = htons(ETH_P_IP)...
我的程序时这样的 socket注册:
struct sockaddr_ll l_addr;
socket_ID=socket(AF_PACKET, SOCK_RAW, htons(ETH_P_IP));
memset(&l_addr, 0 , sizeof(l_addr));
l_addr.sll_family = AF_PACKET;
l_addr.sll_ifindex = dev->ifindex;
l_addr.sll_protocol = htons(ETH_P_IP);
l_addr.sll_pkttype = PACKET_HOST ;
l_addr.sll_halen = 6;
memcpy(l_addr.sll_addr , mac_addr, 6);// mac 地址正确
if(sys_bind(fd, (struct sockaddr *)&l_addr, sizeof(l_addr))
struct sockaddr_ll l_addr;
socket_ID=socket(AF_PACKET, SOCK_RAW, htons(ETH_P_IP));
memset(&l_addr, 0 , sizeof(l_addr));
l_addr.sll_family = AF_PACKET;
l_addr.sll_ifindex = dev->ifindex;
l_addr.sll_protocol = htons(ETH_P_IP);
l_addr.sll_pkttype = PACKET_HOST ;
l_addr.sll_halen = 6;
memcpy(l_addr.sll_addr , mac_addr, 6);// mac 地址正确
if(sys_bind(fd, (struct sockaddr *)&l_addr, sizeof(l_addr))