1 #ifndef TRAFGEN_PROTO_H
2 #define TRAFGEN_PROTO_H
24 PROTO_L0
, /* invalid layer */
35 /* might be negative (e.g. VLAN TPID field) */
44 enum proto_layer layer
;
46 struct proto_hdr
*next
;
47 struct proto_ctx
*ctx
;
49 struct proto_field
*fields
;
52 void (*header_init
)(struct proto_hdr
*hdr
);
53 void (*header_finish
)(struct proto_hdr
*hdr
);
54 void (*packet_finish
)(struct proto_hdr
*hdr
);
55 void (*set_next_proto
)(struct proto_hdr
*hdr
, enum proto_id pid
);
58 extern void protos_init(const char *dev
);
59 extern void proto_header_register(struct proto_hdr
*hdr
);
61 extern struct proto_hdr
*proto_header_init(enum proto_id pid
);
62 extern void proto_header_finish(struct proto_hdr
*hdr
);
63 extern void proto_packet_finish(void);
64 extern struct proto_hdr
*proto_lower_default_add(struct proto_hdr
*hdr
,
67 extern struct proto_hdr
*proto_lower_header(struct proto_hdr
*hdr
);
68 extern uint8_t *proto_header_ptr(struct proto_hdr
*hdr
);
70 extern void proto_header_fields_add(struct proto_hdr
*hdr
,
71 const struct proto_field
*fields
,
74 extern bool proto_field_is_set(struct proto_hdr
*hdr
, uint32_t fid
);
75 extern void proto_field_set_bytes(struct proto_hdr
*hdr
, uint32_t fid
,
77 extern void proto_field_set_u8(struct proto_hdr
*hdr
, uint32_t fid
, uint8_t val
);
78 extern uint8_t proto_field_get_u8(struct proto_hdr
*hdr
, uint32_t fid
);
79 extern void proto_field_set_u16(struct proto_hdr
*hdr
, uint32_t fid
, uint16_t val
);
80 extern uint16_t proto_field_get_u16(struct proto_hdr
*hdr
, uint32_t fid
);
81 extern void proto_field_set_u32(struct proto_hdr
*hdr
, uint32_t fid
, uint32_t val
);
82 extern uint32_t proto_field_get_u32(struct proto_hdr
*hdr
, uint32_t fid
);
84 extern void proto_field_set_default_bytes(struct proto_hdr
*hdr
, uint32_t fid
,
86 extern void proto_field_set_default_u8(struct proto_hdr
*hdr
, uint32_t fid
,
88 extern void proto_field_set_default_u16(struct proto_hdr
*hdr
, uint32_t fid
,
90 extern void proto_field_set_default_u32(struct proto_hdr
*hdr
, uint32_t fid
,
93 extern void proto_field_set_be16(struct proto_hdr
*hdr
, uint32_t fid
, uint16_t val
);
94 extern void proto_field_set_be32(struct proto_hdr
*hdr
, uint32_t fid
, uint32_t val
);
96 extern void proto_field_set_default_be16(struct proto_hdr
*hdr
, uint32_t fid
,
98 extern void proto_field_set_default_be32(struct proto_hdr
*hdr
, uint32_t fid
,
101 extern void proto_field_set_dev_mac(struct proto_hdr
*hdr
, uint32_t fid
);
102 extern void proto_field_set_default_dev_mac(struct proto_hdr
*hdr
, uint32_t fid
);
104 extern void proto_field_set_dev_ipv4(struct proto_hdr
*hdr
, uint32_t fid
);
105 extern void proto_field_set_default_dev_ipv4(struct proto_hdr
*hdr
, uint32_t fid
);
107 #endif /* TRAFGEN_PROTO_H */