void rx_callback(netif_t * netif, unsigned char *pkt, int len) { ether_header_t *ether_header = (ether_header_t *)pkt; int broad = !memcmp(ether_header->dest, broadcast, 6); //vid_border_color(255, 255, 0); if (ether_header->type[0] == 0x08 && (!memcmp(ether_header->dest, eth_mac, 6) || broad)) { if (!process_mine(pkt, len, broad)) goto end; } if (lwip_cb) { //printf("lwip cb\n"); eth_interrupt = 1; lwip_cb(netif, pkt, len); eth_interrupt = 0; goto end; } if (ether_header->type[0] != 0x08) goto end; if (ether_header->type[0] == 0x08 && broad) { if (process_broadcast(pkt, len)) goto end; } end: ; //vid_border_color(0, 0, 0); }
void dcln_process_pkt(unsigned char *pkt, int len) { ether_header_t *ether_header = (ether_header_t *)pkt; if (ether_header->type[0] != 0x08) return; if (!memcmp(ether_header->dest, broadcast, 6)) { process_broadcast(pkt, len); return; } if (!memcmp(ether_header->dest, dcln_our_mac, 6)) { process_mine(pkt, len); return; } }
static gboolean can_read_data(GIOChannel *chan, GIOCondition cond, gpointer data) { struct netlink_info *netlink = data; struct cmsghdr *cmsg; struct msghdr msg; struct iovec iov; struct nlmsghdr *nlmsg; unsigned char buffer[4096]; unsigned char control[32]; uint32_t group = 0; ssize_t len; int sk; sk = g_io_channel_unix_get_fd(chan); iov.iov_base = buffer; iov.iov_len = sizeof(buffer); memset(&msg, 0, sizeof(msg)); msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = control; msg.msg_controllen = sizeof(control); len = recvmsg(sk, &msg, 0); if (len < 0) return FALSE; util_hexdump('>', buffer, len, netlink->debug_handler, netlink->debug_data); for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { struct nl_pktinfo *pktinfo; if (cmsg->cmsg_level != SOL_NETLINK) continue; if (cmsg->cmsg_type != NETLINK_PKTINFO) continue; pktinfo = (void *) CMSG_DATA(cmsg); group = pktinfo->group; } for (nlmsg = iov.iov_base; NLMSG_OK(nlmsg, (uint32_t) len); nlmsg = NLMSG_NEXT(nlmsg, len)) { if (group > 0 && nlmsg->nlmsg_seq == 0) { process_broadcast(netlink, group, nlmsg); continue; } if (nlmsg->nlmsg_pid != netlink->pid) continue; if (nlmsg->nlmsg_flags & NLM_F_MULTI) process_multi(netlink, nlmsg); else process_message(netlink, nlmsg); } return TRUE; }