summaryrefslogtreecommitdiff
path: root/trafgen_lexer.l
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2017-06-01 13:12:29 +0300
committerTobias Klauser <tklauser@distanz.ch>2017-06-02 09:15:32 +0200
commite6c1b6ca7fd51a9b7d2b3c597cd9731b59330032 (patch)
treefb0b0c28179a60fd752090fd9b1f79dadb1308ea /trafgen_lexer.l
parent9d5e303a998e4618d492c9d0befb09e3cd3d746b (diff)
trafgen: parser: Add syntax to generate DNS header
Add new syntax for DNS header generation via 'dns()' proto function. The fields are supported: id - 16 bit identifier qr - message is a query(0) or response(1) op|oper - specified kind of query aanswer - authoritative answer flag trunc - message was truncated flag rdesired - recursion desired flag ravail - recursion available flag zero - reserved for future use rcode - response code qdcount - number of entries in question section ancount - number of entries in answer section nscount - number of entries in authority section arcount - number of entries in additional section Also there are functions to generate DNS sections: 'qry()' function to generate separate query entry: name - variable domain name type - type of the query class - class of the query 'ans()', 'auth()', 'add' functions to generate separate answer, authoritative, adidditional entry with the same fields layout: name - variable domain name type - resource record type class - class of the data ttl - time interval that the record may be cached len - length of data data - variable length of bytes All the DNS section entries will be automaticlly sorted by DNS proto API in the way which is required by DNS header: query entries answer entries authoritative entries additional entries 'name' field in qry/ans/auth/add functions is automatically converted to FQDN format if it was specified as "string". There are also added functions to simplify the way of filling some often used RR types for using them inside ans/auth/add functions: addr(ipv4_addr | ipv6_addr) - fills the following RR fields: len - 4 or 16 depends on IPv4 or IPv6 address was specified data - is filled with IPv4 or IPv6 address type - 1 for IPv4 address, 28 - for IPv6 ns(string) type - 2 cname(string) type - 5 ptr(string) type - 12 EXAMPLES: { dns(qr=1, auth(name="ns1", ns("ns1.org")), ans(name="www.google.com", cname("google.com")), auth(name="aa", ns("bb")), qry(name="www.google.com")) } { dns(qr=1, ans(name="www.google.com", addr(1.2.3.4))) } { dns(qr=1, ans(name="www.google.com", addr(1::))) } Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_lexer.l')
-rw-r--r--trafgen_lexer.l24
1 files changed, 24 insertions, 0 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l
index cf67c74..da072e1 100644
--- a/trafgen_lexer.l
+++ b/trafgen_lexer.l
@@ -239,6 +239,29 @@ ip6_addr ({v680}|{v67}|{v66}|{v65}|{v64}|{v63}|{v62}|{v61}|{v60})
"win"|"window" { return K_WINDOW; }
"urgptr" { return K_URG_PTR; }
+ /* DNS */
+"qr" { return K_QR; }
+"aa"|"aanswer" { return K_AANSWER; }
+"trunc" { return K_TRUNC; }
+"ravail" { return K_RAVAIL; }
+"rdesired" { return K_RDESIRED; }
+"zero" { return K_ZERO; }
+"rc"|"rcode" { return K_RCODE; }
+"qdcount" { return K_QDCOUNT; }
+"ancount" { return K_ANCOUNT; }
+"nscount" { return K_NSCOUNT; }
+"arcount" { return K_ARCOUNT; }
+"name" { return K_NAME; }
+"class" { return K_CLASS; }
+"data" { return K_DATA; }
+"qry"|"query" { return K_QUERY; }
+"ans"|"answer" { return K_ANSWER; }
+"auth" { return K_AUTH; }
+"add" { return K_ADD; }
+"ns" { return K_NS; }
+"cname" { return K_CNAME; }
+"ptr" { return K_PTR; }
+
"eth" { return K_ETH; }
"pause" { return K_PAUSE; }
"pfc" { return K_PFC; }
@@ -251,6 +274,7 @@ ip6_addr ({v680}|{v67}|{v66}|{v65}|{v64}|{v63}|{v62}|{v61}|{v60})
"icmp6"|"icmpv6" { return K_ICMP6; }
"udp" { return K_UDP; }
"tcp" { return K_TCP; }
+"dns" { return K_DNS; }
[ ]*"-"[ ]* { return '-'; }
[ ]*"+"[ ]* { return '+'; }