• Main Page
  • Modules
  • Data Structures
  • Files
  • File List

parse.c

00001 /*
00002  * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org>
00003  *
00004  * This software may be used and distributed according to the terms
00005  * of the GNU General Public License, incorporated herein by reference.
00006  */
00007 
00008 #include "internal/internal.h"
00009 
00010 int __parse_expect_message_type(const struct nlmsghdr *nlh)
00011 {
00012         u_int16_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);
00013         u_int16_t flags = nlh->nlmsg_flags;
00014         int ret = NFCT_T_UNKNOWN;
00015 
00016         if (type == IPCTNL_MSG_EXP_NEW) {
00017                 if (flags & (NLM_F_CREATE|NLM_F_EXCL))
00018                         ret = NFCT_T_NEW;
00019                 else
00020                         ret = NFCT_T_UPDATE;
00021         } else if (type == IPCTNL_MSG_EXP_DELETE)
00022                 ret = NFCT_T_DESTROY;
00023 
00024         return ret;
00025 }
00026 
00027 void __parse_expect(const struct nlmsghdr *nlh,
00028                     struct nfattr *cda[],
00029                     struct nf_expect *exp)
00030 {
00031         struct nfgenmsg *nfhdr = NLMSG_DATA(nlh);
00032 
00033         /* XXX: this is ugly, clean it up, please */
00034         exp->expected.tuple[__DIR_ORIG].l3protonum = nfhdr->nfgen_family;
00035         set_bit(ATTR_ORIG_L3PROTO, exp->expected.set);
00036 
00037         exp->mask.tuple[__DIR_REPL].l3protonum = nfhdr->nfgen_family;
00038         set_bit(ATTR_ORIG_L3PROTO, exp->mask.set);
00039 
00040         if (cda[CTA_EXPECT_TUPLE-1])
00041                 __parse_tuple(cda[CTA_EXPECT_TUPLE-1], 
00042                               &exp->expected.tuple[__DIR_ORIG],
00043                               __DIR_ORIG,
00044                               exp->set);
00045 
00046         if (cda[CTA_EXPECT_MASK-1])
00047                 __parse_tuple(cda[CTA_EXPECT_MASK-1], 
00048                               &exp->mask.tuple[__DIR_ORIG], 
00049                               __DIR_ORIG,
00050                               exp->set);
00051 
00052         if (cda[CTA_EXPECT_TIMEOUT-1]) {
00053                 exp->timeout = 
00054                       ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_TIMEOUT-1]));
00055                 set_bit(ATTR_EXP_TIMEOUT, exp->set);
00056         }
00057 
00058         if (cda[CTA_EXPECT_ZONE-1]) {
00059                 exp->zone =
00060                       ntohs(*(u_int16_t *)NFA_DATA(cda[CTA_EXPECT_ZONE-1]));
00061                 set_bit(ATTR_EXP_ZONE, exp->set);
00062         }
00063         if (cda[CTA_EXPECT_FLAGS-1]) {
00064                 exp->flags =
00065                       ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_FLAGS-1]));
00066                 set_bit(ATTR_EXP_FLAGS, exp->set);
00067         }
00068 }

Generated on Wed Jan 26 2011 23:11:37 for libnetfilter_conntrack by  doxygen 1.7.1