From owner-freebsd-hackers Tue May 2 5:11:45 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mailserv.waikato.ac.nz (mailserv.waikato.ac.nz [130.217.66.61]) by hub.freebsd.org (Postfix) with ESMTP id F3A9437B6EE for ; Tue, 2 May 2000 05:11:36 -0700 (PDT) (envelope-from mjl12@waikato.ac.nz) Received: from stu_ex3.waikato.ac.nz (stu-ex3.waikato.ac.nz [130.217.70.30]) by mailserv.waikato.ac.nz (8.9.3/8.9.0) with ESMTP id AAA64474 for ; Wed, 3 May 2000 00:12:46 +1200 Received: by stu-ex3.waikato.ac.nz with Internet Mail Service (5.5.2650.21) id ; Wed, 3 May 2000 00:11:22 +1200 Message-ID: <45E87454FFC2D211AD9800508B6500942392F8@stu-ex1.waikato.ac.nz> From: "MATTHEW JOHN,LUCKIE" To: "'freebsd-hackers@freebsd.org '" Subject: mbufs & ip stack Date: Wed, 3 May 2000 00:11:07 +1200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message