void* ofpat_action_get (Pvoid_t *aargs, enum ofp_action_type t) { if (!(J1T (rc, *aargs, t))) { P4_LOG ("No arg for ofp_action_type"); return NULL; } else { JLG (pv, *aargs, t); return (void *) *pv; } }
void cpu_packet_init () { char *intf_name = "veth251"; if ((cpu_sock_fd = socket (AF_PACKET, SOCK_RAW, IPPROTO_RAW)) < 0) { P4_LOG ("failed to open raw socket"); exit (1); } struct ifreq ifr; memset (&ifr, 0, sizeof(ifr)); strncpy (ifr.ifr_name, intf_name, IFNAMSIZ); if (ioctl (cpu_sock_fd, SIOCGIFINDEX, (void *)&ifr) < 0) { P4_LOG ("failed to get ifindex of cpu interface"); exit (1); } cpu_ifindex = ifr.ifr_ifindex; struct sockaddr_ll addr; memset (&addr, 0, sizeof (addr)); addr.sll_family = AF_PACKET; addr.sll_ifindex = cpu_ifindex; addr.sll_protocol = htons (ETH_P_ALL); if (bind (cpu_sock_fd, (struct sockaddr *)&addr, sizeof (struct sockaddr_ll)) < 0) { P4_LOG ("bind to cpu interface failed"); exit (1); } int sock_flags = fcntl (cpu_sock_fd, F_GETFL, 0); if (fcntl (cpu_sock_fd, F_SETFL, sock_flags | O_NONBLOCK) < 0) { P4_LOG ("f_setfl on cpu interface failed"); exit (1); } }