PERFORCE change 114202 for review
Paolo Pisati
piso at FreeBSD.org
Wed Feb 7 19:08:28 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=114202
Change 114202 by piso at piso_newluxor on 2007/02/07 19:07:31
Start teaching mbuf to libalias's modules: for now, just modify the
interfaces, and make all the modules compile. Moreover, in the main
libalias code, pullup & fix pointers after modules usage (find_handler()).
Next to go: review all the modules one by one, and pullup enough
data when they peek & poke packet's payload.
Affected files ...
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#60 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_cuseeme.c#15 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_dummy.c#15 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_ftp.c#16 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_irc.c#17 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_local.h#22 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#27 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.h#24 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_nbt.c#14 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_pptp.c#14 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_skinny.c#12 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_smedia.c#17 edit
Differences ...
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#60 (text+ko) ====
@@ -761,10 +761,12 @@
alias_port = ud->uh_dport;
ud->uh_dport = GetOriginalPort(lnk);
- /* XXX broken - Walk out chain. */
- error = find_handler(IN, UDP, la, pip, &ad);
- // XXX m_pullup()
-
+ error = find_handler(IN, UDP, la, ptr, &ad);
+ PULLUP_IPUDPHDR(pip, ptr);
+ if (pip == NULL)
+ return (PKT_ALIAS_IGNORED);
+ ud = (struct udphdr *)ip_next(pip);
+
/* If UDP checksum is not zero, then adjust since destination port */
/* is being unaliased and destination address is being altered. */
if (ud->uh_sum != 0) {
@@ -827,9 +829,11 @@
alias_address = GetAliasAddress(lnk);
alias_port = GetAliasPort(lnk);
- /* XXX broken - Walk out chain. */
- error = find_handler(OUT, UDP, la, pip, &ad);
- // XXX m_pullup()
+ error = find_handler(OUT, UDP, la, ptr, &ad);
+ PULLUP_IPUDPHDR(pip, ptr);
+ if (pip == NULL)
+ return (PKT_ALIAS_IGNORED);
+ ud = (struct udphdr *)ip_next(pip);
/* If UDP checksum is not zero, adjust since source port is */
/* being aliased and source address is being altered */
@@ -898,9 +902,11 @@
.maxpktsize = 0
};
- /* XXX broken - Walk out chain. */
- error = find_handler(IN, TCP, la, pip, &ad);
- // XXX m_pullup()
+ error = find_handler(IN, TCP, la, ptr, &ad);
+ PULLUP_IPTCPHDR(pip, ptr);
+ if (pip == NULL)
+ return (PKT_ALIAS_IGNORED);
+ tc = (struct tcphdr *)ip_next(pip);
alias_address = GetAliasAddress(lnk);
original_address = GetOriginalAddress(lnk);
@@ -1068,9 +1074,11 @@
/* Monitor TCP connection state */
TcpMonitorOut(lnk, tc->th_flags);
- /* XXX broken - Walk out chain. */
- error = find_handler(OUT, TCP, la, pip, &ad);
- // XXX m_pullup()
+ error = find_handler(OUT, TCP, la, ptr, &ad);
+ PULLUP_IPTCPHDR(pip, ptr);
+ if (pip == NULL)
+ return (PKT_ALIAS_IGNORED);
+ tc = (struct tcphdr *)ip_next(pip);
/* Adjust TCP checksum since source port is being aliased */
/* and source address is being altered */
@@ -1333,9 +1341,10 @@
.maxpktsize = 0
};
- /* XXX broken - Walk out chain. */
- error = find_handler(IN, IP, la, pip, &ad);
- // XXX m_pullup()
+ error = find_handler(IN, IP, la, ptr, &ad);
+ PULLUP_IPHDR(pip, ptr);
+ if (pip == NULL)
+ return (PKT_ALIAS_IGNORED);
if (error == 0)
iresult = PKT_ALIAS_OK;
else
@@ -1481,9 +1490,11 @@
.dport = NULL,
.maxpktsize = 0
};
- /* XXX broken - Walk out chain. */
- error = find_handler(OUT, IP, la, pip, &ad);
- // XXX m_pullup()
+
+ error = find_handler(OUT, IP, la, ptr, &ad);
+ PULLUP_IPHDR(pip, ptr);
+ if (pip == NULL)
+ return (PKT_ALIAS_IGNORED);
if (error == 0)
iresult = PKT_ALIAS_OK;
else
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_cuseeme.c#15 (text+ko) ====
@@ -56,11 +56,11 @@
#define CUSEEME_PORT_NUMBER 7648
static void
-AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip,
+AliasHandleCUSeeMeOut(struct libalias *la, pkt_t ptr,
struct alias_link *lnk);
static void
-AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip,
+AliasHandleCUSeeMeIn(struct libalias *la, pkt_t ptr,
struct in_addr original_addr);
static int
@@ -75,18 +75,18 @@
}
static int
-protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandlerin(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandleCUSeeMeIn(la, pip, *ah->oaddr);
+ AliasHandleCUSeeMeIn(la, ptr, *ah->oaddr);
return (0);
}
static int
-protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandlerout(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandleCUSeeMeOut(la, pip, ah->lnk);
+ AliasHandleCUSeeMeOut(la, ptr, ah->lnk);
return (0);
}
@@ -173,14 +173,21 @@
};
static void
-AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, struct alias_link *lnk)
+AliasHandleCUSeeMeOut(struct libalias *la, pkt_t ptr, struct alias_link *lnk)
{
- struct udphdr *ud = ip_next(pip);
+ struct ip *pip;
+ struct udphdr *ud;
+
+ PULLUP_UDPHDR(pip, ptr);
+ if (pip == NULL)
+ return;
+ ud = ip_next(pip);
if (ntohs(ud->uh_ulen) - sizeof(struct udphdr) >= sizeof(struct cu_header)) {
struct cu_header *cu;
struct alias_link *cu_lnk;
+ // XXX broken
cu = udp_next(ud);
if (cu->addr)
cu->addr = (u_int32_t) GetAliasAddress(lnk).s_addr;
@@ -196,9 +203,10 @@
}
static void
-AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, struct in_addr original_addr)
+AliasHandleCUSeeMeIn(struct libalias *la, pkt_t ptr, struct in_addr original_addr)
{
struct in_addr alias_addr;
+ struct ip *pip;
struct udphdr *ud;
struct cu_header *cu;
struct oc_header *oc;
@@ -207,8 +215,12 @@
int i;
(void)la;
+ PULLUP_UDPHDR(pip, ptr);
+ if (pip == NULL)
+ return;
alias_addr.s_addr = pip->ip_dst.s_addr;
ud = ip_next(pip);
+ // XXX broken
cu = udp_next(ud);
oc = (struct oc_header *)(cu + 1);
ci = (struct client_info *)(oc + 1);
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_dummy.c#15 (text+ko) ====
@@ -57,7 +57,7 @@
#endif
static void
-AliasHandleDummy(struct libalias *la, struct ip *ip, struct alias_data *ah);
+AliasHandleDummy(struct libalias *la, pkt_t ptr, struct alias_data *ah);
static int
fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah)
@@ -86,10 +86,10 @@
*/
static int
-protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandler(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandleDummy(la, pip, ah);
+ AliasHandleDummy(la, ptr, ah);
return (0);
}
@@ -146,7 +146,7 @@
#endif
static void
-AliasHandleDummy(struct libalias *la, struct ip *ip, struct alias_data *ah)
+AliasHandleDummy(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
; /* Dummy. */
}
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_ftp.c#16 (text+ko) ====
@@ -98,7 +98,7 @@
#define FTP_CONTROL_PORT_NUMBER 21
static void
-AliasHandleFtpOut(struct libalias *, struct ip *, struct alias_link *,
+AliasHandleFtpOut(struct libalias *, pkt_t, struct alias_link *,
int maxpacketsize);
static int
@@ -115,10 +115,10 @@
}
static int
-protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandler(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandleFtpOut(la, pip, ah->lnk, ah->maxpktsize);
+ AliasHandleFtpOut(la, ptr, ah->lnk, ah->maxpktsize);
return (0);
}
@@ -189,23 +189,28 @@
static void
AliasHandleFtpOut(
struct libalias *la,
- struct ip *pip, /* IP packet to examine/patch */
+ pkt_t ptr, /* IP packet to examine/patch */
struct alias_link *lnk, /* The link to go through (aliased port) */
int maxpacketsize /* The maximum size this packet can grow to
(including headers) */ )
{
int hlen, tlen, dlen, pflags;
char *sptr;
+ struct ip *pip;
struct tcphdr *tc;
int ftp_message_type;
/* Calculate data length of TCP packet */
+ PULLUP_TCPHDR(pip, ptr);
+ if (pip == NULL)
+ return;
tc = (struct tcphdr *)ip_next(pip);
hlen = (pip->ip_hl + tc->th_off) << 2;
tlen = ntohs(pip->ip_len);
dlen = tlen - hlen;
/* Place string pointer and beginning of data */
+ // XXX broken
sptr = (char *)pip;
sptr += hlen;
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_irc.c#17 (text+ko) ====
@@ -83,7 +83,7 @@
#define DBprintf(a)
static void
-AliasHandleIrcOut(struct libalias *, struct ip *, struct alias_link *,
+AliasHandleIrcOut(struct libalias *, pkt_t, struct alias_link *,
int maxpacketsize);
static int
@@ -100,10 +100,10 @@
}
static int
-protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandler(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandleIrcOut(la, pip, ah->lnk, ah->maxpktsize);
+ AliasHandleIrcOut(la, ptr, ah->lnk, ah->maxpktsize);
return (0);
}
@@ -154,7 +154,7 @@
static void
AliasHandleIrcOut(struct libalias *la,
- struct ip *pip, /* IP packet to examine */
+ pkt_t ptr, /* IP packet to examine */
struct alias_link *lnk, /* Which link are we on? */
int maxsize /* Maximum size of IP packet including
* headers */
@@ -164,10 +164,14 @@
struct in_addr true_addr;
u_short true_port;
char *sptr;
+ struct ip *pip;
struct tcphdr *tc;
int i; /* Iterator through the source */
/* Calculate data length of TCP packet */
+ PULLUP_TCPHDR(pip, ptr);
+ if (pip == NULL)
+ return;
tc = (struct tcphdr *)ip_next(pip);
hlen = (pip->ip_hl + tc->th_off) << 2;
tlen = ntohs(pip->ip_len);
@@ -181,6 +185,7 @@
return;
/* Place string pointer at beginning of data */
+ // XXX broken
sptr = (char *)pip;
sptr += hlen;
maxsize -= hlen; /* We're interested in maximum size of
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_local.h#22 (text+ko) ====
@@ -214,8 +214,19 @@
#define PULLUP_IPTCPHDR(pip, ptr) do { \
*ptr = m_pullup((*ptr), sizeof(struct ip)); \
(pip) = mtod(*ptr, struct ip *); \
- *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct tcphdr)); \
- (pip) = mtod(*ptr, struct ip *); \
+ if (pip != NULL) { \
+ *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct tcphdr)); \
+ (pip) = mtod(*ptr, struct ip *); \
+ } \
+} while (0)
+
+#define PULLUP_IPUDPHDR(pip, ptr) do { \
+ *ptr = m_pullup((*ptr), sizeof(struct ip)); \
+ (pip) = mtod(*ptr, struct ip *); \
+ if (pip != NULL) { \
+ *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct udphdr)); \
+ (pip) = mtod(*ptr, struct ip *); \
+ } \
} while (0)
#else
typedef char * pkt_t;
@@ -226,6 +237,7 @@
#define PULLUP_ICMPHDR(pip, ptr) pip = (struct ip *)ptr
#define PULLUP_ICMPIP64(pip, ptr, ic) pip = (struct ip *)ptr
#define PULLUP_IPTCPHDR(pip, ptr) pip = (struct ip *)ptr
+#define PULLUP_IPUDPHDR(pip, ptr) pip = (struct ip *)ptr
#endif
/*
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#27 (text+ko) ====
@@ -215,18 +215,22 @@
}
int
-find_handler(int8_t dir, int8_t proto, struct libalias *la, struct ip *pip,
+find_handler(int8_t dir, int8_t proto, struct libalias *la, pkt_t ptr,
struct alias_data *ad)
{
+ struct ip *pip;
struct proto_handler *p;
int error = ENOENT;
+ PULLUP_IPHDR(pip, ptr);
+ if (pip == NULL)
+ return (error);
LIBALIAS_RLOCK();
LIST_FOREACH(p, &handler_chain, entries) {
if ((p->dir & dir) && (p->proto & proto))
if (p->fingerprint(la, pip, ad) == 0) {
- error = p->protohandler(la, pip, ad);
+ error = p->protohandler(la, ptr, ad);
break;
}
}
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.h#24 (text+ko) ====
@@ -83,7 +83,7 @@
int (*fingerprint)(struct libalias *la, /* Fingerprint * function. */
struct ip *pip, struct alias_data *ah);
int (*protohandler)(struct libalias *la, /* Aliasing * function. */
- struct ip *pip, struct alias_data *ah);
+ pkt_t ptr, struct alias_data *ah);
LIST_ENTRY(proto_handler) entries;
};
@@ -114,7 +114,7 @@
int LibAliasDetachHandlers(struct proto_handler *);
int detach_handler(struct proto_handler *);
int find_handler(int8_t, int8_t, struct libalias *,
- struct ip *, struct alias_data *);
+ pkt_t ptr, struct alias_data *);
struct proto_handler *first_handler(void);
/* Functions used with dll module. */
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_nbt.c#14 (text+ko) ====
@@ -69,11 +69,11 @@
#define NETBIOS_DGM_PORT_NUMBER 138
static int
-AliasHandleUdpNbt(struct libalias *, struct ip *, struct alias_link *,
+AliasHandleUdpNbt(struct libalias *, pkt_t, struct alias_link *,
struct in_addr *, u_short);
static int
-AliasHandleUdpNbtNS(struct libalias *, struct ip *, struct alias_link *,
+AliasHandleUdpNbtNS(struct libalias *, pkt_t, struct alias_link *,
struct in_addr *, u_short *, struct in_addr *, u_short *);
static int
fingerprint1(struct libalias *la, struct ip *pip, struct alias_data *ah)
@@ -89,10 +89,10 @@
}
static int
-protohandler1(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandler1(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandleUdpNbt(la, pip, ah->lnk, ah->aaddr, *ah->aport);
+ AliasHandleUdpNbt(la, ptr, ah->lnk, ah->aaddr, *ah->aport);
return (0);
}
@@ -110,19 +110,23 @@
}
static int
-protohandler2in(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandler2in(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandleUdpNbtNS(la, pip, ah->lnk, ah->aaddr, ah->aport,
+ AliasHandleUdpNbtNS(la, ptr, ah->lnk, ah->aaddr, ah->aport,
ah->oaddr, ah->dport);
return (0);
}
static int
-protohandler2out(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandler2out(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
-
- AliasHandleUdpNbtNS(la, pip, ah->lnk, &pip->ip_src, ah->sport,
+ struct ip *pip;
+
+ PULLUP_IPHDR(pip, ptr);
+ if (pip == NULL)
+ return (-1);
+ AliasHandleUdpNbtNS(la, ptr, ah->lnk, &pip->ip_src, ah->sport,
ah->aaddr, ah->aport);
return (0);
}
@@ -335,12 +339,13 @@
static int
AliasHandleUdpNbt(
struct libalias *la,
- struct ip *pip, /* IP packet to examine/patch */
+ pkt_t ptr, /* IP packet to examine/patch */
struct alias_link *lnk,
struct in_addr *alias_address,
u_short alias_port
)
{
+ struct ip *pip;
struct udphdr *uh;
NbtDataHeader *ndh;
u_char *p = NULL;
@@ -350,9 +355,13 @@
(void)lnk;
/* Calculate data length of UDP packet */
+ PULLUP_UDPHDR(pip ,ptr);
+ if (pip == NULL)
+ return (-1);
uh = (struct udphdr *)ip_next(pip);
pmax = (char *)uh + ntohs(uh->uh_ulen);
+ // XXX broken
ndh = (NbtDataHeader *)udp_next(uh);
if ((char *)(ndh + 1) > pmax)
return (-1);
@@ -763,13 +772,14 @@
static int
AliasHandleUdpNbtNS(
struct libalias *la,
- struct ip *pip, /* IP packet to examine/patch */
+ pkt_t ptr, /* IP packet to examine/patch */
struct alias_link *lnk,
struct in_addr *alias_address,
u_short * alias_port,
struct in_addr *original_address,
u_short * original_port)
{
+ struct ip *pip;
struct udphdr *uh;
NbtNSHeader *nsh;
u_char *p;
@@ -784,8 +794,17 @@
nbtarg.oldport = *alias_port;
nbtarg.newaddr = *original_address;
nbtarg.newport = *original_port;
+
+ // XXX as we m_pullup() some more data below, alias_address could
+ // XXX point to junk data afterwards: invalidate it now to avoid
+ // XXX people using it later (for more info see above ->
+ // XXX protohandler2out())
+ alias_address = NULL;
/* Calculate data length of UDP packet */
+ PULLUP_UDPHDR(pip, ptr);
+ if (pip == NULL)
+ return (-1);
uh = (struct udphdr *)ip_next(pip);
nbtarg.uh_sum = &(uh->uh_sum);
nsh = (NbtNSHeader *)udp_next(uh);
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_pptp.c#14 (text+ko) ====
@@ -67,16 +67,16 @@
#define PPTP_CONTROL_PORT_NUMBER 1723
static void
-AliasHandlePptpOut(struct libalias *, struct ip *, struct alias_link *);
+AliasHandlePptpOut(struct libalias *, pkt_t, struct alias_link *);
static void
-AliasHandlePptpIn(struct libalias *, struct ip *, struct alias_link *);
+AliasHandlePptpIn(struct libalias *, pkt_t, struct alias_link *);
static int
-AliasHandlePptpGreOut(struct libalias *, struct ip *);
+AliasHandlePptpGreOut(struct libalias *, pkt_t);
static int
-AliasHandlePptpGreIn(struct libalias *, struct ip *);
+AliasHandlePptpGreIn(struct libalias *, pkt_t);
static int
fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah)
@@ -98,36 +98,36 @@
}
static int
-protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandlerin(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandlePptpIn(la, pip, ah->lnk);
+ AliasHandlePptpIn(la, ptr, ah->lnk);
return (0);
}
static int
-protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandlerout(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandlePptpOut(la, pip, ah->lnk);
+ AliasHandlePptpOut(la, ptr, ah->lnk);
return (0);
}
static int
-protohandlergrein(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandlergrein(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY ||
- AliasHandlePptpGreIn(la, pip) == 0)
+ AliasHandlePptpGreIn(la, ptr) == 0)
return (0);
return (-1);
}
static int
-protohandlergreout(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandlergreout(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- if (AliasHandlePptpGreOut(la, pip) == 0)
+ if (AliasHandlePptpGreOut(la, ptr) == 0)
return (0);
return (-1);
}
@@ -298,15 +298,19 @@
static void
AliasHandlePptpOut(struct libalias *la,
- struct ip *pip, /* IP packet to examine/patch */
+ pkt_t ptr, /* IP packet to examine/patch */
struct alias_link *lnk)
{ /* The PPTP control link */
struct alias_link *pptp_lnk;
PptpCallId cptr;
PptpCode codes;
u_int16_t ctl_type; /* control message type */
+ struct ip *pip;
struct tcphdr *tc;
+ PULLUP_IPHDR(pip, ptr);
+ if (pip == NULL)
+ return;
/* Verify valid PPTP control message */
if ((cptr = AliasVerifyPptp(pip, &ctl_type)) == NULL)
return;
@@ -345,6 +349,9 @@
cptr->cid1 = GetAliasPort(pptp_lnk);
/* Compute TCP checksum for revised packet */
+ PULLUP_TCPHDR(pip ,ptr);
+ if (pip == NULL)
+ return;
tc = (struct tcphdr *)ip_next(pip);
accumulate -= cptr->cid1;
ADJUST_CHECKSUM(accumulate, tc->th_sum);
@@ -370,15 +377,19 @@
static void
AliasHandlePptpIn(struct libalias *la,
- struct ip *pip, /* IP packet to examine/patch */
+ pkt_t ptr, /* IP packet to examine/patch */
struct alias_link *lnk)
{ /* The PPTP control link */
struct alias_link *pptp_lnk;
PptpCallId cptr;
u_int16_t *pcall_id;
u_int16_t ctl_type; /* control message type */
+ struct ip *pip;
struct tcphdr *tc;
+ PULLUP_IPHDR(pip ,ptr);
+ if (pip == NULL)
+ return;
/* Verify valid PPTP control message */
if ((cptr = AliasVerifyPptp(pip, &ctl_type)) == NULL)
return;
@@ -417,6 +428,9 @@
*pcall_id = GetOriginalPort(pptp_lnk);
/* Compute TCP checksum for modified packet */
+ PULLUP_TCPHDR(pip, ptr);
+ if (pip == NULL)
+ return;
tc = (struct tcphdr *)ip_next(pip);
accumulate -= *pcall_id;
ADJUST_CHECKSUM(accumulate, tc->th_sum);
@@ -472,11 +486,14 @@
}
static int
-AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
+AliasHandlePptpGreOut(struct libalias *la, pkt_t ptr)
{
GreHdr *gr;
struct alias_link *lnk;
+ struct ip *pip;
+ // XXX broken
+ PULLUP_IPHDR(pip, ptr);
gr = (GreHdr *) ip_next(pip);
/* Check GRE header bits. */
@@ -496,11 +513,14 @@
}
static int
-AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
+AliasHandlePptpGreIn(struct libalias *la, pkt_t ptr)
{
GreHdr *gr;
struct alias_link *lnk;
+ struct ip *pip;
+ // XXX broken
+ PULLUP_IPHDR(pip, ptr);
gr = (GreHdr *) ip_next(pip);
/* Check GRE header bits. */
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_skinny.c#12 (text+ko) ====
@@ -54,7 +54,7 @@
#endif
static void
-AliasHandleSkinny(struct libalias *, struct ip *, struct alias_link *);
+AliasHandleSkinny(struct libalias *, pkt_t ptr, struct alias_link *);
static int
fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah)
@@ -69,10 +69,10 @@
}
static int
-protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandler(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
- AliasHandleSkinny(la, pip, ah->lnk);
+ AliasHandleSkinny(la, ptr, ah->lnk);
return (0);
}
@@ -300,20 +300,25 @@
}
static void
-AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *lnk)
+AliasHandleSkinny(struct libalias *la, pkt_t ptr, struct alias_link *lnk)
{
size_t hlen, tlen, dlen;
+ struct ip *pip;
struct tcphdr *tc;
u_int32_t msgId, t, len, lip;
struct skinny_header *sd;
size_t orig_len, skinny_hdr_len = sizeof(struct skinny_header);
ConvDirection direction;
+ PULLUP_TCPHDR(pip, ptr);
+ if (pip == NULL)
+ return;
tc = (struct tcphdr *)ip_next(pip);
hlen = (pip->ip_hl + tc->th_off) << 2;
tlen = ntohs(pip->ip_len);
dlen = tlen - hlen;
+ // XXX broken
sd = (struct skinny_header *)tcp_next(tc);
/*
==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_smedia.c#17 (text+ko) ====
@@ -129,7 +129,7 @@
#define TFTP_PORT_NUMBER 69
static void
-AliasHandleRtspOut(struct libalias *, struct ip *, struct alias_link *,
+AliasHandleRtspOut(struct libalias *, pkt_t ptr, struct alias_link *,
int maxpacketsize);
static int
fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah)
@@ -150,13 +150,17 @@
}
static int
-protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah)
+protohandler(struct libalias *la, pkt_t ptr, struct alias_data *ah)
{
-
- if (ntohs(*ah->dport) == TFTP_PORT_NUMBER)
+ struct ip *pip;
+
+ if (ntohs(*ah->dport) == TFTP_PORT_NUMBER) {
+ PULLUP_IPHDR(pip, ptr);
+ if (pip == NULL)
+ return (-1);
FindRtspOut(la, pip->ip_src, pip->ip_dst,
*ah->sport, *ah->aport, IPPROTO_UDP);
- else AliasHandleRtspOut(la, pip, ah->lnk, ah->maxpktsize);
+ } else AliasHandleRtspOut(la, ptr, ah->lnk, ah->maxpktsize);
return (0);
}
@@ -477,9 +481,10 @@
}
static void
-AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *lnk, int maxpacketsize)
+AliasHandleRtspOut(struct libalias *la, pkt_t ptr, struct alias_link *lnk, int maxpacketsize)
{
int hlen, tlen, dlen;
+ struct ip *pip;
struct tcphdr *tc;
char *data;
const char *setup = "SETUP", *pna = "PNA", *str200 = "200";
@@ -489,11 +494,15 @@
(void)maxpacketsize;
+ PULLUP_TCPHDR(pip, ptr);
+ if (pip == NULL)
+ return;
tc = (struct tcphdr *)ip_next(pip);
hlen = (pip->ip_hl + tc->th_off) << 2;
tlen = ntohs(pip->ip_len);
dlen = tlen - hlen;
+ // XXX broken
data = (char *)pip;
data += hlen;
More information about the p4-projects
mailing list