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.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 { |
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"), |
357 DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"), |
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"), |
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"), |
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"), |
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"), |
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, |
470 *us1 = (const u_char *)s1, 471 *us2 = (const u_char *)s2; |
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 */ |
684const char * |
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 |
820static const char pcap_version_string[] = "libpcap version 0.9.8"; |
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 */ |
829static const char wpcap_version_string[] = "4.0"; |
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 --- |