| 733 | } |
| 734 | |
| 735 | int packet_socket_setup(unsigned int block_size, unsigned int frame_size, |
| 736 | unsigned int block_nr, unsigned int sizeof_priv, int timeout) { |
| 737 | int s = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); |
| 738 | if (s < 0) |
| 739 | die("socket(AF_PACKET): %m"); |
| 740 | |
| 741 | packet_socket_rx_ring_init(s, block_size, frame_size, block_nr, sizeof_priv, timeout); |
| 742 | |
| 743 | struct sockaddr_ll sa; |
| 744 | memset(&sa, 0, sizeof(sa)); |
| 745 | sa.sll_family = PF_PACKET; |
| 746 | sa.sll_protocol = htons(ETH_P_ALL); |
| 747 | sa.sll_ifindex = if_nametoindex("lo"); |
| 748 | sa.sll_hatype = 0; |
| 749 | sa.sll_pkttype = 0; |
| 750 | sa.sll_halen = 0; |
| 751 | |
| 752 | int rv = bind(s, (struct sockaddr *)&sa, sizeof(sa)); |
| 753 | if (rv < 0) |
| 754 | die("bind(AF_PACKET): %m"); |
| 755 | |
| 756 | return s; |
| 757 | } |
| 758 | |
| 759 | int pagealloc_pad(int count, int size) { |
| 760 | return packet_socket_setup(size, 2048, count, 0, 100); |
no test coverage detected