All of lore.kernel.org
 help / color / mirror / Atom feed
From: Subhash Gopinath <subhashg@gmail.com>
To: netfilter@lists.netfilter.org
Subject: problem with hook function for DHCP
Date: Mon, 29 Nov 2004 23:58:44 -0800	[thread overview]
Message-ID: <81703d8a041129235876acd876@mail.gmail.com> (raw)

Hello all,

I am facing problems capturing DHCP packets sent from a client to a server....
Basically, the hook function (defined below) is not getting called for
each packet going out of the system.. Any ideas ?

Thanks in adv,
Subhash

-------------------------------------------------------------------------------

#define DHCP_SERVER_PORT 67

unsigned int out_hook_func(unsigned int hooknum, 
                       struct sk_buff **skb,
                       const struct net_device *in,
                       const struct net_device *out,
                       int (*okfn)(struct sk_buff *))
{

        struct udphdr *udp_hdr;
        struct sk_buff *sb = *skb;
        unsigned char *dhcp_hdr, *ptr;
        unsigned int len, sub_id, xid;

        printk (KERN_INFO "Here\n");
        /* Check if the message is valid and is a UDP message */
        if(!sb || !sb->nh.iph || sb->nh.iph->protocol != IPPROTO_UDP)
                return NF_ACCEPT;

        /* Check if the UDP message contains DHCP in the payload */
        udp_hdr = (struct udphdr *)(sb->data + ((sb->nh.iph->ihl)<<2));
        if(udp_hdr->dest != htons(DHCP_SERVER_PORT))
                return NF_ACCEPT;

        printk(KERN_INFO "DHCP packet\n");
        return NF_ACCEPT;

}

int init_module()
{
        /* Register Hook for packets sent */
        out_nfho.hook     = out_hook_func;
        //out_nfho.hooknum  = NF_IP_LOCAL_OUT;
        out_nfho.hooknum  = NF_IP_POST_ROUTING;
        out_nfho.pf       = PF_INET;
        out_nfho.priority = NF_IP_PRI_FIRST;
        nf_register_hook(&out_nfho);
}

void cleanup_module()
{
        nf_unregister_hook(&out_nfho);
}


             reply	other threads:[~2004-11-30  7:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-30  7:58 Subhash Gopinath [this message]
2004-11-30 20:41 ` problem with hook function for DHCP Jason Opperisano
  -- strict thread matches above, loose matches on Subject: below --
2004-11-30 21:52 Hudson Delbert J Contr 61 CS/SCBN
2004-11-30 23:21 ` Subhash Gopinath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81703d8a041129235876acd876@mail.gmail.com \
    --to=subhashg@gmail.com \
    --cc=netfilter@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.