diff --git a/tcp.c b/tcp.c index ee3c6e5..ccb5895 100644 --- a/tcp.c +++ b/tcp.c @@ -1059,7 +1059,7 @@ static void tcp_sock4_iov_init(void) for (i = 0; i < ARRAY_SIZE(tcp4_l2_buf); i++) { tcp4_l2_buf[i] = (struct tcp4_l2_buf_t) { - .eh = L2_BUF_ETH_IP4_INIT, + .eh = L2_BUF_ETH_INIT(ETH_P_IP), .iph = L2_BUF_IP4_INIT(IPPROTO_TCP), .th = { .doff = sizeof(struct tcphdr) / 4, .ack = 1 } }; @@ -1067,7 +1067,7 @@ static void tcp_sock4_iov_init(void) for (i = 0; i < ARRAY_SIZE(tcp4_l2_flags_buf); i++) { tcp4_l2_flags_buf[i] = (struct tcp4_l2_flags_buf_t) { - .eh = L2_BUF_ETH_IP4_INIT, + .eh = L2_BUF_ETH_INIT(ETH_P_IP), .iph = L2_BUF_IP4_INIT(IPPROTO_TCP) }; } @@ -1091,7 +1091,7 @@ static void tcp_sock6_iov_init(void) for (i = 0; i < ARRAY_SIZE(tcp6_l2_buf); i++) { tcp6_l2_buf[i] = (struct tcp6_l2_buf_t) { - .eh = L2_BUF_ETH_IP6_INIT, + .eh = L2_BUF_ETH_INIT(ETH_P_IPV6), .ip6h = L2_BUF_IP6_INIT(IPPROTO_TCP), .th = { .doff = sizeof(struct tcphdr) / 4, .ack = 1 } }; @@ -1099,7 +1099,7 @@ static void tcp_sock6_iov_init(void) for (i = 0; i < ARRAY_SIZE(tcp6_l2_flags_buf); i++) { tcp6_l2_flags_buf[i] = (struct tcp6_l2_flags_buf_t) { - .eh = L2_BUF_ETH_IP6_INIT, + .eh = L2_BUF_ETH_INIT(ETH_P_IPV6), .ip6h = L2_BUF_IP6_INIT(IPPROTO_TCP) }; } diff --git a/udp.c b/udp.c index fb3f790..4549316 100644 --- a/udp.c +++ b/udp.c @@ -329,7 +329,7 @@ static void udp_sock4_iov_init(const struct ctx *c) for (i = 0; i < ARRAY_SIZE(udp4_l2_buf); i++) { udp4_l2_buf[i] = (struct udp4_l2_buf_t) { - .eh = L2_BUF_ETH_IP4_INIT, + .eh = L2_BUF_ETH_INIT(ETH_P_IP), .iph = L2_BUF_IP4_INIT(IPPROTO_UDP) }; } @@ -370,7 +370,7 @@ static void udp_sock6_iov_init(const struct ctx *c) for (i = 0; i < ARRAY_SIZE(udp6_l2_buf); i++) { udp6_l2_buf[i] = (struct udp6_l2_buf_t) { - .eh = L2_BUF_ETH_IP6_INIT, + .eh = L2_BUF_ETH_INIT(ETH_P_IPV6), .ip6h = L2_BUF_IP6_INIT(IPPROTO_UDP) }; } diff --git a/util.h b/util.h index b4c139d..b5be7a6 100644 --- a/util.h +++ b/util.h @@ -102,18 +102,11 @@ int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags, (void *)(arg)); \ } while (0) -#define L2_BUF_ETH_IP4_INIT \ +#define L2_BUF_ETH_INIT(proto) \ { \ .h_dest = { 0 }, \ .h_source = { 0 }, \ - .h_proto = htons_constant(ETH_P_IP), \ - } - -#define L2_BUF_ETH_IP6_INIT \ - { \ - .h_dest = { 0 }, \ - .h_source = { 0 }, \ - .h_proto = htons_constant(ETH_P_IPV6), \ + .h_proto = htons_constant(proto), \ } #define L2_BUF_IP4_INIT(proto) \