X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b0d623f7f2ae71ed96e60569f61f9a9a27016e80..5c9f46613a83ebfc29a5b1f099448259e96a98f0:/bsd/net/pf_osfp.c diff --git a/bsd/net/pf_osfp.c b/bsd/net/pf_osfp.c index fcd823cfa..2dc1e241c 100644 --- a/bsd/net/pf_osfp.c +++ b/bsd/net/pf_osfp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Apple Inc. All rights reserved. + * Copyright (c) 2007-2011 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -86,7 +86,7 @@ static void pf_osfp_insert(struct pf_osfp_list *, struct pf_os_fingerprint *); * Returns the list of possible OSes. */ struct pf_osfp_enlist * -pf_osfp_fingerprint(struct pf_pdesc *pd, struct mbuf *m, int off, +pf_osfp_fingerprint(struct pf_pdesc *pd, pbuf_t *pbuf, int off, const struct tcphdr *tcp) { struct ip *ip; @@ -99,17 +99,17 @@ pf_osfp_fingerprint(struct pf_pdesc *pd, struct mbuf *m, int off, return (NULL); if (pd->af == PF_INET) { - ip = mtod(m, struct ip *); + ip = pbuf->pb_data; ip6 = (struct ip6_hdr *)NULL; } else { ip = (struct ip *)NULL; - ip6 = mtod(m, struct ip6_hdr *); + ip6 = pbuf->pb_data; } - if (!pf_pull_hdr(m, off, hdr, tcp->th_off << 2, NULL, NULL, + if (!pf_pull_hdr(pbuf, off, hdr, tcp->th_off << 2, NULL, NULL, pd->af)) return (NULL); - return (pf_osfp_fingerprint_hdr(ip, ip6, (struct tcphdr *)hdr)); + return (pf_osfp_fingerprint_hdr(ip, ip6, (struct tcphdr *)(void *)hdr)); } struct pf_osfp_enlist * @@ -312,7 +312,7 @@ int pf_osfp_add(struct pf_osfp_ioctl *fpioc) { struct pf_os_fingerprint *fp, fpadd; - struct pf_osfp_entry *entry; + struct pf_osfp_entry *entry, *uentry; memset(&fpadd, 0, sizeof (fpadd)); fpadd.fp_tcpopts = fpioc->fp_tcpopts; @@ -324,6 +324,12 @@ pf_osfp_add(struct pf_osfp_ioctl *fpioc) fpadd.fp_wscale = fpioc->fp_wscale; fpadd.fp_ttl = fpioc->fp_ttl; + uentry = &fpioc->fp_os; + uentry->fp_entry.sle_next = NULL; + uentry->fp_class_nm[sizeof (uentry->fp_class_nm) - 1] = '\0'; + uentry->fp_version_nm[sizeof (uentry->fp_version_nm) - 1] = '\0'; + uentry->fp_subtype_nm[sizeof (uentry->fp_subtype_nm) - 1] = '\0'; + DPFPRINTF("adding osfp %s %s %s = %s%d:%d:%d:%s%d:0x%llx %d " "(TS=%s,M=%s%d,W=%s%d) %x\n", fpioc->fp_os.fp_class_nm, fpioc->fp_os.fp_version_nm, @@ -527,6 +533,7 @@ pf_osfp_get(struct pf_osfp_ioctl *fpioc) fpioc->fp_getnum = num; memcpy(&fpioc->fp_os, entry, sizeof (fpioc->fp_os)); + fpioc->fp_os.fp_entry.sle_next = NULL; return (0); } } @@ -549,7 +556,7 @@ pf_osfp_validate(void) if (find.fp_mss == 0) find.fp_mss = 128; if (f->fp_flags & PF_OSFP_WSIZE_MSS) - find.fp_wsize *= find.fp_mss, 1; + find.fp_wsize *= find.fp_mss; else if (f->fp_flags & PF_OSFP_WSIZE_MTU) find.fp_wsize *= (find.fp_mss + 40); else if (f->fp_flags & PF_OSFP_WSIZE_MOD)