Skip to content

Commit

Permalink
Label count indexer
Browse files Browse the repository at this point in the history
- `label_count`:
  - Rename `labellen` to `label_count`
  - Add `label_count` to first test
  - Clarify man-page and add to sample config
  • Loading branch information
jelu committed Jan 21, 2022
1 parent 6932247 commit d27171f
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dsc_SOURCES = asn_index.c certain_qnames_index.c client_index.c \
idn_qname_index.c inX_addr.c ip_direction_index.c ip_proto_index.c \
ip_version_index.c md_array.c md_array_json_printer.c \
md_array_xml_printer.c msglen_index.c null_index.c opcode_index.c \
parse_conf.c pcap.c qclass_index.c qname_index.c qnamelen_index.c labellen_index.c \
parse_conf.c pcap.c qclass_index.c qname_index.c qnamelen_index.c label_count_index.c \
qr_aa_bits_index.c qtype_index.c query_classification_index.c rcode_index.c \
rd_bit_index.c server_ip_addr_index.c tc_bit_index.c tld_index.c \
transport_index.c xmalloc.c response_time_index.c tld_list.c \
Expand All @@ -37,7 +37,7 @@ dist_dsc_SOURCES = asn_index.h base64.h certain_qnames_index.h client_index.h \
do_bit_index.h edns_bufsiz_index.h edns_version_index.h geoip.h hashtbl.h \
idn_qname_index.h inX_addr.h ip_direction_index.h ip_proto_index.h \
ip_version_index.h md_array.h msglen_index.h null_index.h opcode_index.h \
parse_conf.h pcap.h qclass_index.h qname_index.h qnamelen_index.h labellen_index.h \
parse_conf.h pcap.h qclass_index.h qname_index.h qnamelen_index.h label_count_index.h \
qr_aa_bits_index.h qtype_index.h query_classification_index.h rcode_index.h \
rd_bit_index.h server_ip_addr_index.h syslog_debug.h tc_bit_index.h \
tld_index.h transport_index.h xmalloc.h response_time_index.h tld_list.h \
Expand Down
4 changes: 2 additions & 2 deletions src/dns_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "client_subnet_index.h"
#include "server_ip_addr_index.h"
#include "qnamelen_index.h"
#include "labellen_index.h"
#include "label_count_index.h"
#include "qname_index.h"
#include "msglen_index.h"
#include "certain_qnames_index.h"
Expand Down Expand Up @@ -92,7 +92,7 @@ static indexer indexers[] = {
{ "null", 0, null_indexer, null_iterator },
{ "qclass", 0, qclass_indexer, qclass_iterator, qclass_reset },
{ "qnamelen", 0, qnamelen_indexer, qnamelen_iterator, qnamelen_reset },
{ "labellen", 0, labellen_indexer, labellen_iterator, labellen_reset },
{ "label_count", 0, label_count_indexer, label_count_iterator, label_count_reset },
{ "qname", 0, qname_indexer, qname_iterator, qname_reset },
{ "second_ld", 0, second_ld_indexer, second_ld_iterator, second_ld_reset },
{ "third_ld", 0, third_ld_indexer, third_ld_iterator, third_ld_reset },
Expand Down
10 changes: 5 additions & 5 deletions src/dsc.conf.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,10 @@ section.
Note this is the \*(lqexpanded\*(rq length if the message happens to take
advantage of DNS message \*(lqcompression\*(rq.
.TP
\fBlabellen\fR
The count of labels the first (and usually only) QNAME in a DNS message question
section.
Note this count is based on the full QNAME if the message happens to take
advantage of DNS message \*(lqcompression\*(rq.
\fBlabel_count\fR
The number of labels (between "." dots) in the first (and usually only)
QNAME in a DNS message question section.
Note that a value of 0 (zero) means DNS root (.).
.TP
\fBqtype\fR
The query type (QTYPE) for the first QNAME in the DNS message question
Expand Down Expand Up @@ -952,6 +951,7 @@ dataset direction_vs_ipproto ip Direction:ip_direction IPProto:ip_proto any;
#dataset qr_aa_bits dns Direction:ip_direction QRAABits:qr_aa_bits any;
#dataset servfail_qname dns ALL:null Qname:qname servfail-only,replies-only;
#dataset ad_qname dns ALL:null Qname:qname authentic-data-only,replies-only;
#dataset label_count dns All:null LabelCount:label_count any;

#statistics_interval 60;
#no_wait_interval;
Expand Down
1 change: 1 addition & 0 deletions src/dsc.conf.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ dataset client_port_range dns All:null PortRange:dns_sport_range queries-only;
dataset direction_vs_ipproto ip Direction:ip_direction IPProto:ip_proto any;
#dataset dns_ip_version_vs_qtype dns IPVersion:dns_ip_version Qtype:qtype queries-only;
#dataset response_time dns All:null ResponseTime:response_time;
#dataset label_count dns All:null LabelCount:label_count any;

# datasets for collecting data on priming queries at root nameservers
#dataset priming_queries dns Transport:transport EDNSBufSiz:edns_bufsiz priming-query,queries-only;
Expand Down
8 changes: 4 additions & 4 deletions src/labellen_index.c → src/label_count_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@

#include "config.h"

#include "labellen_index.h"
#include "label_count_index.h"

#include <string.h>

static int largest = 0;

#define MAX_LABELS 64

int labellen_indexer(const dns_message* m)
int label_count_indexer(const dns_message* m)
{
if (m->malformed)
return -1;
Expand All @@ -67,7 +67,7 @@ int labellen_indexer(const dns_message* m)

static int next_iter;

int labellen_iterator(const char** label)
int label_count_iterator(const char** label)
{
static char label_buf[10];
if (NULL == label) {
Expand All @@ -81,7 +81,7 @@ int labellen_iterator(const char** label)
return next_iter++;
}

void labellen_reset()
void label_count_reset()
{
largest = 0;
}
12 changes: 6 additions & 6 deletions src/labellen_index.h → src/label_count_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __dsc_labellen_index_h
#define __dsc_labellen_index_h
#ifndef __dsc_label_count_index_h
#define __dsc_label_count_index_h

#include "dns_message.h"

int labellen_indexer(const dns_message*);
int labellen_iterator(const char** label);
void labellen_reset(void);
int label_count_indexer(const dns_message*);
int label_count_iterator(const char** label);
void label_count_reset(void);

#endif /* __dsc_labellen_index_h */
#endif /* __dsc_label_count_index_h */
1 change: 1 addition & 0 deletions src/test/1458044657.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dataset qr_aa_bits dns Direction:ip_direction QRAABits:qr_aa_bits any;
dataset server dns All:null IP:server any;
dataset second_ld_vs_rcode dns Rcode:rcode SecondLD:second_ld replies-only max-cells=50;
dataset third_ld_vs_rcode dns Rcode:rcode ThirdLD:third_ld replies-only max-cells=50;
dataset label_count dns All:null LabelCount:label_count any;
output_format XML;
output_format JSON;
tld_list ./1458044657.tld_list.dist;
15 changes: 15 additions & 0 deletions src/test/1458044657.json_gold
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
}
]
},
{
"name": "label_count",
"start_time": 1458044655,
"stop_time": 1458044657,
"dimensions": [ "All", "LabelCount" ],
"data": [
{
"All": "ALL",
"LabelCount": [
{ "val": "3", "count": 4 },
{ "val": "6", "count": 4 }
]
}
]
},
{
"name": "third_ld_vs_rcode",
"start_time": 1458044655,
Expand Down
10 changes: 10 additions & 0 deletions src/test/1458044657.xml_gold
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
</ifname>
</data>
</array>
<array name="label_count" dimensions="2" start_time="1458044655" stop_time="1458044657">
<dimension number="1" type="All"/>
<dimension number="2" type="LabelCount"/>
<data>
<All val="ALL">
<LabelCount val="3" count="4"/>
<LabelCount val="6" count="4"/>
</All>
</data>
</array>
<array name="third_ld_vs_rcode" dimensions="2" start_time="1458044655" stop_time="1458044657">
<dimension number="1" type="Rcode"/>
<dimension number="2" type="ThirdLD"/>
Expand Down

0 comments on commit d27171f

Please sign in to comment.