Skip to content

Commit

Permalink
Removed unnecessary comments, debugs and whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
oskar456 committed Jul 20, 2013
1 parent dac29b7 commit 8f135d1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
5 changes: 2 additions & 3 deletions libxt_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static int dns_parse(int c, char **argv, int invert, unsigned int *flags,
if (invert)
info->invert_flags |= XT_DNS_QTYPE;
return true;
break;

case '4': /* edns0 */
if (*flags & XT_DNS_EDNS0)
xtables_error(PARAMETER_PROBLEM, "xt_dns: "
Expand All @@ -210,6 +210,7 @@ static int dns_parse(int c, char **argv, int invert, unsigned int *flags,
if (invert)
info->invert_flags |= XT_DNS_EDNS0;
return true;

case '5': /* bufsize */
if (*flags & XT_DNS_BUFSIZE)
xtables_error(PARAMETER_PROBLEM, "xt_dns: "
Expand All @@ -230,7 +231,6 @@ static void dns_print(const void *ip, const struct xt_entry_match *match, int nu
struct xt_dns_info *info = (void *) match->data;
const char *name;


printf(S1"dns"S2);
if (info->flags & XT_DNS_QUERY) {
printf("%s",S1);
Expand Down Expand Up @@ -341,4 +341,3 @@ void _init(void)
xtables_register_match(&dns_match);
xtables_register_match(&dns_match6);
}

14 changes: 2 additions & 12 deletions xt_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ void debug_dump_buf(u8 *dns, size_t len, size_t offset, char *title) {
#define debug_dump_buf(dns, len, offset, title)
#endif


// uncomment following line if you get compilation error
//#define HAVE_XT_MATCH_PARAM

#define MAX_MTU 2000
static u8 pktbuf[MAX_MTU]; /* buffer for whole packet in case skb is fragmented */

static bool skip_name(u8 *dns, size_t len, size_t *offset) {
/* skip labels */
Expand Down Expand Up @@ -80,8 +77,6 @@ static bool skip_rr(u8 *dns, size_t len, size_t *offset) {
return false;
}

static u8 pktbuf[MAX_MTU]; /* buffer for whole packet in case skb is fragmented */

#ifdef HAVE_XT_MATCH_PARAM
static bool dns_mt(const struct sk_buff *skb, const struct xt_match_param *par)
#else
Expand Down Expand Up @@ -114,8 +109,6 @@ static bool dns_mt(const struct sk_buff *skb, struct xt_action_param *par)
pr_warn(KBUILD_MODNAME": skb_header_pointer failed!\n");
return false;
}
/*dns = skb->data + (par->thoff + sizeof(struct udphdr));
len = skb_headlen(skb) - (par->thoff + sizeof(struct udphdr));*/

/* minimum DNS query payload is 17 bytes (for "." root zone) */
if (len < 17)
Expand Down Expand Up @@ -159,8 +152,6 @@ static bool dns_mt(const struct sk_buff *skb, struct xt_action_param *par)
if (!is_match)
goto qtype_out;



/* match if type=info->type, class IN */
is_match = (dns[offset-4] == 0x00) && (dns[offset-3] == info->qtype)
&& (dns[offset-2] == 0x00) && (dns[offset-2] == 0x01);
Expand All @@ -184,7 +175,6 @@ static bool dns_mt(const struct sk_buff *skb, struct xt_action_param *par)
}
if (!is_match)
goto edns0_out;
debug_dump_buf(dns, len, offset, "after_query");

/* skip answer and authority sections */
for (i=0; i<(counts[1]+counts[2]); i++) {
Expand All @@ -203,7 +193,7 @@ static bool dns_mt(const struct sk_buff *skb, struct xt_action_param *par)
if (!is_match)
break;
}
if (!is_match || i == counts[3]) {
if (!is_match || (i == counts[3])) {
is_match = false;
goto edns0_out;
}
Expand Down
3 changes: 0 additions & 3 deletions xt_dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,4 @@ struct xt_dns_info {
u_int16_t bufsize[2]; /* edns0 bufsize [min:max] */
};



#endif

0 comments on commit 8f135d1

Please sign in to comment.