diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2017-06-01 13:12:28 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-06-02 09:15:27 +0200 |
commit | 9d5e303a998e4618d492c9d0befb09e3cd3d746b (patch) | |
tree | 8ed2c72a573cad5acf92b62f4f0048c9cff251c4 /trafgen_l7.h | |
parent | a2524f2bc9c0e8651221ba88b6013db55cec0190 (diff) |
trafgen: l7: Add DNS header generation API
Add trafgen_l7.c module with DNS proto header generation with
support of filling DNS query/answer/authority/additional sections
as sub headers.
Introcuded new concept as 'sub header' which is needed to easy handle
DNS sections which might be added on-demand, and to simplify using
sub-header as regular header with a fields, offset, etc. There is a
parent header which contains array of pointers of sub-headers, and the
array is ordered as they are located in the parent header. The
sub-headers mostly encapsulated by the parent header which 'knows'
the semantic of them. The new proto_hdr->push_sub_header(...) callback
was added to tell the parent header to push the sub-header's fields,
sub-header also may have proto_ops which must be filled by the parent.
This sub-header concept might be used in the future if it will be needed
to support DHCP, WLAN headers.
There are 4 kinds of DNS sub-headers - query, answer, authority,
additional. 'id' of each sub-header is used to only differentiate these
types of sections. These sections have strict order inside DNS header,
and there was added the proto_hdr_move_sub_header(...) to sort them in
required order.
Actually there are only 2 proto_hdr's which describes 4 DNS sections -
query & rrecord, because rrecord covers another 3 - answer, auhority,
additional which have the same layout.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_l7.h')
-rw-r--r-- | trafgen_l7.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/trafgen_l7.h b/trafgen_l7.h new file mode 100644 index 0000000..cf19fa4 --- /dev/null +++ b/trafgen_l7.h @@ -0,0 +1,45 @@ +#ifndef TRAFGEN_L7_H +#define TRAFGEN_L7_H + +enum dns_field { + DNS_ID, + DNS_QR, + DNS_OPCODE, + DNS_AA, + DNS_TC, + DNS_RD, + DNS_RA, + DNS_ZERO, + DNS_RCODE, + DNS_QD_COUNT, + DNS_AN_COUNT, + DNS_NS_COUNT, + DNS_AR_COUNT, +}; + +enum dns_header { + DNS_UNDEF_HDR, + DNS_QUERY_HDR, + DNS_ANSWER_HDR, + DNS_AUTH_HDR, + DNS_ADD_HDR, +}; + +enum dns_query_field { + DNS_QUERY_NAME, + DNS_QUERY_TYPE, + DNS_QUERY_CLASS, +}; + +enum dns_rrecord_field { + DNS_RRECORD_NAME, + DNS_RRECORD_TYPE, + DNS_RRECORD_CLASS, + DNS_RRECORD_TTL, + DNS_RRECORD_LEN, + DNS_RRECORD_DATA, +}; + +extern void protos_l7_init(void); + +#endif /* TRAFGEN_L7_H */ |