Date: Sun, 12 Apr 2009 20:24:28 +0000 (UTC) From: Paolo Pisati <piso@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r190976 - user/piso/ipfw/sys/netinet/libalias Message-ID: <200904122024.n3CKOSpI038445@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: piso Date: Sun Apr 12 20:24:28 2009 New Revision: 190976 URL: http://svn.freebsd.org/changeset/base/190976 Log: Teach alias_sctp about mbuf. Modified: user/piso/ipfw/sys/netinet/libalias/alias.c user/piso/ipfw/sys/netinet/libalias/alias.h user/piso/ipfw/sys/netinet/libalias/alias_local.h user/piso/ipfw/sys/netinet/libalias/alias_sctp.c Modified: user/piso/ipfw/sys/netinet/libalias/alias.c ============================================================================== --- user/piso/ipfw/sys/netinet/libalias/alias.c Sun Apr 12 19:50:46 2009 (r190975) +++ user/piso/ipfw/sys/netinet/libalias/alias.c Sun Apr 12 20:24:28 2009 (r190976) @@ -1346,7 +1346,7 @@ LibAliasInLocked(struct libalias *la, pk break; #ifdef _KERNEL case IPPROTO_SCTP: - iresult = SctpAlias(la, pip, SN_TO_LOCAL); + iresult = SctpAlias(la, ptr, SN_TO_LOCAL); break; #endif case IPPROTO_GRE: { @@ -1497,7 +1497,7 @@ LibAliasOutLocked(struct libalias *la, p break; #ifdef _KERNEL case IPPROTO_SCTP: - iresult = SctpAlias(la, pip, SN_TO_GLOBAL); + iresult = SctpAlias(la, ptr, SN_TO_GLOBAL); break; #endif case IPPROTO_GRE: { Modified: user/piso/ipfw/sys/netinet/libalias/alias.h ============================================================================== --- user/piso/ipfw/sys/netinet/libalias/alias.h Sun Apr 12 19:50:46 2009 (r190975) +++ user/piso/ipfw/sys/netinet/libalias/alias.h Sun Apr 12 20:24:28 2009 (r190976) @@ -128,6 +128,11 @@ typedef struct mbuf ** pkt_t; (ic->icmp_ip.ip_hl << 2) - sizeof(struct ip) + 8; \ PULLUP_SIZE(pip, ptr, s); \ } while (0) + +#define PULLUP_SCTPHDR(pip, ptr) do { \ + pip = mtod(*ptr, struct ip *); \ + PULLUP_SIZE(pip, ptr, (pip->ip_hl << 2) + sizeof(struct sctphdr)); \ +} while (0) #else typedef char * pkt_t; @@ -136,6 +141,7 @@ typedef char * pkt_t; #define PULLUP_TCPHDR(pip, ptr) pip = (struct ip *)ptr #define PULLUP_ICMPHDR(pip, ptr) pip = (struct ip *)ptr #define PULLUP_ICMPIP64HDR(pip, ptr) pip = (struct ip *)ptr +#define PULLUP_SCTPHDR(pip, ptr) pip = (struct ip *)ptr #endif /* Initialization and control functions. */ Modified: user/piso/ipfw/sys/netinet/libalias/alias_local.h ============================================================================== --- user/piso/ipfw/sys/netinet/libalias/alias_local.h Sun Apr 12 19:50:46 2009 (r190975) +++ user/piso/ipfw/sys/netinet/libalias/alias_local.h Sun Apr 12 20:24:28 2009 (r190976) @@ -230,7 +230,9 @@ struct libalias { */ void AliasSctpInit(struct libalias *la); void AliasSctpTerm(struct libalias *la); -int SctpAlias(struct libalias *la, struct ip *ip, int direction); +#ifdef _KERNEL +int SctpAlias(struct libalias *la, struct mbuf **ptr, int direction); +#endif /* * We do not calculate TCP checksums when libalias is a kernel Modified: user/piso/ipfw/sys/netinet/libalias/alias_sctp.c ============================================================================== --- user/piso/ipfw/sys/netinet/libalias/alias_sctp.c Sun Apr 12 19:50:46 2009 (r190975) +++ user/piso/ipfw/sys/netinet/libalias/alias_sctp.c Sun Apr 12 20:24:28 2009 (r190976) @@ -78,6 +78,7 @@ #include <machine/stdarg.h> #include <sys/param.h> #include <sys/systm.h> +#include <sys/mbuf.h> #include <sys/kernel.h> #include <sys/module.h> #include <sys/syslog.h> @@ -100,7 +101,7 @@ * ---------------------------------------------------------------------- */ /* Packet Parsing Functions */ -static int sctp_PktParser(struct libalias *la, int direction, struct ip *pip, +static int sctp_PktParser(struct libalias *la, int direction, pkt_t ptr, struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc); static int GetAsconfVtags(struct libalias *la, struct sctp_nat_msg *sm, uint32_t *l_vtag, uint32_t *g_vtag, int direction); @@ -705,15 +706,16 @@ void AliasSctpTerm(struct libalias *la) * - Return the appropriate result to libalias * * @param la Pointer to the relevant libalias instance - * @param pip Pointer to IP packet to process + * @param ptr Pointer to IP packet to process * @param direction SN_TO_LOCAL | SN_TO_GLOBAL * * @return PKT_ALIAS_OK | PKT_ALIAS_IGNORE | PKT_ALIAS_ERROR */ int -SctpAlias(struct libalias *la, struct ip *pip, int direction) +SctpAlias(struct libalias *la, pkt_t ptr, int direction) { int rtnval; + struct ip *pip; struct sctp_nat_msg msg; struct sctp_nat_assoc *assoc = NULL; @@ -725,7 +727,8 @@ SctpAlias(struct libalias *la, struct ip sctp_CheckTimers(la); /* Check timers */ /* Parse the packet */ - rtnval = sctp_PktParser(la, direction, pip, &msg, &assoc); //using *char (change to mbuf when get code from paolo) + rtnval = sctp_PktParser(la, direction, ptr, &msg, &assoc); + PULLUP_IPHDR(pip, ptr); switch (rtnval) { case SN_PARSE_OK: break; @@ -1011,17 +1014,17 @@ TxAbortErrorM(struct libalias *la, struc * * @param la Pointer to the relevant libalias instance * @param direction SN_TO_LOCAL | SN_TO_GLOBAL - * @param pip + * @param ptr * @param sm Pointer to sctp message information * @param passoc Pointer to the association this SCTP Message belongs to * * @return SN_PARSE_OK | SN_PARSE_ERROR_* */ static int -sctp_PktParser(struct libalias *la, int direction, struct ip *pip, +sctp_PktParser(struct libalias *la, int direction, pkt_t ptr, struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc) -//sctp_PktParser(int direction, struct mbuf *ipak, int ip_hdr_len,struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc) { + struct ip *pip; struct sctphdr *sctp_hdr; struct sctp_chunkhdr *chunk_hdr; struct sctp_paramhdr *param_hdr; @@ -1041,7 +1044,7 @@ sctp_PktParser(struct libalias *la, int * Also, I am only interested in the content of INIT and ADDIP chunks */ - // no mbuf stuff from Paolo yet so ... + PULLUP_SCTPHDR(pip, ptr); sm->ip_hdr = pip; /* remove ip header length from the bytes_left */ bytes_left = ntohs(pip->ip_len) - (pip->ip_hl << 2);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904122024.n3CKOSpI038445>