Deleted Added
full compact
pcap.c (162012) pcap.c (172677)
1/*
2 * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35static const char rcsid[] _U_ =
1/*
2 * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35static const char rcsid[] _U_ =
36 "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.88.2.8 2005/08/13 22:29:46 hannes Exp $ (LBL)";
36 "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.88.2.19 2007/09/19 02:50:52 guy Exp $ (LBL)";
37#endif
38
39#ifdef HAVE_CONFIG_H
40#include "config.h"
41#endif
42
43#ifdef WIN32
44#include <pcap-stdinc.h>

--- 190 unchanged lines hidden (view full) ---

235 if (*dlt_buffer == NULL) {
236 (void)snprintf(p->errbuf, sizeof(p->errbuf),
237 "malloc: %s", pcap_strerror(errno));
238 return (-1);
239 }
240 **dlt_buffer = p->linktype;
241 return (1);
242 } else {
37#endif
38
39#ifdef HAVE_CONFIG_H
40#include "config.h"
41#endif
42
43#ifdef WIN32
44#include <pcap-stdinc.h>

--- 190 unchanged lines hidden (view full) ---

235 if (*dlt_buffer == NULL) {
236 (void)snprintf(p->errbuf, sizeof(p->errbuf),
237 "malloc: %s", pcap_strerror(errno));
238 return (-1);
239 }
240 **dlt_buffer = p->linktype;
241 return (1);
242 } else {
243 *dlt_buffer = (int*)malloc(sizeof(**dlt_buffer) * p->dlt_count);
243 *dlt_buffer = (int*)calloc(sizeof(**dlt_buffer), p->dlt_count);
244 if (*dlt_buffer == NULL) {
245 (void)snprintf(p->errbuf, sizeof(p->errbuf),
246 "malloc: %s", pcap_strerror(errno));
247 return (-1);
248 }
249 (void)memcpy(*dlt_buffer, p->dlt_list,
250 sizeof(**dlt_buffer) * p->dlt_count);
251 return (p->dlt_count);

--- 97 unchanged lines hidden (view full) ---

349 DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
350 DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
351 DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
352 DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus BSD radio information header"),
353 DLT_CHOICE(DLT_APPLE_IP_OVER_IEEE1394, "Apple IP-over-IEEE 1394"),
354 DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
355 DLT_CHOICE(DLT_DOCSIS, "DOCSIS"),
356 DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
244 if (*dlt_buffer == NULL) {
245 (void)snprintf(p->errbuf, sizeof(p->errbuf),
246 "malloc: %s", pcap_strerror(errno));
247 return (-1);
248 }
249 (void)memcpy(*dlt_buffer, p->dlt_list,
250 sizeof(**dlt_buffer) * p->dlt_count);
251 return (p->dlt_count);

--- 97 unchanged lines hidden (view full) ---

349 DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
350 DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
351 DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
352 DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus BSD radio information header"),
353 DLT_CHOICE(DLT_APPLE_IP_OVER_IEEE1394, "Apple IP-over-IEEE 1394"),
354 DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
355 DLT_CHOICE(DLT_DOCSIS, "DOCSIS"),
356 DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
357 DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"),
357 DLT_CHOICE(DLT_IEEE802_11_RADIO_AVS, "802.11 plus AVS radio information header"),
358 DLT_CHOICE(DLT_SYMANTEC_FIREWALL, "Symantec Firewall"),
359 DLT_CHOICE(DLT_JUNIPER_ATM1, "Juniper ATM1 PIC"),
360 DLT_CHOICE(DLT_JUNIPER_ATM2, "Juniper ATM2 PIC"),
361 DLT_CHOICE(DLT_JUNIPER_MLPPP, "Juniper Multi-Link PPP"),
358 DLT_CHOICE(DLT_IEEE802_11_RADIO_AVS, "802.11 plus AVS radio information header"),
359 DLT_CHOICE(DLT_SYMANTEC_FIREWALL, "Symantec Firewall"),
360 DLT_CHOICE(DLT_JUNIPER_ATM1, "Juniper ATM1 PIC"),
361 DLT_CHOICE(DLT_JUNIPER_ATM2, "Juniper ATM2 PIC"),
362 DLT_CHOICE(DLT_JUNIPER_MLPPP, "Juniper Multi-Link PPP"),
362 DLT_CHOICE(DLT_PPP_PPPD, "PPP for pppd, with direction flag"),
363 DLT_CHOICE(DLT_JUNIPER_PPPOE, "Juniper PPPoE"),
364 DLT_CHOICE(DLT_JUNIPER_PPPOE_ATM, "Juniper PPPoE/ATM"),
365 DLT_CHOICE(DLT_GPRS_LLC, "GPRS LLC"),
366 DLT_CHOICE(DLT_GPF_T, "GPF-T"),
367 DLT_CHOICE(DLT_GPF_F, "GPF-F"),
368 DLT_CHOICE(DLT_JUNIPER_PIC_PEER, "Juniper PIC Peer"),
369 DLT_CHOICE(DLT_JUNIPER_MLFR, "Juniper Multi-Link Frame Relay"),
363 DLT_CHOICE(DLT_PPP_PPPD, "PPP for pppd, with direction flag"),
364 DLT_CHOICE(DLT_JUNIPER_PPPOE, "Juniper PPPoE"),
365 DLT_CHOICE(DLT_JUNIPER_PPPOE_ATM, "Juniper PPPoE/ATM"),
366 DLT_CHOICE(DLT_GPRS_LLC, "GPRS LLC"),
367 DLT_CHOICE(DLT_GPF_T, "GPF-T"),
368 DLT_CHOICE(DLT_GPF_F, "GPF-F"),
369 DLT_CHOICE(DLT_JUNIPER_PIC_PEER, "Juniper PIC Peer"),
370 DLT_CHOICE(DLT_JUNIPER_MLFR, "Juniper Multi-Link Frame Relay"),
370 DLT_CHOICE(DLT_ERF_ETH, "Ethernet with Endace ERF header"),
371 DLT_CHOICE(DLT_ERF_POS, "Packet-over-SONET with Endace ERF header"),
372 DLT_CHOICE(DLT_JUNIPER_GGSN, "Juniper GGSN PIC"),
373 DLT_CHOICE(DLT_JUNIPER_ES, "Juniper Encryption Services PIC"),
374 DLT_CHOICE(DLT_JUNIPER_MONITOR, "Juniper Passive Monitor PIC"),
375 DLT_CHOICE(DLT_JUNIPER_SERVICES, "Juniper Advanced Services PIC"),
371 DLT_CHOICE(DLT_ERF_ETH, "Ethernet with Endace ERF header"),
372 DLT_CHOICE(DLT_ERF_POS, "Packet-over-SONET with Endace ERF header"),
373 DLT_CHOICE(DLT_JUNIPER_GGSN, "Juniper GGSN PIC"),
374 DLT_CHOICE(DLT_JUNIPER_ES, "Juniper Encryption Services PIC"),
375 DLT_CHOICE(DLT_JUNIPER_MONITOR, "Juniper Passive Monitor PIC"),
376 DLT_CHOICE(DLT_JUNIPER_SERVICES, "Juniper Advanced Services PIC"),
376 DLT_CHOICE(DLT_JUNIPER_MFR, "Juniper FRF.16 Frame Relay"),
377 DLT_CHOICE(DLT_JUNIPER_ETHER, "Juniper Ethernet"),
378 DLT_CHOICE(DLT_JUNIPER_PPP, "Juniper PPP"),
379 DLT_CHOICE(DLT_JUNIPER_FRELAY, "Juniper Frame Relay"),
380 DLT_CHOICE(DLT_JUNIPER_CHDLC, "Juniper C-HDLC"),
377 DLT_CHOICE(DLT_JUNIPER_MFR, "Juniper FRF.16 Frame Relay"),
378 DLT_CHOICE(DLT_JUNIPER_ETHER, "Juniper Ethernet"),
379 DLT_CHOICE(DLT_JUNIPER_PPP, "Juniper PPP"),
380 DLT_CHOICE(DLT_JUNIPER_FRELAY, "Juniper Frame Relay"),
381 DLT_CHOICE(DLT_JUNIPER_CHDLC, "Juniper C-HDLC"),
382 DLT_CHOICE(DLT_MFR, "FRF.16 Frame Relay"),
383 DLT_CHOICE(DLT_JUNIPER_VP, "Juniper Voice PIC"),
384 DLT_CHOICE(DLT_MTP2, "SS7 MTP2"),
385 DLT_CHOICE(DLT_A429, "Arinc 429"),
386 DLT_CHOICE(DLT_A653_ICM, "Arinc 653 Interpartition Communication"),
387 DLT_CHOICE(DLT_USB, "USB"),
388 DLT_CHOICE(DLT_BLUETOOTH_HCI_H4, "Bluetooth HCI UART transport layer"),
389 DLT_CHOICE(DLT_CAN20B, "Controller Area Network (CAN) v. 2.0B"),
390 DLT_CHOICE(DLT_MTP2_WITH_PHDR, "SS7 MTP2 with Pseudo-header"),
381 DLT_CHOICE_SENTINEL
382};
383
384/*
385 * This array is designed for mapping upper and lower case letter
386 * together for a case independent comparison. The mappings are
387 * based upon ascii character sequences.
388 */

--- 63 unchanged lines hidden (view full) ---

452 (u_char)'\370', (u_char)'\371', (u_char)'\372', (u_char)'\373',
453 (u_char)'\374', (u_char)'\375', (u_char)'\376', (u_char)'\377',
454};
455
456int
457pcap_strcasecmp(const char *s1, const char *s2)
458{
459 register const u_char *cm = charmap,
391 DLT_CHOICE_SENTINEL
392};
393
394/*
395 * This array is designed for mapping upper and lower case letter
396 * together for a case independent comparison. The mappings are
397 * based upon ascii character sequences.
398 */

--- 63 unchanged lines hidden (view full) ---

462 (u_char)'\370', (u_char)'\371', (u_char)'\372', (u_char)'\373',
463 (u_char)'\374', (u_char)'\375', (u_char)'\376', (u_char)'\377',
464};
465
466int
467pcap_strcasecmp(const char *s1, const char *s2)
468{
469 register const u_char *cm = charmap,
460 *us1 = (u_char *)s1,
461 *us2 = (u_char *)s2;
470 *us1 = (const u_char *)s1,
471 *us2 = (const u_char *)s2;
462
463 while (cm[*us1] == cm[*us2++])
464 if (*us1++ == '\0')
465 return(0);
466 return (cm[*us1] - cm[*--us2]);
467}
468
469int

--- 196 unchanged lines hidden (view full) ---

666 snprintf (p, sizeof(errbuf)-(p-errbuf), " (%lu)", error);
667 return (errbuf);
668}
669#endif
670
671/*
672 * Not all systems have strerror().
673 */
472
473 while (cm[*us1] == cm[*us2++])
474 if (*us1++ == '\0')
475 return(0);
476 return (cm[*us1] - cm[*--us2]);
477}
478
479int

--- 196 unchanged lines hidden (view full) ---

676 snprintf (p, sizeof(errbuf)-(p-errbuf), " (%lu)", error);
677 return (errbuf);
678}
679#endif
680
681/*
682 * Not all systems have strerror().
683 */
674char *
684const char *
675pcap_strerror(int errnum)
676{
677#ifdef HAVE_STRERROR
678 return (strerror(errnum));
679#else
680 extern int sys_nerr;
681 extern const char *const sys_errlist[];
682 static char ebuf[20];

--- 119 unchanged lines hidden (view full) ---

802 * run, various undesirable things may happen (warnings, the string
803 * being the one from the version of the library with which the program
804 * was linked, or even weirder things, such as the string being the one
805 * from the library but being truncated).
806 */
807#ifdef HAVE_VERSION_H
808#include "version.h"
809#else
685pcap_strerror(int errnum)
686{
687#ifdef HAVE_STRERROR
688 return (strerror(errnum));
689#else
690 extern int sys_nerr;
691 extern const char *const sys_errlist[];
692 static char ebuf[20];

--- 119 unchanged lines hidden (view full) ---

812 * run, various undesirable things may happen (warnings, the string
813 * being the one from the version of the library with which the program
814 * was linked, or even weirder things, such as the string being the one
815 * from the library but being truncated).
816 */
817#ifdef HAVE_VERSION_H
818#include "version.h"
819#else
810static const char pcap_version_string[] = "libpcap version 0.9[.x]";
820static const char pcap_version_string[] = "libpcap version 0.9.8";
811#endif
812
813#ifdef WIN32
814/*
815 * XXX - it'd be nice if we could somehow generate the WinPcap and libpcap
816 * version numbers when building WinPcap. (It'd be nice to do so for
817 * the packet.dll version number as well.)
818 */
821#endif
822
823#ifdef WIN32
824/*
825 * XXX - it'd be nice if we could somehow generate the WinPcap and libpcap
826 * version numbers when building WinPcap. (It'd be nice to do so for
827 * the packet.dll version number as well.)
828 */
819static const char wpcap_version_string[] = "3.1";
829static const char wpcap_version_string[] = "4.0";
820static const char pcap_version_string_fmt[] =
821 "WinPcap version %s, based on %s";
822static const char pcap_version_string_packet_dll_fmt[] =
823 "WinPcap version %s (packet.dll version %s), based on %s";
824static char *full_pcap_version_string;
825
826const char *
827pcap_lib_version(void)

--- 81 unchanged lines hidden ---
830static const char pcap_version_string_fmt[] =
831 "WinPcap version %s, based on %s";
832static const char pcap_version_string_packet_dll_fmt[] =
833 "WinPcap version %s (packet.dll version %s), based on %s";
834static char *full_pcap_version_string;
835
836const char *
837pcap_lib_version(void)

--- 81 unchanged lines hidden ---