trafgen: parser: Add syntax to generate Ethernet header fields
[netsniff-ng.git] / trafgen_l2.c
blob1082049ad07a8e8ce0aa1e3b5922e3b797606f9d
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Subject to the GPL, version 2.
4 */
6 #include "built_in.h"
7 #include "trafgen_l2.h"
8 #include "trafgen_proto.h"
10 struct proto_field eth_fields[] = {
11 { .id = ETH_DST_ADDR, .len = 6, },
12 { .id = ETH_SRC_ADDR, .len = 6, .offset = 6 },
13 { .id = ETH_PROTO_ID, .len = 2, .offset = 12 },
16 static void eth_header_init(struct proto_hdr *hdr)
18 proto_header_fields_add(hdr, eth_fields, array_size(eth_fields));
20 proto_field_set_default_dev_mac(hdr, ETH_SRC_ADDR);
23 static struct proto_hdr eth_hdr = {
24 .id = PROTO_ETH,
25 .layer = PROTO_L2,
26 .header_init = eth_header_init,
29 void protos_l2_init(void)
31 proto_header_register(&eth_hdr);