Hi

I am writing some custom code into the freebsd ip stack (as a project)

I am trying to get the payload of an ip packet out of an mbuf and cast it to
the type of data being carried (an ipmp header).

When i try to get the ipmp_hdr out of the mbuf, and try to do some work with
it, i seem to be referencing the ip_hdr with the ipmp_hdr pointer (based on
the values i extract from it)

What am i doing wrong?  I have based my code on the Freebsd 3.2 icmp code
and am running under freebsd 3.2

Also, why is the ICMP_ADVLENMIN defined as (8 + sizeof(struct ip) + 8) in
ip_icmp.h ??

Below is the source for what i am doing

Hopefully someone can help

Matthew

#define IPMP_ADVLENMIN (8 + sizeof(struct ip) + 8)
void ipmp_input(struct mbuf *m, int off)
{
  struct ip          *ip_hdr;
  int                 ipmplen;
  int                 hlen;
  int                 i;
  struct ipmp_header *ipmp_hdr;

  ip_hdr  = mtod(m, struct ip *);
  ipmplen = ip_hdr->ip_len;
  hlen    = off;

/* check that the length of the data in the packet is the minimum reqd */
  if(ipmplen < IPMP_MINLEN)
    {
      ipmpstat.tooshort++;
      goto freeit;
    }

  /* pull up the header of the ipmp packet */
  i = hlen + min(ipmplen, IPMP_ADVLENMIN);

  if(m->m_len < i && (m = m_pullup(m,i)) == 0)
    {
    /* if the call fails to m_pullup, the buffer is freed automatically */
      ipmpstat.tooshort++;
      return;
    }

  /* get the ip header again as the mbuf locn has probably changed */
  ip_hdr = mtod(m, struct ip *);

  /* get the ipmp header */
  m->m_len  -= hlen;
  m->m_data += hlen;
  ipmp_hdr   = mtod(m, struct ipmp_header *);
  m->m_len  += hlen;
  m->m_data -= hlen;


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to