Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpcap Import libpcap 0.8.3 from tcpdump.org



details:   https://anonhg.NetBSD.org/src/rev/f089cde07793
branches:  trunk
changeset: 570054:f089cde07793
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Sun Sep 19 21:31:39 2004 +0000

description:
Import libpcap 0.8.3 from tcpdump.org

diffstat:

 lib/libpcap/atmuni31.h    |   89 ++++++
 lib/libpcap/bpf_dump.c    |   69 +++++
 lib/libpcap/fad-getad.c   |  250 +++++++++++++++++++
 lib/libpcap/llc.h         |   71 +++++
 lib/libpcap/pcap-bpf.h    |  598 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/libpcap/pcap-stdinc.h |   63 ++++
 lib/libpcap/sunatmpos.h   |   47 +++
 7 files changed, 1187 insertions(+), 0 deletions(-)

diffs (truncated from 1215 to 300 lines):

diff -r d4e25906cd18 -r f089cde07793 lib/libpcap/atmuni31.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpcap/atmuni31.h    Sun Sep 19 21:31:39 2004 +0000
@@ -0,0 +1,89 @@
+.\" $NetBSD: atmuni31.h,v 1.1.1.1 2004/09/19 21:31:45 dyoung Exp $
+.\
+/*
+ * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Yen Yen Lim and
+        North Dakota State University
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @(#) Header: /tcpdump/master/libpcap/atmuni31.h,v 1.1 2002/07/11 09:06:32 guy Exp  (LBL)
+ */
+
+/* Based on UNI3.1 standard by ATM Forum */
+
+/* ATM traffic types based on VPI=0 and (the following VCI */
+#define PPC                    0x05    /* Point-to-point signal msg */
+#define BCC                    0x02    /* Broadcast signal msg */
+#define OAMF4SC                        0x03    /* Segment OAM F4 flow cell */
+#define OAMF4EC                        0x04    /* End-to-end OAM F4 flow cell */
+#define METAC                  0x01    /* Meta signal msg */
+#define ILMIC                  0x10    /* ILMI msg */
+
+/* Q.2931 signalling messages */
+#define CALL_PROCEED           0x02    /* call proceeding */
+#define CONNECT                        0x07    /* connect */
+#define CONNECT_ACK            0x0f    /* connect_ack */
+#define SETUP                  0x05    /* setup */
+#define RELEASE                        0x4d    /* release */
+#define RELEASE_DONE           0x5a    /* release_done */
+#define RESTART                        0x46    /* restart */
+#define RESTART_ACK            0x4e    /* restart ack */
+#define STATUS                 0x7d    /* status */
+#define STATUS_ENQ             0x75    /* status ack */
+#define ADD_PARTY              0x80    /* add party */
+#define ADD_PARTY_ACK          0x81    /* add party ack */
+#define ADD_PARTY_REJ          0x82    /* add party rej */
+#define DROP_PARTY             0x83    /* drop party */
+#define DROP_PARTY_ACK         0x84    /* drop party ack */
+
+/* Information Element Parameters in the signalling messages */
+#define CAUSE                  0x08    /* cause */
+#define ENDPT_REF              0x54    /* endpoint reference */
+#define AAL_PARA               0x58    /* ATM adaptation layer parameters */
+#define TRAFF_DESCRIP          0x59    /* atm traffic descriptors */
+#define CONNECT_ID             0x5a    /* connection identifier */
+#define QOS_PARA               0x5c    /* quality of service parameters */
+#define B_HIGHER               0x5d    /* broadband higher layer information */
+#define B_BEARER               0x5e    /* broadband bearer capability */
+#define B_LOWER                        0x5f    /* broadband lower information */
+#define CALLING_PARTY          0x6c    /* calling party number */
+#define CALLED_PARTY           0x70    /* called party nmber */
+
+#define Q2931                  0x09
+
+/* Q.2931 signalling general messages format */
+#define PROTO_POS       0      /* offset of protocol discriminator */
+#define CALL_REF_POS    2      /* offset of call reference value */
+#define MSG_TYPE_POS    5      /* offset of message type */
+#define MSG_LEN_POS     7      /* offset of mesage length */
+#define IE_BEGIN_POS    9      /* offset of first information element */
+
+/* format of signalling messages */
+#define TYPE_POS       0
+#define LEN_POS                2
+#define FIELD_BEGIN_POS 4
diff -r d4e25906cd18 -r f089cde07793 lib/libpcap/bpf_dump.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpcap/bpf_dump.c    Sun Sep 19 21:31:39 2004 +0000
@@ -0,0 +1,69 @@
+.\" $NetBSD: bpf_dump.c,v 1.1.1.1 2004/09/19 21:31:39 dyoung Exp $
+.\
+/*
+ * Copyright (c) 1992, 1993, 1994, 1995, 1996
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+#include <sys/cdefs.h>
+#ifndef lint
+#if 0
+static const char rcsid[] _U_ =
+    "@(#) Header: /tcpdump/master/libpcap/bpf_dump.c,v 1.13.2.1 2003/11/15 23:26:37 guy Exp  (LBL)";
+#else
+__RCSID("$NetBSD: bpf_dump.c,v 1.1.1.1 2004/09/19 21:31:39 dyoung Exp $");
+#endif
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pcap.h>
+#include <stdio.h>
+
+void
+bpf_dump(struct bpf_program *p, int option)
+{
+       struct bpf_insn *insn;
+       int i;
+       int n = p->bf_len;
+
+       insn = p->bf_insns;
+       if (option > 2) {
+               printf("%d\n", n);
+               for (i = 0; i < n; ++insn, ++i) {
+                       printf("%u %u %u %u\n", insn->code,
+                              insn->jt, insn->jf, insn->k);
+               }
+               return ;
+       }
+       if (option > 1) {
+               for (i = 0; i < n; ++insn, ++i)
+                       printf("{ 0x%x, %d, %d, 0x%08x },\n",
+                              insn->code, insn->jt, insn->jf, insn->k);
+               return;
+       }
+       for (i = 0; i < n; ++insn, ++i) {
+#ifdef BDEBUG
+               extern int bids[];
+               printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1);
+#endif
+               puts(bpf_image(insn, i));
+       }
+}
diff -r d4e25906cd18 -r f089cde07793 lib/libpcap/fad-getad.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpcap/fad-getad.c   Sun Sep 19 21:31:39 2004 +0000
@@ -0,0 +1,250 @@
+.\" $NetBSD: fad-getad.c,v 1.1.1.1 2004/09/19 21:31:39 dyoung Exp $
+.\
+/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
+/*
+ * Copyright (c) 1994, 1995, 1996, 1997, 1998
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the Computer Systems
+ *     Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+#if 0
+static const char rcsid[] _U_ =
+    "@(#) Header: /tcpdump/master/libpcap/fad-getad.c,v 1.7.2.2 2004/03/11 23:04:52 guy Exp  (LBL)";
+#else
+__RCSID("$NetBSD: fad-getad.c,v 1.1.1.1 2004/09/19 21:31:39 dyoung Exp $");
+#endif
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <net/if.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ifaddrs.h>
+
+#include "pcap-int.h"
+
+#ifdef HAVE_OS_PROTO_H
+#include "os-proto.h"
+#endif
+
+/*
+ * This is fun.
+ *
+ * In older BSD systems, socket addresses were fixed-length, and
+ * "sizeof (struct sockaddr)" gave the size of the structure.
+ * All addresses fit within a "struct sockaddr".
+ *
+ * In newer BSD systems, the socket address is variable-length, and
+ * there's an "sa_len" field giving the length of the structure;
+ * this allows socket addresses to be longer than 2 bytes of family
+ * and 14 bytes of data.
+ *
+ * Some commercial UNIXes use the old BSD scheme, some use the RFC 2553
+ * variant of the old BSD scheme (with "struct sockaddr_storage" rather
+ * than "struct sockaddr"), and some use the new BSD scheme.
+ *
+ * Some versions of GNU libc use neither scheme, but has an "SA_LEN()"
+ * macro that determines the size based on the address family.  Other
+ * versions don't have "SA_LEN()" (as it was in drafts of RFC 2553
+ * but not in the final version).  On the latter systems, we explicitly
+ * check the AF_ type to determine the length; we assume that on
+ * all those systems we have "struct sockaddr_storage".
+ */
+#ifndef SA_LEN
+#ifdef HAVE_SOCKADDR_SA_LEN
+#define SA_LEN(addr)   ((addr)->sa_len)
+#else /* HAVE_SOCKADDR_SA_LEN */
+#ifdef HAVE_SOCKADDR_STORAGE
+static size_t
+get_sa_len(struct sockaddr *addr)
+{
+       switch (addr->sa_family) {
+
+#ifdef AF_INET
+       case AF_INET:
+               return (sizeof (struct sockaddr_in));
+#endif
+
+#ifdef AF_INET6
+       case AF_INET6:
+               return (sizeof (struct sockaddr_in6));
+#endif
+
+       default:
+               return (sizeof (struct sockaddr));
+       }
+}
+#define SA_LEN(addr)   (get_sa_len(addr))
+#else /* HAVE_SOCKADDR_STORAGE */
+#define SA_LEN(addr)   (sizeof (struct sockaddr))
+#endif /* HAVE_SOCKADDR_STORAGE */
+#endif /* HAVE_SOCKADDR_SA_LEN */
+#endif /* SA_LEN */
+
+/*
+ * Get a list of all interfaces that are up and that we can open.
+ * Returns -1 on error, 0 otherwise.
+ * The list, as returned through "alldevsp", may be null if no interfaces
+ * were up and could be opened.
+ *
+ * This is the implementation used on platforms that have "getifaddrs()".
+ */
+int



Home | Main Index | Thread Index | Old Index