Consolidate local patches into contrib/, making updates easier.
authorPeter Avalos <pavalos@dragonflybsd.org>
Thu, 11 Oct 2007 00:21:59 +0000 (00:21 +0000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Thu, 11 Oct 2007 00:21:59 +0000 (00:21 +0000)
contrib/libpcap-0.9/gencode.c
contrib/libpcap-0.9/gencode.h
contrib/libpcap-0.9/grammar.y
contrib/libpcap-0.9/scanner.l
lib/libpcap/Makefile
lib/libpcap/patches/gencode.c.patch [deleted file]
lib/libpcap/patches/gencode.h.patch [deleted file]
lib/libpcap/patches/grammar.y.patch [deleted file]
lib/libpcap/patches/scanner.l.patch [deleted file]

index 5067abc..aaec7a3 100644 (file)
@@ -84,6 +84,9 @@ static const char rcsid[] _U_ =
 #endif /*INET6*/
 #include <pcap-namedb.h>
 
+#include <netproto/802_11/ieee80211.h>
+#include <netproto/802_11/ieee80211_radiotap.h>
+
 #define ETHERMTU       1500
 
 #ifndef IPPROTO_SCTP
@@ -6535,6 +6538,21 @@ gen_pf_action(int action)
        return (b0);
 }
 
+/* IEEE 802.11 wireless header */
+struct block *
+gen_p80211_type(int type, int mask)
+{
+       struct block *b0;
+
+       if (linktype != DLT_IEEE802_11 && linktype != DLT_IEEE802_11_RADIO) {
+               bpf_error("action not supported on linktype 0x%x\n", linktype);
+               /* NOTREACHED */
+       }
+       b0 = gen_mcmp(OR_LINK, offsetof(struct ieee80211_frame, i_fc[0]),
+                     BPF_B, (bpf_int32)type, (bpf_int32)mask);
+       return (b0);
+}
+
 struct block *
 gen_acode(eaddr, q)
        register const u_char *eaddr;
index f4c5cf7..4581ff8 100644 (file)
@@ -312,6 +312,8 @@ struct block *gen_pf_reason(int);
 struct block *gen_pf_action(int);
 struct block *gen_pf_dir(int);
 
+struct block *gen_p80211_type(int, int);
+
 void bpf_optimize(struct block **);
 void bpf_error(const char *, ...)
     __attribute__((noreturn, format (printf, 1, 2)));
index eedd630..6e1ccdb 100644 (file)
@@ -55,6 +55,8 @@ struct rtentry;
 #include "pf.h"
 #include <pcap-namedb.h>
 
+#include <netproto/802_11/ieee80211.h>
+
 #ifdef HAVE_OS_PROTO_H
 #include "os-proto.h"
 #endif
@@ -63,6 +65,10 @@ struct rtentry;
                         (q).dir = (d),\
                         (q).addr = (a)
 
+static const char *ieee80211_mgt_names[] = IEEE80211_MGT_SUBTYPE_NAMES;
+static const char *ieee80211_ctl_names[] = IEEE80211_CTL_SUBTYPE_NAMES;
+static const char *ieee80211_data_names[] = IEEE80211_DATA_SUBTYPE_NAMES;
+
 int n_errors = 0;
 
 static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
@@ -109,7 +115,7 @@ pcap_parse()
 %type  <a>     arth narth
 %type  <i>     byteop pname pnum relop irelop
 %type  <blk>   and or paren not null prog
-%type  <rblk>  other pfvar
+%type  <rblk>  other pfvar p80211
 %type  <i>     atmtype atmmultitype
 %type  <blk>   atmfield
 %type  <blk>   atmfieldvalue atmvalue atmlistvalue
@@ -143,12 +149,13 @@ pcap_parse()
 %token RADIO
 %token FISU LSSU MSU
 %token SIO OPC DPC SLS
+%token TYPE SUBTYPE
 
 %type  <s> ID
 %type  <e> EID
 %type  <e> AID
 %type  <s> HID HID6
-%type  <i> NUM action reason
+%type  <i> NUM action reason type subtype type_subtype
 
 %left OR AND
 %nonassoc  '!'
@@ -340,6 +347,7 @@ other:        pqual TK_BROADCAST    { $$ = gen_broadcast($1); }
        | PPPOED                { $$ = gen_pppoed(); }
        | PPPOES                { $$ = gen_pppoes(); }
        | pfvar                 { $$ = $1; }
+       | pqual p80211          { $$ = $2; }
        ;
 
 pfvar:   PF_IFNAME ID          { $$ = gen_pf_ifname($2); }
@@ -350,6 +358,83 @@ pfvar:       PF_IFNAME ID          { $$ = gen_pf_ifname($2); }
        | PF_ACTION action      { $$ = gen_pf_action($2); }
        ;
 
+p80211:   TYPE type SUBTYPE subtype
+                               { $$ = gen_p80211_type($2 | $4,
+                                       IEEE80211_FC0_TYPE_MASK |
+                                       IEEE80211_FC0_SUBTYPE_MASK);
+                               }
+       | TYPE type             { $$ = gen_p80211_type($2,
+                                       IEEE80211_FC0_TYPE_MASK);
+                               }
+       | SUBTYPE type_subtype  { $$ = gen_p80211_type($2,
+                                       IEEE80211_FC0_TYPE_MASK |
+                                       IEEE80211_FC0_SUBTYPE_MASK);
+                               }
+       ;
+
+type:    NUM
+       | ID                    { const char *names[] = IEEE80211_TYPE_NAMES;
+                                 int i, lim;
+                                 lim = (IEEE80211_FC0_TYPE_MASK >> IEEE80211_FC0_TYPE_SHIFT) + 1;
+                                 for (i = 0; i < lim; ++i) {
+                                       if (pcap_strcasecmp($1, names[i]) == 0) {
+                                               $$ = i << IEEE80211_FC0_TYPE_SHIFT;
+                                               break;
+                                       }
+                                 }
+                                 if (i == lim)
+                                       bpf_error("unknown 802.11 type name");
+                               }
+       ;
+
+subtype:  NUM
+       | ID                    { const char **names;
+                                 int i, lim;
+                                 if ($<i>-1 == IEEE80211_FC0_TYPE_MGT)
+                                       names = ieee80211_mgt_names;
+                                 else if ($<i>-1 == IEEE80211_FC0_TYPE_CTL)
+                                       names = ieee80211_ctl_names;
+                                 else if ($<i>-1 == IEEE80211_FC0_TYPE_DATA)
+                                       names = ieee80211_data_names;
+                                 else
+                                       bpf_error("unknown 802.11 type");
+                                 lim = (IEEE80211_FC0_SUBTYPE_MASK >> IEEE80211_FC0_SUBTYPE_SHIFT) + 1;
+                                 for (i = 0; i < lim; ++i) {
+                                       if (pcap_strcasecmp($1, names[i]) == 0) {
+                                               $$ = i << IEEE80211_FC0_SUBTYPE_SHIFT;
+                                               break;
+                                       }
+                                 }
+                                 if (i == lim)
+                                       bpf_error("unknown 802.11 subtype name");
+                               }
+       ;
+
+type_subtype:  ID              { const char **sub_names[] = {
+                                       ieee80211_mgt_names,
+                                       ieee80211_ctl_names,
+                                       ieee80211_data_names
+                                 };
+                                 int i, j, lim, sub_lim;
+                                 sub_lim = sizeof(sub_names) / sizeof(sub_names[0]);
+                                 lim = (IEEE80211_FC0_SUBTYPE_MASK >> IEEE80211_FC0_SUBTYPE_SHIFT) + 1;
+                                 for (i = 0; i < sub_lim; ++i) {
+                                       const char **names = sub_names[i];
+                                       for (j = 0; j < lim; ++j) {
+                                               if (pcap_strcasecmp($1, names[j]) == 0)
+                                                       break;
+                                       }
+                                       if (j != lim) {
+                                               $$ = (i << IEEE80211_FC0_TYPE_SHIFT) |
+                                                    (j << IEEE80211_FC0_SUBTYPE_SHIFT);
+                                               break;
+                                       }
+                                 }
+                                 if (i == sub_lim)
+                                       bpf_error("unknown 802.11 subtype name");
+                               }
+               ;
+
 reason:          NUM                   { $$ = $1; }
        | ID                    { const char *reasons[] = PFRES_NAMES;
                                  int i;
index 01face1..52faed0 100644 (file)
@@ -247,6 +247,9 @@ protochain  {
 
 gateway                return GATEWAY;
 
+type           return TYPE;
+subtype                return SUBTYPE;
+
 less           return LESS;
 greater                return GREATER;
 byte           return CBYTE;
index c525ba4..f71ec88 100644 (file)
@@ -1,18 +1,14 @@
 # Makefile for libpcap
 # $FreeBSD: src/lib/libpcap/Makefile,v 1.24.2.4 2002/07/22 14:21:50 ru Exp $
-# $DragonFly: src/lib/libpcap/Makefile,v 1.10 2007/03/16 12:59:10 sephe Exp $
+# $DragonFly: src/lib/libpcap/Makefile,v 1.11 2007/10/11 00:21:59 pavalos Exp $
 
 SRCDIR=        ${.CURDIR}/../../contrib/libpcap-0.9
-CONTRIBDIR=${SRCDIR}
-
-PATCHES!= echo ${.CURDIR}/patches/*.patch
 
 LIB=    pcap
 SRCS=  grammar.y tokdefs.h pcap-bpf.c version.h \
        pcap.c inet.c fad-getad.c gencode.c optimize.c nametoaddr.c \
        etherent.c savefile.c bpf_filter.c bpf_image.c bpf_dump.c \
        scanner.l version.c
-SRCS+= ${PATCHES}
 INCS=  pcap.h pcap-namedb.h pcap-bpf.h pcap-int.h
 MAN=   pcap.3
 CLEANFILES=tokdefs.h version.c version.h
diff --git a/lib/libpcap/patches/gencode.c.patch b/lib/libpcap/patches/gencode.c.patch
deleted file mode 100644 (file)
index 0b36a64..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-$DragonFly: src/lib/libpcap/patches/Attic/gencode.c.patch,v 1.1 2007/03/16 12:59:10 sephe Exp $
-Index: gencode.c
-===================================================================
-RCS file: /opt/df_cvs/src/contrib/libpcap-0.9/gencode.c,v
-retrieving revision 1.1.1.1
-diff -u -r1.1.1.1 gencode.c
---- gencode.c  25 Dec 2006 00:32:18 -0000      1.1.1.1
-+++ gencode.c  10 Mar 2007 04:51:54 -0000
-@@ -84,6 +84,9 @@
- #endif /*INET6*/
- #include <pcap-namedb.h>
-+#include <netproto/802_11/ieee80211.h>
-+#include <netproto/802_11/ieee80211_radiotap.h>
-+
- #define ETHERMTU      1500
- #ifndef IPPROTO_SCTP
-@@ -6303,6 +6306,21 @@
-       return (b0);
- }
-+/* IEEE 802.11 wireless header */
-+struct block *
-+gen_p80211_type(int type, int mask)
-+{
-+      struct block *b0;
-+
-+      if (linktype != DLT_IEEE802_11 && linktype != DLT_IEEE802_11_RADIO) {
-+              bpf_error("action not supported on linktype 0x%x\n", linktype);
-+              /* NOTREACHED */
-+      }
-+      b0 = gen_mcmp(OR_LINK, offsetof(struct ieee80211_frame, i_fc[0]),
-+                    BPF_B, (bpf_int32)type, (bpf_int32)mask);
-+      return (b0);
-+}
-+
- struct block *
- gen_acode(eaddr, q)
-       register const u_char *eaddr;
diff --git a/lib/libpcap/patches/gencode.h.patch b/lib/libpcap/patches/gencode.h.patch
deleted file mode 100644 (file)
index 58ce10b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-$DragonFly: src/lib/libpcap/patches/Attic/gencode.h.patch,v 1.1 2007/03/16 12:59:10 sephe Exp $
-Index: gencode.h
-===================================================================
-RCS file: /opt/df_cvs/src/contrib/libpcap-0.9/gencode.h,v
-retrieving revision 1.1.1.1
-diff -u -r1.1.1.1 gencode.h
---- gencode.h  25 Dec 2006 00:32:18 -0000      1.1.1.1
-+++ gencode.h  9 Mar 2007 10:26:11 -0000
-@@ -306,6 +306,8 @@
- struct block *gen_pf_action(int);
- struct block *gen_pf_dir(int);
-+struct block *gen_p80211_type(int, int);
-+
- void bpf_optimize(struct block **);
- void bpf_error(const char *, ...)
-     __attribute__((noreturn, format (printf, 1, 2)));
diff --git a/lib/libpcap/patches/grammar.y.patch b/lib/libpcap/patches/grammar.y.patch
deleted file mode 100644 (file)
index b8fb46f..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-$DragonFly: src/lib/libpcap/patches/Attic/grammar.y.patch,v 1.2 2007/08/07 18:12:02 pavalos Exp $
---- grammar.y.orig     2007-08-07 12:56:23.000000000 -0400
-+++ grammar.y  2007-08-07 12:56:02.000000000 -0400
-@@ -55,6 +55,8 @@
- #include "pf.h"
- #include <pcap-namedb.h>
-+#include <netproto/802_11/ieee80211.h>
-+
- #ifdef HAVE_OS_PROTO_H
- #include "os-proto.h"
- #endif
-@@ -63,6 +65,10 @@
-                        (q).dir = (d),\
-                        (q).addr = (a)
-+static const char *ieee80211_mgt_names[] = IEEE80211_MGT_SUBTYPE_NAMES;
-+static const char *ieee80211_ctl_names[] = IEEE80211_CTL_SUBTYPE_NAMES;
-+static const char *ieee80211_data_names[] = IEEE80211_DATA_SUBTYPE_NAMES;
-+
- int n_errors = 0;
- static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
-@@ -109,7 +115,7 @@
- %type <a>     arth narth
- %type <i>     byteop pname pnum relop irelop
- %type <blk>   and or paren not null prog
--%type <rblk>  other pfvar
-+%type <rblk>  other pfvar p80211
- %type <i>     atmtype atmmultitype
- %type <blk>   atmfield
- %type <blk>   atmfieldvalue atmvalue atmlistvalue
-@@ -143,12 +149,13 @@
- %token        RADIO
- %token        FISU LSSU MSU
- %token        SIO OPC DPC SLS
-+%token        TYPE SUBTYPE
- %type <s> ID
- %type <e> EID
- %type <e> AID
- %type <s> HID HID6
--%type <i> NUM action reason
-+%type <i> NUM action reason type subtype type_subtype
- %left OR AND
- %nonassoc  '!'
-@@ -340,6 +347,7 @@
-       | PPPOED                { $$ = gen_pppoed(); }
-       | PPPOES                { $$ = gen_pppoes(); }
-       | pfvar                 { $$ = $1; }
-+      | pqual p80211          { $$ = $2; }
-       ;
- pfvar:          PF_IFNAME ID          { $$ = gen_pf_ifname($2); }
-@@ -350,6 +358,83 @@
-       | PF_ACTION action      { $$ = gen_pf_action($2); }
-       ;
-+p80211:   TYPE type SUBTYPE subtype
-+                              { $$ = gen_p80211_type($2 | $4,
-+                                      IEEE80211_FC0_TYPE_MASK |
-+                                      IEEE80211_FC0_SUBTYPE_MASK);
-+                              }
-+      | TYPE type             { $$ = gen_p80211_type($2,
-+                                      IEEE80211_FC0_TYPE_MASK);
-+                              }
-+      | SUBTYPE type_subtype  { $$ = gen_p80211_type($2,
-+                                      IEEE80211_FC0_TYPE_MASK |
-+                                      IEEE80211_FC0_SUBTYPE_MASK);
-+                              }
-+      ;
-+
-+type:   NUM
-+      | ID                    { const char *names[] = IEEE80211_TYPE_NAMES;
-+                                int i, lim;
-+                                lim = (IEEE80211_FC0_TYPE_MASK >> IEEE80211_FC0_TYPE_SHIFT) + 1;
-+                                for (i = 0; i < lim; ++i) {
-+                                      if (pcap_strcasecmp($1, names[i]) == 0) {
-+                                              $$ = i << IEEE80211_FC0_TYPE_SHIFT;
-+                                              break;
-+                                      }
-+                                }
-+                                if (i == lim)
-+                                      bpf_error("unknown 802.11 type name");
-+                              }
-+      ;
-+
-+subtype:  NUM
-+      | ID                    { const char **names;
-+                                int i, lim;
-+                                if ($<i>-1 == IEEE80211_FC0_TYPE_MGT)
-+                                      names = ieee80211_mgt_names;
-+                                else if ($<i>-1 == IEEE80211_FC0_TYPE_CTL)
-+                                      names = ieee80211_ctl_names;
-+                                else if ($<i>-1 == IEEE80211_FC0_TYPE_DATA)
-+                                      names = ieee80211_data_names;
-+                                else
-+                                      bpf_error("unknown 802.11 type");
-+                                lim = (IEEE80211_FC0_SUBTYPE_MASK >> IEEE80211_FC0_SUBTYPE_SHIFT) + 1;
-+                                for (i = 0; i < lim; ++i) {
-+                                      if (pcap_strcasecmp($1, names[i]) == 0) {
-+                                              $$ = i << IEEE80211_FC0_SUBTYPE_SHIFT;
-+                                              break;
-+                                      }
-+                                }
-+                                if (i == lim)
-+                                      bpf_error("unknown 802.11 subtype name");
-+                              }
-+      ;
-+
-+type_subtype: ID              { const char **sub_names[] = {
-+                                      ieee80211_mgt_names,
-+                                      ieee80211_ctl_names,
-+                                      ieee80211_data_names
-+                                };
-+                                int i, j, lim, sub_lim;
-+                                sub_lim = sizeof(sub_names) / sizeof(sub_names[0]);
-+                                lim = (IEEE80211_FC0_SUBTYPE_MASK >> IEEE80211_FC0_SUBTYPE_SHIFT) + 1;
-+                                for (i = 0; i < sub_lim; ++i) {
-+                                      const char **names = sub_names[i];
-+                                      for (j = 0; j < lim; ++j) {
-+                                              if (pcap_strcasecmp($1, names[j]) == 0)
-+                                                      break;
-+                                      }
-+                                      if (j != lim) {
-+                                              $$ = (i << IEEE80211_FC0_TYPE_SHIFT) |
-+                                                   (j << IEEE80211_FC0_SUBTYPE_SHIFT);
-+                                              break;
-+                                      }
-+                                }
-+                                if (i == sub_lim)
-+                                      bpf_error("unknown 802.11 subtype name");
-+                              }
-+              ;
-+
- reason:         NUM                   { $$ = $1; }
-       | ID                    { const char *reasons[] = PFRES_NAMES;
-                                 int i;
diff --git a/lib/libpcap/patches/scanner.l.patch b/lib/libpcap/patches/scanner.l.patch
deleted file mode 100644 (file)
index 5257440..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-$DragonFly: src/lib/libpcap/patches/Attic/scanner.l.patch,v 1.1 2007/03/16 12:59:10 sephe Exp $
-Index: scanner.l
-===================================================================
-RCS file: /opt/df_cvs/src/contrib/libpcap-0.9/scanner.l,v
-retrieving revision 1.1.1.1
-diff -u -r1.1.1.1 scanner.l
---- scanner.l  25 Dec 2006 00:32:20 -0000      1.1.1.1
-+++ scanner.l  9 Mar 2007 10:26:11 -0000
-@@ -247,6 +247,9 @@
- gateway               return GATEWAY;
-+type          return TYPE;
-+subtype               return SUBTYPE;
-+
- less          return LESS;
- greater               return GREATER;
- byte          return CBYTE;