/* * This callback is invoked from the socket code when we * detect an incoming DHCP packet on the raw socket. */ static void ni_dhcp_socket_recv(ni_socket_t *sock) { ni_capture_t *capture = sock->user_data; ni_buffer_t buf; if (ni_capture_recv(capture, &buf) >= 0) { ni_dhcp_device_t *dev = ni_capture_get_user_data(capture); ni_dhcp_fsm_process_dhcp_packet(dev, &buf); } }
/* * This callback is invoked from the socket code when we * detect an incoming ARP packet on the raw socket. */ static void ni_arp_socket_recv(ni_socket_t *sock) { ni_capture_t *capture = sock->user_data; ni_buffer_t buf; if (ni_capture_recv(capture, &buf) >= 0) { ni_arp_socket_t *arph = ni_capture_get_user_data(capture); ni_arp_packet_t packet; if (ni_arp_parse(arph, &buf, &packet) >= 0) arph->callback(arph, &packet, arph->user_data); } }