├── Makefile ├── README.md ├── address.c ├── address.h ├── adlist.c ├── adlist.h ├── file_cache.c ├── file_cache.h ├── hash.c ├── hash.h ├── libpcap ├── CHANGES ├── CREDITS ├── ChmodBPF │ ├── ChmodBPF │ └── StartupParameters.plist ├── INSTALL.txt ├── LICENSE ├── Makefile.in ├── README ├── README.Win32 ├── README.aix ├── README.dag ├── README.hpux ├── README.linux ├── README.macosx ├── README.septel ├── README.sita ├── README.tru64 ├── SUNOS4 │ ├── nit_if.o.sparc │ ├── nit_if.o.sun3 │ └── nit_if.o.sun4c.4.0.3c ├── TODO ├── VERSION ├── Win32 │ ├── Include │ │ ├── Gnuc.h │ │ ├── addrinfo.h │ │ ├── arpa │ │ │ └── nameser.h │ │ ├── bittypes.h │ │ ├── cdecl_ext.h │ │ ├── inetprivate.h │ │ ├── ip6_misc.h │ │ ├── net │ │ │ ├── if.h │ │ │ ├── netdb.h │ │ │ └── paths.h │ │ └── sockstorage.h │ ├── Prj │ │ ├── libpcap.dsp │ │ └── libpcap.dsw │ └── Src │ │ ├── ffs.c │ │ ├── gai_strerror.c │ │ ├── getaddrinfo.c │ │ ├── getnetbynm.c │ │ ├── getnetent.c │ │ ├── getopt.c │ │ ├── getservent.c │ │ ├── inet_aton.c │ │ ├── inet_net.c │ │ └── inet_pton.c ├── aclocal.m4 ├── arcnet.h ├── atmuni31.h ├── bpf │ └── net │ │ └── bpf_filter.c ├── bpf_dump.c ├── bpf_image.c ├── chmod_bpf ├── config.guess ├── config.h ├── config.h.in ├── config.status ├── config.sub ├── configure ├── configure.in ├── dlpisubs.c ├── dlpisubs.h ├── etherent.c ├── ethertype.h ├── fad-getad.c ├── fad-gifc.c ├── fad-glifc.c ├── fad-null.c ├── fad-sita.c ├── fad-win32.c ├── filtertest.c ├── findalldevstest.c ├── gencode.c ├── gencode.h ├── grammar.y ├── ieee80211.h ├── inet.c ├── install-sh ├── lbl │ ├── os-aix4.h │ ├── os-hpux11.h │ ├── os-osf4.h │ ├── os-osf5.h │ ├── os-solaris2.h │ ├── os-sunos4.h │ └── os-ultrix4.h ├── llc.h ├── missing │ └── snprintf.c ├── mkdep ├── msdos │ ├── bin2c.c │ ├── common.dj │ ├── makefile │ ├── makefile.dj │ ├── makefile.wc │ ├── ndis2.c │ ├── ndis2.h │ ├── ndis_0.asm │ ├── pkt_rx0.asm │ ├── pkt_rx1.s │ ├── pktdrvr.c │ ├── pktdrvr.h │ └── readme.dos ├── nametoaddr.c ├── net ├── nlpid.h ├── opentest.c ├── optimize.c ├── org.tcpdump.chmod_bpf.plist ├── packaging │ └── pcap.spec.in ├── pcap-bpf.c ├── pcap-bpf.h ├── pcap-bt-linux.c ├── pcap-bt-linux.h ├── pcap-can-linux.c ├── pcap-can-linux.h ├── pcap-common.c ├── pcap-common.h ├── pcap-config.1 ├── pcap-config.in ├── pcap-dag.c ├── pcap-dag.h ├── pcap-dlpi.c ├── pcap-dos.c ├── pcap-dos.h ├── pcap-enet.c ├── pcap-filter.manmisc ├── pcap-filter.manmisc.in ├── pcap-int.h ├── pcap-libdlpi.c ├── pcap-linktype.manmisc ├── pcap-linktype.manmisc.in ├── pcap-linux.c ├── pcap-namedb.h ├── pcap-nit.c ├── pcap-null.c ├── pcap-pf.c ├── pcap-savefile.manfile ├── pcap-savefile.manfile.in ├── pcap-septel.c ├── pcap-septel.h ├── pcap-sita.c ├── pcap-sita.h ├── pcap-sita.html ├── pcap-snf.c ├── pcap-snf.h ├── pcap-snit.c ├── pcap-snoop.c ├── pcap-stdinc.h ├── pcap-usb-linux.c ├── pcap-usb-linux.h ├── pcap-win32.c ├── pcap.3pcap ├── pcap.3pcap.in ├── pcap.c ├── pcap.h ├── pcap │ ├── bluetooth.h │ ├── bpf.h │ ├── ipnet.h │ ├── namedb.h │ ├── pcap.h │ ├── sll.h │ ├── usb.h │ └── vlan.h ├── pcap_activate.3pcap ├── pcap_breakloop.3pcap ├── pcap_can_set_rfmon.3pcap ├── pcap_close.3pcap ├── pcap_compile.3pcap ├── pcap_compile.3pcap.in ├── pcap_create.3pcap ├── pcap_datalink.3pcap ├── pcap_datalink.3pcap.in ├── pcap_datalink_name_to_val.3pcap ├── pcap_datalink_val_to_name.3pcap ├── pcap_dump.3pcap ├── pcap_dump_close.3pcap ├── pcap_dump_file.3pcap ├── pcap_dump_flush.3pcap ├── pcap_dump_ftell.3pcap ├── pcap_dump_open.3pcap ├── pcap_dump_open.3pcap.in ├── pcap_file.3pcap ├── pcap_fileno.3pcap ├── pcap_findalldevs.3pcap ├── pcap_free_datalinks.3pcap ├── pcap_freealldevs.3pcap ├── pcap_freecode.3pcap ├── pcap_get_selectable_fd.3pcap ├── pcap_geterr.3pcap ├── pcap_inject.3pcap ├── pcap_is_swapped.3pcap ├── pcap_lib_version.3pcap ├── pcap_list_datalinks.3pcap ├── pcap_list_datalinks.3pcap.in ├── pcap_lookupdev.3pcap ├── pcap_lookupnet.3pcap ├── pcap_loop.3pcap ├── pcap_major_version.3pcap ├── pcap_next_ex.3pcap ├── pcap_offline_filter.3pcap ├── pcap_open_dead.3pcap ├── pcap_open_dead.3pcap.in ├── pcap_open_live.3pcap ├── pcap_open_offline.3pcap ├── pcap_open_offline.3pcap.in ├── pcap_set_buffer_size.3pcap ├── pcap_set_datalink.3pcap ├── pcap_set_promisc.3pcap ├── pcap_set_rfmon.3pcap ├── pcap_set_snaplen.3pcap ├── pcap_set_timeout.3pcap ├── pcap_setdirection.3pcap ├── pcap_setfilter.3pcap ├── pcap_setnonblock.3pcap ├── pcap_snapshot.3pcap ├── pcap_stats.3pcap ├── pcap_statustostr.3pcap ├── pcap_strerror.3pcap ├── ppp.h ├── runlex.sh ├── savefile.c ├── scanner.l ├── selpolltest.c ├── sf-pcap-ng.c ├── sf-pcap-ng.h ├── sf-pcap.c ├── sf-pcap.h └── sunatmpos.h ├── log.c ├── log.h ├── mysqlpcap-prepare.png ├── mysqlpcap.c ├── mysqlpcap.h ├── mysqlpcap.png ├── packet.c ├── packet.h ├── packet_reorder.c ├── protocol.c ├── protocol.h ├── stat.c ├── stat.h ├── test ├── README ├── a.c ├── bak_p23.c ├── p1.c ├── p10_use_db.c ├── p11_sqlcollect_size_too_big.c ├── p12_perf_test.c ├── p13_com_field_list.c ├── p14_local_file.c ├── p15_com_test.c ├── p16_long_preprare.c ├── p17_mix_sql_prepare.c ├── p18_mix_prepare.c ├── p19_null_prepare.c ├── p2.c ├── p20_stmt_fetch_and_cursor.c ├── p21_long_preprare_ok.c ├── p22_blob.c ├── p23_stmt_send_long_data.c ├── p24_stmt_send_long_data2.c ├── p27_big_prepare_resultset.c ├── p28_compress.c ├── p3.c ├── p4.c ├── p5.c ├── p6.c ├── p7.c ├── p8_multi_sql.c ├── p9_long_field.c └── stmt │ ├── a.c │ ├── bak_p23.c │ ├── p1.c │ ├── p10_use_db.c │ ├── p11_sqlcollect_size_too_big.c │ ├── p12_perf_test.c │ ├── p13_com_field_list.c │ ├── p14_local_file.c │ ├── p15_com_test.c │ ├── p16_long_preprare.c │ ├── p17_mix_sql_prepare.c │ ├── p18_mix_prepare.c │ ├── p19_null_prepare.c │ ├── p2.c │ ├── p20_stmt_fetch_and_cursor.c │ ├── p21_long_preprare_ok.c │ ├── p22_blob.c │ ├── p23_stmt_send_long_data.c │ ├── p24_stmt_send_long_data2.c │ ├── p27_big_prepare_resultset.c │ ├── p28_compress.c │ ├── p299_stmt_fetch.c │ ├── p29_stmt_fetch.c │ ├── p3.c │ ├── p30_explain_error.c │ ├── p4.c │ ├── p5.c │ ├── p6.c │ ├── p7.c │ ├── p8_multi_sql.c │ ├── p90_store_use_result_stmt_cursor_case.c │ ├── p94_stmt_send_long_data.c │ ├── p95.c │ ├── p95_stmt_merge_order.c │ ├── p96_stmt_merge.c │ ├── p96_stmt_null.c │ ├── p97_stmt_type.c │ ├── p98_drds.c │ ├── p98_stmt_mix.c │ ├── p99_stmt_normal.c │ └── p9_long_field.c ├── user.c ├── user.h ├── utils.c └── utils.h /Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc -O0 2 | CFLAGS= -g -Wall 3 | INSTALL=/usr/bin/install 4 | INSTALLDIR=/usr/local 5 | BINDIR=$(INSTALLDIR)/bin 6 | 7 | COMPILE.c = $(CC) $(CFLAGS) $(INCLUDE) $(CPPFLAGS) $(TARGET_ARCH) -c 8 | LINK.o = $(CC) $(INCLUDE) $(LDFLAGS) $(TARGET_ARCH) 9 | LINK.c = $(CC) $(CFLAGS) $(INCLUDE) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) 10 | VPATH=./ 11 | 12 | TARGET=libpcap mysqlpcap 13 | 14 | all:$(TARGET) 15 | 16 | libpcap-pfring: dummy 17 | @cd libpcap-pfring && ./configure && make 18 | 19 | libpcap: dummy 20 | @cd libpcap && ./configure && make 21 | 22 | mysqlpcap:LOADLIBES += libpcap/libpcap.a -lpthread 23 | mysqlpcap:CFLAGS += -Ilibpcap -DDEBUG 24 | mysqlpcap: mysqlpcap.c hash.o log.o packet.o protocol.o address.o utils.o adlist.o user.o file_cache.o stat.o 25 | 26 | #mysqlpcap:LOADLIBES += lib/libpcap.a lib/libpfring.a -lpthread 27 | #mysqlpcap:CFLAGS += -Ilibpcap-pfring 28 | #mysqlpcap: mysqlpcap.c hash.o log.o packet.o protocol.o address.o adlist.o utils.o 29 | 30 | clean: 31 | - rm -f *.o mysqlpcap && cd libpcap && make clean 32 | 33 | install:$(TARGET) 34 | mkdir -p $(BINDIR) 35 | $(INSTALL) $(TARGET) $(BINDIR) 36 | 37 | dummy: 38 | 39 | 40 | 41 | test:user_test 42 | ./user_test 43 | 44 | user_test: user.c 45 | gcc -g -o user_test -D_USER_TEST_ -DDEBUG user.c log.c utils.c adlist.c 46 | -------------------------------------------------------------------------------- /address.h: -------------------------------------------------------------------------------- 1 | #ifndef LOCAL_ADDRESSES_H 2 | #define LOCAL_ADDRESSES_H 3 | 4 | #include 5 | 6 | struct address_list; 7 | typedef struct address_list AddressList; 8 | 9 | AddressList* get_addresses(); 10 | AddressList* parse_addresses(char []); 11 | 12 | int free_addresses(AddressList *al); 13 | 14 | int is_local_address(AddressList*, struct in_addr); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /file_cache.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "log.h" 9 | #include "utils.h" 10 | #include "mysqlpcap.h" 11 | 12 | #define CACHE_SIZE 100 * 1024 13 | /* add cache max size */ 14 | #define ONE_CACHE_MAX_SIZE 4 * 1024 15 | /* log flush time, avoid printf two much */ 16 | #define FLUSH_INTERVAL 2 17 | 18 | typedef struct _FileCache{ 19 | FILE *file; 20 | char *cache; 21 | } FileCache; 22 | 23 | char G_one_cache[ONE_CACHE_MAX_SIZE]; 24 | 25 | /* file or stdout */ 26 | int fileCacheInit(MysqlPcap *mp) { 27 | ASSERT(mp); 28 | FileCache *fc = mp->config = calloc(1, sizeof(FileCache)); 29 | 30 | if (strlen(mp->cacheFileName) > 0) { 31 | fc->file = fopen(mp->cacheFileName, "a+"); 32 | if (NULL == fc->file) { 33 | dump(L_ERR, "%s can open", mp->cacheFileName); 34 | } 35 | } 36 | 37 | if (NULL == fc->file) fc->file = stdout; 38 | 39 | fc->cache = calloc(1, CACHE_SIZE); 40 | setbuffer(fc->file, fc->cache, CACHE_SIZE); 41 | mp->cacheFlushTime = time(NULL); 42 | return OK; 43 | } 44 | 45 | int fileCacheAdd(MysqlPcap *mp, const char *fmt, ...) { 46 | ASSERT(mp); 47 | va_list ap; 48 | va_start(ap, fmt); 49 | vsnprintf(G_one_cache, sizeof(G_one_cache), fmt, ap); 50 | va_end(ap); 51 | 52 | FileCache *fc = mp->config; 53 | fprintf(fc->file, "%s", G_one_cache); 54 | 55 | return OK; 56 | } 57 | 58 | int fileCacheFlush(MysqlPcap* mp, int force) { 59 | ASSERT(mp && mp->config); 60 | FileCache *fc = mp->config; 61 | ASSERT(mp->fakeNow >= mp->cacheFlushTime); 62 | 63 | /* not force flush and not on time would return */ 64 | if ((force == 0) && (mp->fakeNow - mp->cacheFlushTime <= FLUSH_INTERVAL)) { 65 | return OK; 66 | } 67 | fflush(fc->file); 68 | mp->cacheFlushTime = mp->fakeNow; 69 | return OK; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /file_cache.h: -------------------------------------------------------------------------------- 1 | 2 | int fileCacheInit(MysqlPcap *mp); 3 | 4 | int fileCacheAdd(MysqlPcap *mp, const char *fmt, ...); 5 | 6 | int fileCacheFlush(MysqlPcap* mp, int force); 7 | -------------------------------------------------------------------------------- /libpcap/ChmodBPF/ChmodBPF: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | . /etc/rc.common 4 | 5 | StartService () 6 | { 7 | # 8 | # Unfortunately, Mac OS X's devfs is based on the old FreeBSD 9 | # one, not the current one, so there's no way to configure it 10 | # to create BPF devices with particular owners or groups. 11 | # This startup item will make it owned by the admin group, 12 | # with permissions rw-rw----, so that anybody in the admin 13 | # group can use programs that capture or send raw packets. 14 | # 15 | # Change this as appropriate for your site, e.g. to make 16 | # it owned by a particular user without changing the permissions, 17 | # so only that user and the super-user can capture or send raw 18 | # packets, or give it the permissions rw-r-----, so that 19 | # only the super-user can send raw packets but anybody in the 20 | # admin group can capture packets. 21 | # 22 | chgrp admin /dev/bpf* 23 | chmod g+rw /dev/bpf* 24 | } 25 | 26 | StopService () 27 | { 28 | return 0; 29 | } 30 | 31 | RestartService () { StartService; } 32 | 33 | RunService "$1" 34 | -------------------------------------------------------------------------------- /libpcap/ChmodBPF/StartupParameters.plist: -------------------------------------------------------------------------------- 1 | { 2 | Description = "Change BPF permissions"; 3 | Provides = ("ChmodBPF"); 4 | } 5 | -------------------------------------------------------------------------------- /libpcap/LICENSE: -------------------------------------------------------------------------------- 1 | License: BSD 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in 11 | the documentation and/or other materials provided with the 12 | distribution. 13 | 3. The names of the authors may not be used to endorse or promote 14 | products derived from this software without specific prior 15 | written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 18 | IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | -------------------------------------------------------------------------------- /libpcap/README.Win32: -------------------------------------------------------------------------------- 1 | Under Win32, libpcap is integrated in the WinPcap packet capture system. 2 | WinPcap provides a framework that allows libpcap to capture the packets 3 | under Windows 95, Windows 98, Windows ME, Windows NT 4, Windows 2000 4 | and Windows XP. 5 | WinPcap binaries and source code can be found at http://winpcap.polito.it: 6 | they include also a developer's pack with all the necessary to compile 7 | libpcap-based applications under Windows. 8 | 9 | How to compile libpcap with Visual Studio 10 | ----------------------------------------- 11 | 12 | In order to compile libpcap you will need: 13 | 14 | - version 6 (or higher) of Microsoft Visual Studio 15 | - The November 2001 (or later) edition of Microsoft Platform 16 | Software Development Kit (SDK), that contains some necessary includes 17 | for IPv6 support. You can download it from http://www.microsoft.com/sdk 18 | - the latest WinPcap sources from http://winpcap.polito.it/install 19 | 20 | The WinPcap source code already contains a recent (usually the latest 21 | stable) version of libpcap. If you need to compile a different one, 22 | simply download it from www.tcpdump.org and copy the sources in the 23 | winpcap\wpcap\libpcap folder of the WinPcap distribution. If you want to 24 | compile a libpcap source retrieved from the tcpdump.org Git, you will 25 | have to create the scanner and the grammar by hand (with lex and yacc) 26 | or with the cygnus makefile, since The Visual Studio project is not able 27 | to build them. 28 | 29 | Open the project file winpcap\wpcap\prj\wpcap.dsw with Visual Studio and 30 | build wpcap.dll. wpcap.lib, the library file to link with the applications, 31 | will be generated in winpcap\wpcap\lib\. wpcap.dll will be generated in 32 | winpcap\wpcap\prj\release or winpcap\wpcap\prj\debug depending on the type 33 | of binary that is being created. 34 | 35 | How to compile libpcap with Cygnus 36 | ---------------------------------- 37 | 38 | To build wpcap.dll, cd to the directory WPCAP/PRJ of the WinPcap source code 39 | distribution and type "make". libwpcap.a, the library file to link with the 40 | applications, will be generated in winpcap\wpcap\lib\. wpcap.dll will be 41 | generated in winpcap\wpcap\prj. 42 | 43 | Remember, you CANNOT use the MSVC-generated .lib files with gcc, use 44 | libwpcap.a instead. 45 | 46 | "make install" installs wpcap.dll in the Windows system folder. 47 | -------------------------------------------------------------------------------- /libpcap/README.septel: -------------------------------------------------------------------------------- 1 | The following instructions apply if you have a Linux platform and want 2 | libpcap to support the Septel range of passive network monitoring cards 3 | from Intel (http://www.intel.com) 4 | 5 | 1) Install and build the Septel software distribution by following the 6 | instructions supplied with that package. 7 | 8 | 2) Configure libcap. To allow the 'configure' script to locate the Septel 9 | software distribution use the '--with-septel' option: 10 | 11 | ./configure --with-septel=DIR 12 | 13 | where DIR is the root of the Septel software distribution, for example 14 | /var/src/septel. 15 | 16 | By default (if you write only ./configure --with-septel) it takes 17 | ./../septel as argument for DIR. 18 | 19 | If the Septel software is correctly detected 'configure' will 20 | report: 21 | 22 | checking whether we have Septel API... yes 23 | 24 | If 'configure' reports that there is no Septel API, the directory may have been 25 | incorrectly specified or the Septel software was not built before configuring 26 | libpcap. 27 | 28 | See also the libpcap INSTALL.txt file for further libpcap configuration 29 | options. 30 | 31 | Building libpcap at this stage will include support for both the native 32 | packet capture stream and for capturing from Septel cards. To build 33 | libpcap with only Septel support specify the capture type as 'septel' 34 | when configuring libpcap: 35 | 36 | ./configure --with-septel=DIR --with-pcap=septel 37 | 38 | Applications built with libpcap configured in this way will only detect Septel 39 | cards and will not capture from the native OS packet stream. 40 | 41 | Note: As mentioned in pcap-septel.c we should first edit the system.txt 42 | file to change the user part example (UPE) module id to 0xdd instead of 43 | 0x2d for technical reason. So this change in system.txt is crutial and 44 | things will go wrong if it's not done. System.txt along with config.txt 45 | are configuration files that are edited by the user before running the 46 | gctload program that uses these files for initialising modules and 47 | configuring parameters. 48 | 49 | ---------------------------------------------------------------------- 50 | for more information please contact me : gil_hoyek@hotmail.com 51 | -------------------------------------------------------------------------------- /libpcap/README.tru64: -------------------------------------------------------------------------------- 1 | The following instructions are applicable to Tru64 UNIX 2 | (formerly Digital UNIX (formerly DEC OSF/1)) version 4.0, and 3 | probably to later versions as well; at least some options apply to 4 | Digital UNIX 3.2 - perhaps all do. 5 | 6 | In order to use kernel packet filtering on this system, you have 7 | to configure it in such a way: 8 | 9 | Kernel configuration 10 | -------------------- 11 | 12 | The packet filtering kernel option must be enabled at kernel 13 | installation. If it was not the case, you can rebuild the kernel with 14 | "doconfig -c" after adding the following line in the kernel 15 | configuration file (/sys/conf/): 16 | 17 | option PACKETFILTER 18 | 19 | or use "doconfig" without any arguments to add the packet filter driver 20 | option via the kernel option menu (see the system administration 21 | documentation for information on how to do this). 22 | 23 | Device configuration 24 | -------------------- 25 | 26 | Devices used for packet filtering must be created thanks to 27 | the following command (executed in the /dev directory): 28 | 29 | ./MAKEDEV pfilt 30 | 31 | Interface configuration 32 | ----------------------- 33 | 34 | In order to capture all packets on a network, you may want to allow 35 | applications to put the interface on that network into "local copy" 36 | mode, so that tcpdump can see packets sent by the host on which it's 37 | running as well as packets received by that host, and to put the 38 | interface into "promiscuous" mode, so that tcpdump can see packets on 39 | the network segment not sent to the host on which it's running, by using 40 | the pfconfig(1) command: 41 | 42 | pfconfig +c +p 43 | 44 | or allow application to put any interface into "local copy" or 45 | "promiscuous" mode by using the command: 46 | 47 | pfconfig +c +p -a 48 | 49 | Note: all instructions given require root privileges. 50 | -------------------------------------------------------------------------------- /libpcap/SUNOS4/nit_if.o.sparc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoterran/tcpcollect/44b1f8595992a922e848a3ff9a1a2a258cb3dd9e/libpcap/SUNOS4/nit_if.o.sparc -------------------------------------------------------------------------------- /libpcap/SUNOS4/nit_if.o.sun3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoterran/tcpcollect/44b1f8595992a922e848a3ff9a1a2a258cb3dd9e/libpcap/SUNOS4/nit_if.o.sun3 -------------------------------------------------------------------------------- /libpcap/SUNOS4/nit_if.o.sun4c.4.0.3c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoterran/tcpcollect/44b1f8595992a922e848a3ff9a1a2a258cb3dd9e/libpcap/SUNOS4/nit_if.o.sun4c.4.0.3c -------------------------------------------------------------------------------- /libpcap/TODO: -------------------------------------------------------------------------------- 1 | TODO list for libpcap 2 | ======================= 3 | 4 | Important stuff (to be done before the next release) 5 | --------------- 6 | 7 | General 8 | 9 | - configure should not be in Git. Most open source projects have an 10 | autogen.sh script to run autoconf etc. after checkout. I think we 11 | should stick to the standard. 12 | 13 | - The source files should be better documented. There is no official 14 | design guideline for what is done where. There should be a common coding 15 | style (okay, you can guess that by looking at the code) and a guide for 16 | what needs to be documented. 17 | 18 | Less urgent items 19 | ----------------- 20 | 21 | - Better documentation and cleanup of the interface. I am seeing a few 22 | problems at the first glance which needs fixing: 23 | + pcap_lookupnet makes little to no sense with protocols != IPv4 24 | + not very well suited for interactive programs (think ethereal). There 25 | should be a way for the application to get a file descriptor which it 26 | has to monitor and a callback in pcap which has to be called on 27 | activity (XXX - "pcap_fileno()" handles the first part, although 28 | "select()" and "poll()" don't work on BPF devices on most BSDs, and 29 | you can call "pcap_dispatch()" as the dispatch routine after putting 30 | the descriptor into non-blocking mode) 31 | + too many functions. There are a lot of functions for everything which 32 | violates the KISS principle. Why do we need pcap_strerror, pcap_perror 33 | and pcap_geterr? 34 | + the manpage has a brief description of each function but where is the 35 | big picture? Seems like you need to buy UNP for that... 36 | -------------------------------------------------------------------------------- /libpcap/VERSION: -------------------------------------------------------------------------------- 1 | 1.1.1 2 | -------------------------------------------------------------------------------- /libpcap/Win32/Include/Gnuc.h: -------------------------------------------------------------------------------- 1 | /* @(#) $Header: /tcpdump/master/libpcap/Win32/Include/Gnuc.h,v 1.1 2002-08-01 08:33:05 risso Exp $ (LBL) */ 2 | 3 | /* Define __P() macro, if necessary */ 4 | 5 | #ifndef __P 6 | #if __STDC__ 7 | #define __P(protos) protos 8 | #else 9 | #define __P(protos) () 10 | #endif 11 | #endif 12 | 13 | /* inline foo */ 14 | #ifndef __cplusplus 15 | #ifdef __GNUC__ 16 | #define inline __inline 17 | #else 18 | #define inline 19 | #endif 20 | #endif 21 | 22 | /* 23 | * Handle new and old "dead" routine prototypes 24 | * 25 | * For example: 26 | * 27 | * __dead void foo(void) __attribute__((volatile)); 28 | * 29 | */ 30 | #ifdef __GNUC__ 31 | #ifndef __dead 32 | #define __dead volatile 33 | #endif 34 | #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) 35 | #ifndef __attribute__ 36 | #define __attribute__(args) 37 | #endif 38 | #endif 39 | #else 40 | #ifndef __dead 41 | #define __dead 42 | #endif 43 | #ifndef __attribute__ 44 | #define __attribute__(args) 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /libpcap/Win32/Include/cdecl_ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999 WIDE Project. 3 | * 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 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the project nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | #ifndef HAVE_PORTABLE_PROTOTYPE 30 | 31 | #if defined(__STDC__) || defined(__cplusplus) 32 | #define __P(protos) protos /* full-blown ANSI C */ 33 | #else 34 | #define __P(protos) () /* traditional C preprocessor */ 35 | #endif 36 | 37 | #endif /* !HAVE_PORTABLE_PROTOTYPE */ 38 | -------------------------------------------------------------------------------- /libpcap/Win32/Include/sockstorage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999 WIDE Project. 3 | * 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 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the project nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | struct sockaddr_storage { 30 | #ifdef HAVE_SOCKADDR_SA_LEN 31 | u_int8_t __ss_len; 32 | u_int8_t __ss_family; 33 | u_int8_t fill[126]; 34 | #else 35 | u_int8_t __ss_family; 36 | u_int8_t fill[127]; 37 | #endif /* HAVE_SOCKADDR_SA_LEN */ 38 | }; 39 | -------------------------------------------------------------------------------- /libpcap/Win32/Prj/libpcap.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "libpcap"=".\libpcap.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /libpcap/Win32/Src/ffs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1993 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 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 | #if defined(LIBC_SCCS) && !defined(lint) 35 | static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93"; 36 | #endif /* LIBC_SCCS and not lint */ 37 | 38 | #include 39 | 40 | /* 41 | * ffs -- vax ffs instruction 42 | */ 43 | int 44 | ffs(mask) 45 | register int mask; 46 | { 47 | register int bit; 48 | 49 | if (mask == 0) 50 | return(0); 51 | for (bit = 1; !(mask & 1); bit++) 52 | mask >>= 1; 53 | return(bit); 54 | } 55 | -------------------------------------------------------------------------------- /libpcap/Win32/Src/getnetbynm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1983 Regents of the University of California. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms are permitted 6 | * provided that the above copyright notice and this paragraph are 7 | * duplicated in all such forms and that any documentation, 8 | * advertising materials, and other materials related to such 9 | * distribution and use acknowledge that the software was developed 10 | * by the University of California, Berkeley. The name of the 11 | * University may not be used to endorse or promote products derived 12 | * from this software without specific prior written permission. 13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #if defined(LIBC_SCCS) && !defined(lint) 19 | static char sccsid[] = "@(#)getnetbyname.c 5.5 (Berkeley) 6/27/88"; 20 | #endif /* LIBC_SCCS and not lint */ 21 | 22 | #include "inetprivate.h" 23 | 24 | extern int _net_stayopen; 25 | 26 | struct netent * 27 | getnetbyname(const char *name) 28 | { 29 | register struct netent *p; 30 | register char **cp; 31 | 32 | setnetent(_net_stayopen); 33 | while (p = getnetent()) { 34 | if (strcmp(p->n_name, name) == 0) 35 | break; 36 | for (cp = p->n_aliases; *cp != 0; cp++) 37 | if (strcmp(*cp, name) == 0) 38 | goto found; 39 | } 40 | found: 41 | if (!_net_stayopen) 42 | endnetent(); 43 | return (p); 44 | } 45 | -------------------------------------------------------------------------------- /libpcap/Win32/Src/inet_aton.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoterran/tcpcollect/44b1f8595992a922e848a3ff9a1a2a258cb3dd9e/libpcap/Win32/Src/inet_aton.c -------------------------------------------------------------------------------- /libpcap/Win32/Src/inet_pton.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoterran/tcpcollect/44b1f8595992a922e848a3ff9a1a2a258cb3dd9e/libpcap/Win32/Src/inet_pton.c -------------------------------------------------------------------------------- /libpcap/bpf_dump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | #ifndef lint 22 | static const char rcsid[] _U_ = 23 | "@(#) $Header: /tcpdump/master/libpcap/bpf_dump.c,v 1.15 2008-01-02 04:16:46 guy Exp $ (LBL)"; 24 | #endif 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include "config.h" 28 | #endif 29 | 30 | #include 31 | #include 32 | 33 | void 34 | bpf_dump(const struct bpf_program *p, int option) 35 | { 36 | const struct bpf_insn *insn; 37 | int i; 38 | int n = p->bf_len; 39 | 40 | insn = p->bf_insns; 41 | if (option > 2) { 42 | printf("%d\n", n); 43 | for (i = 0; i < n; ++insn, ++i) { 44 | printf("%u %u %u %u\n", insn->code, 45 | insn->jt, insn->jf, insn->k); 46 | } 47 | return ; 48 | } 49 | if (option > 1) { 50 | for (i = 0; i < n; ++insn, ++i) 51 | printf("{ 0x%x, %d, %d, 0x%08x },\n", 52 | insn->code, insn->jt, insn->jf, insn->k); 53 | return; 54 | } 55 | for (i = 0; i < n; ++insn, ++i) { 56 | #ifdef BDEBUG 57 | extern int bids[]; 58 | printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1); 59 | #endif 60 | puts(bpf_image(insn, i)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /libpcap/chmod_bpf: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # 4 | # Unfortunately, Mac OS X's devfs is based on the old FreeBSD 5 | # one, not the current one, so there's no way to configure it 6 | # to create BPF devices with particular owners or groups. 7 | # This startup item will make it owned by the admin group, 8 | # with permissions rw-rw----, so that anybody in the admin 9 | # group can use programs that capture or send raw packets. 10 | # 11 | # Change this as appropriate for your site, e.g. to make 12 | # it owned by a particular user without changing the permissions, 13 | # so only that user and the super-user can capture or send raw 14 | # packets, or give it the permissions rw-r-----, so that 15 | # only the super-user can send raw packets but anybody in the 16 | # admin group can capture packets. 17 | # 18 | chgrp admin /dev/bpf* 19 | chmod g+rw /dev/bpf* 20 | -------------------------------------------------------------------------------- /libpcap/dlpisubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#) $Header: /tcpdump/master/libpcap/dlpisubs.h,v 1.2 2008-04-04 19:37:45 guy Exp $ 3 | */ 4 | 5 | #ifndef dlpisubs_h 6 | #define dlpisubs_h 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* 13 | * Functions used by dlpisubs.c. 14 | */ 15 | int pcap_stats_dlpi(pcap_t *, struct pcap_stat *); 16 | int pcap_process_pkts(pcap_t *, pcap_handler, u_char *, int, u_char *, int); 17 | int pcap_process_mactype(pcap_t *, u_int); 18 | #ifdef HAVE_SYS_BUFMOD_H 19 | int pcap_conf_bufmod(pcap_t *, int, int); 20 | #endif 21 | int pcap_alloc_databuf(pcap_t *); 22 | int strioctl(int, int, int, char *); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libpcap/fad-sita.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fad-sita.c: Packet capture interface additions for SITA ACN devices 3 | * 4 | * Copyright (c) 2007 Fulko Hew, SITA INC Canada, Inc 5 | * 6 | * License: BSD 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 3. The names of the authors may not be used to endorse or promote 19 | * products derived from this software without specific prior 20 | * written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 23 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 25 | */ 26 | 27 | /* $Id: fad-sita.c */ 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include "config.h" 31 | #endif 32 | 33 | #include 34 | #include "pcap-int.h" 35 | 36 | #include "pcap-sita.h" 37 | 38 | extern pcap_if_t *acn_if_list; /* pcap's list of available interfaces */ 39 | 40 | int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) { 41 | 42 | //printf("pcap_findalldevs()\n"); // fulko 43 | 44 | *alldevsp = 0; /* initialize the returned variables before we do anything */ 45 | strcpy(errbuf, ""); 46 | if (acn_parse_hosts_file(errbuf)) /* scan the hosts file for potential IOPs */ 47 | { 48 | //printf("pcap_findalldevs() returning BAD after parsehosts\n"); // fulko 49 | return -1; 50 | } 51 | //printf("pcap_findalldevs() got hostlist now finding devs\n"); // fulko 52 | if (acn_findalldevs(errbuf)) /* then ask the IOPs for their monitorable devices */ 53 | { 54 | //printf("pcap_findalldevs() returning BAD after findalldevs\n"); // fulko 55 | return -1; 56 | } 57 | *alldevsp = acn_if_list; 58 | acn_if_list = 0; /* then forget our list head, because someone will call pcap_freealldevs() to empty the malloc'ed stuff */ 59 | //printf("pcap_findalldevs() returning ZERO OK\n"); // fulko 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /libpcap/lbl/os-aix4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * @(#) $Header: /tcpdump/master/libpcap/lbl/os-aix4.h,v 1.1 2002-06-01 09:37:40 guy Exp $ 22 | */ 23 | 24 | /* Prototypes missing in AIX 4.x */ 25 | int ffs(int i); 26 | -------------------------------------------------------------------------------- /libpcap/lbl/os-hpux11.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * @(#) $Header: /tcpdump/master/libpcap/lbl/os-hpux11.h,v 1.1 2002-06-01 09:37:41 guy Exp $ 22 | */ 23 | 24 | /* Prototypes missing in HP-UX 11.x */ 25 | int ffs(int i); 26 | -------------------------------------------------------------------------------- /libpcap/lbl/os-osf4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * @(#) $Header: /tcpdump/master/libpcap/lbl/os-osf4.h,v 1.2 2000-12-22 11:51:33 guy Exp $ (LBL) 22 | */ 23 | 24 | /* Prototypes missing in Digital UNIX 4.x */ 25 | int snprintf(char *, size_t, const char *, ...); 26 | int vsnprintf(char *, size_t, const char *, va_list); 27 | int pfopen(char *, int); 28 | 29 | -------------------------------------------------------------------------------- /libpcap/lbl/os-osf5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * @(#) $Header: /tcpdump/master/libpcap/lbl/os-osf5.h,v 1.2 2002-08-02 03:24:15 guy Exp $ (LBL) 22 | */ 23 | 24 | /* 25 | * Prototypes missing in Tru64 UNIX 5.x 26 | * XXX - "snprintf()" and "vsnprintf()" aren't missing, but you have to 27 | * #define the right value to get them defined by . 28 | */ 29 | int snprintf(char *, size_t, const char *, ...); 30 | int vsnprintf(char *, size_t, const char *, va_list); 31 | int pfopen(char *, int); 32 | 33 | -------------------------------------------------------------------------------- /libpcap/lbl/os-solaris2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * @(#) $Header: /tcpdump/master/libpcap/lbl/os-solaris2.h,v 1.19 2000-10-11 04:02:52 guy Exp $ (LBL) 22 | */ 23 | 24 | /* Prototypes missing in SunOS 5 */ 25 | char *strerror(int); 26 | int snprintf(char *, size_t, const char *, ...); 27 | -------------------------------------------------------------------------------- /libpcap/lbl/os-ultrix4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1990, 1993, 1994, 1995, 1996 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * @(#) $Header: /tcpdump/master/libpcap/lbl/os-ultrix4.h,v 1.19 1999-10-07 23:46:41 mcr Exp $ (LBL) 22 | */ 23 | 24 | /* Prototypes missing in Ultrix 4 */ 25 | int bcmp(const char *, const char *, u_int); 26 | void bcopy(const void *, void *, u_int); 27 | void bzero(void *, u_int); 28 | void endservent(void); 29 | int getopt(int, char * const *, const char *); 30 | #ifdef __STDC__ 31 | struct timeval; 32 | struct timezone; 33 | #endif 34 | int gettimeofday(struct timeval *, struct timezone *); 35 | int ioctl(int, int, caddr_t); 36 | int pfopen(char *, int); 37 | int setlinebuf(FILE *); 38 | int socket(int, int, int); 39 | int strcasecmp(const char *, const char *); 40 | -------------------------------------------------------------------------------- /libpcap/llc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1997 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * @(#) $Header: /tcpdump/master/libpcap/llc.h,v 1.2 2001-01-28 09:44:50 guy Exp $ (LBL) 22 | */ 23 | 24 | /* 25 | * 802.2 LLC SAP values. 26 | */ 27 | 28 | #ifndef LLCSAP_NULL 29 | #define LLCSAP_NULL 0x00 30 | #endif 31 | #ifndef LLCSAP_GLOBAL 32 | #define LLCSAP_GLOBAL 0xff 33 | #endif 34 | #ifndef LLCSAP_8021B 35 | #define LLCSAP_8021B_I 0x02 36 | #endif 37 | #ifndef LLCSAP_8021B 38 | #define LLCSAP_8021B_G 0x03 39 | #endif 40 | #ifndef LLCSAP_IP 41 | #define LLCSAP_IP 0x06 42 | #endif 43 | #ifndef LLCSAP_PROWAYNM 44 | #define LLCSAP_PROWAYNM 0x0e 45 | #endif 46 | #ifndef LLCSAP_8021D 47 | #define LLCSAP_8021D 0x42 48 | #endif 49 | #ifndef LLCSAP_RS511 50 | #define LLCSAP_RS511 0x4e 51 | #endif 52 | #ifndef LLCSAP_ISO8208 53 | #define LLCSAP_ISO8208 0x7e 54 | #endif 55 | #ifndef LLCSAP_PROWAY 56 | #define LLCSAP_PROWAY 0x8e 57 | #endif 58 | #ifndef LLCSAP_SNAP 59 | #define LLCSAP_SNAP 0xaa 60 | #endif 61 | #ifndef LLCSAP_IPX 62 | #define LLCSAP_IPX 0xe0 63 | #endif 64 | #ifndef LLCSAP_NETBEUI 65 | #define LLCSAP_NETBEUI 0xf0 66 | #endif 67 | #ifndef LLCSAP_ISONS 68 | #define LLCSAP_ISONS 0xfe 69 | #endif 70 | -------------------------------------------------------------------------------- /libpcap/missing/snprintf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoterran/tcpcollect/44b1f8595992a922e848a3ff9a1a2a258cb3dd9e/libpcap/missing/snprintf.c -------------------------------------------------------------------------------- /libpcap/msdos/bin2c.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | static void Abort (char *fmt,...) 7 | { 8 | va_list args; 9 | va_start (args, fmt); 10 | vfprintf (stderr, fmt, args); 11 | va_end (args); 12 | exit (1); 13 | } 14 | 15 | int main (int argc, char **argv) 16 | { 17 | FILE *inFile; 18 | FILE *outFile = stdout; 19 | time_t now = time (NULL); 20 | int ch, i; 21 | 22 | if (argc != 2) 23 | Abort ("Usage: %s bin-file [> result]", argv[0]); 24 | 25 | if ((inFile = fopen(argv[1],"rb")) == NULL) 26 | Abort ("Cannot open %s\n", argv[1]); 27 | 28 | fprintf (outFile, 29 | "/* data statements for file %s at %.24s */\n" 30 | "/* Generated by BIN2C, G.Vanem 1995 */\n", 31 | argv[1], ctime(&now)); 32 | 33 | i = 0; 34 | while ((ch = fgetc(inFile)) != EOF) 35 | { 36 | if (i++ % 12 == 0) 37 | fputs ("\n ", outFile); 38 | fprintf (outFile, "0x%02X,", ch); 39 | } 40 | fputc ('\n', outFile); 41 | fclose (inFile); 42 | return (0); 43 | } 44 | -------------------------------------------------------------------------------- /libpcap/msdos/common.dj: -------------------------------------------------------------------------------- 1 | # 2 | # Common defines for libpcap and 16/32-bit network drivers (djgpp) 3 | # 4 | # @(#) $Header: /tcpdump/master/libpcap/msdos/common.dj,v 1.2 2004-12-19 19:36:33 guy Exp $ (LBL) 5 | 6 | .SUFFIXES: .exe .wlm .dxe .l .y 7 | .PHONY: check_gcclib 8 | 9 | default: check_gcclib all 10 | 11 | GCCLIB = /djgpp/lib/gcc-lib/djgpp/3.31 12 | MAKEFILE = Makefile.dj 13 | 14 | # 15 | # DLX 2.91+ lib. Change path to suite. 16 | # Not used anymore. Uses DXE3 now. 17 | # 18 | # DLX_LIB = $(DJDIR)/contrib/dlx.291/libdlx.a 19 | # DLX_LINK = $(DJDIR)/bin/dlxgen.exe 20 | 21 | WATT32_ROOT = $(subst \,/,$(WATT_ROOT)) 22 | 23 | 24 | ifeq ($(wildcard $(GCCLIB)/libgcc.a),) 25 | check_gcclib: 26 | @echo libgcc.a not found. Set \"$(GCCLIB)\" to \"/djgpp/lib/gcc-lib/djgpp/3.X\" 27 | endif 28 | 29 | 30 | # 31 | # Include 32-bit driver support 32 | # 33 | USE_32BIT_DRIVERS = 0 34 | 35 | # 36 | # Use loadable driver modules instead of statically linking 37 | # all drivers. 38 | # 39 | USE_32BIT_MODULES = 0 40 | 41 | # 42 | # Put interrupt sensitive code/data in locked sections 43 | # Do `make clean' in all affected directories after changing this. 44 | # 45 | USE_SECTION_LOCKING = 0 46 | 47 | # 48 | # Set to 1 to use exception handler lib (only for me) 49 | # 50 | USE_EXCEPT = 0 51 | 52 | CC = gcc.exe 53 | LD = ld.exe 54 | ASM = nasm.exe -fbin -dDEBUG 55 | YACC = bison.exe 56 | LEX = flex.exe 57 | 58 | CFLAGS = -g -gcoff -O2 -Wall -I. -I$(WATT32_ROOT)/inc 59 | 60 | ifeq ($(USE_EXCEPT),1) 61 | CFLAGS += -DUSE_EXCEPT 62 | EXC_LIB = d:/prog/mw/except/lib/libexc.a 63 | endif 64 | 65 | ifeq ($(USE_SECTION_LOCKING),1) 66 | CFLAGS += -DUSE_SECTION_LOCKING 67 | endif 68 | 69 | ifeq ($(USE_32BIT_DRIVERS),1) 70 | CFLAGS += -DUSE_32BIT_DRIVERS 71 | endif 72 | 73 | %.o: %.c 74 | $(CC) -c $(CFLAGS) $< 75 | @echo 76 | 77 | %.o: %.s 78 | $(CC) -c $(CFLAGS) -x assembler-with-cpp -o $@ $< 79 | @echo 80 | 81 | -------------------------------------------------------------------------------- /libpcap/net: -------------------------------------------------------------------------------- 1 | ./bpf/net -------------------------------------------------------------------------------- /libpcap/nlpid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Juniper Networks, Inc. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution. The name of Juniper Networks may not 11 | * be used to endorse or promote products derived from this software 12 | * without specific prior written permission. 13 | * 14 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 15 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 | * 18 | * @(#) $Header: /tcpdump/master/libpcap/nlpid.h,v 1.2 2002-12-06 00:01:34 hannes Exp $ (Juniper) 19 | */ 20 | 21 | /* Types missing from some systems */ 22 | 23 | /* 24 | * Network layer prototocol identifiers 25 | */ 26 | #ifndef ISO8473_CLNP 27 | #define ISO8473_CLNP 0x81 28 | #endif 29 | #ifndef ISO9542_ESIS 30 | #define ISO9542_ESIS 0x82 31 | #endif 32 | #ifndef ISO9542X25_ESIS 33 | #define ISO9542X25_ESIS 0x8a 34 | #endif 35 | #ifndef ISO10589_ISIS 36 | #define ISO10589_ISIS 0x83 37 | #endif 38 | /* 39 | * this does not really belong in the nlpid.h file 40 | * however we need it for generating nice 41 | * IS-IS related BPF filters 42 | */ 43 | #define ISIS_L1_LAN_IIH 15 44 | #define ISIS_L2_LAN_IIH 16 45 | #define ISIS_PTP_IIH 17 46 | #define ISIS_L1_LSP 18 47 | #define ISIS_L2_LSP 20 48 | #define ISIS_L1_CSNP 24 49 | #define ISIS_L2_CSNP 25 50 | #define ISIS_L1_PSNP 26 51 | #define ISIS_L2_PSNP 27 52 | 53 | #ifndef ISO8878A_CONS 54 | #define ISO8878A_CONS 0x84 55 | #endif 56 | #ifndef ISO10747_IDRP 57 | #define ISO10747_IDRP 0x85 58 | #endif 59 | -------------------------------------------------------------------------------- /libpcap/org.tcpdump.chmod_bpf.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | org.tcpdump.chmod_bpf 7 | RunAtLoad 8 | 9 | Program 10 | /usr/local/bin/chmod_bpf 11 | ProgramArguments 12 | 13 | /usr/local/bin/chmod_bpf 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /libpcap/packaging/pcap.spec.in: -------------------------------------------------------------------------------- 1 | %define prefix /usr 2 | %define version @VERSION@ 3 | 4 | Summary: packet capture library 5 | Name: libpcap 6 | Version: %version 7 | Release: 1 8 | Group: Development/Libraries 9 | Copyright: BSD 10 | Source: @NAME@.tar.gz 11 | BuildRoot: /tmp/%{name}-buildroot 12 | URL: http://www.tcpdump.org 13 | 14 | %description 15 | Packet-capture library LIBPCAP @VERSION@ 16 | Now maintained by "The Tcpdump Group" 17 | See http://www.tcpdump.org 18 | Please send inquiries/comments/reports to tcpdump-workers@lists.tcpdump.org 19 | 20 | %prep 21 | %setup 22 | 23 | %post 24 | ldconfig 25 | 26 | %build 27 | CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix 28 | make 29 | 30 | %install 31 | rm -rf $RPM_BUILD_ROOT 32 | make install DESTDIR=$RPM_BUILD_ROOT mandir=/usr/share/man 33 | cd $RPM_BUILD_ROOT/usr/lib 34 | V1=`echo @VERSION@ | sed 's/\\.[^\.]*$//g'` 35 | V2=`echo @VERSION@ | sed 's/\\.[^\.]*\.[^\.]*$//g'` 36 | ln -sf libpcap.so.@VERSION@ libpcap.so.$V1 37 | if test "$V2" -ne "$V1"; then 38 | ln -sf libpcap.so.$V1 libpcap.so.$V2 39 | ln -sf libpcap.so.$V2 libpcap.so 40 | else 41 | ln -sf libpcap.so.$V1 libpcap.so 42 | fi 43 | 44 | %clean 45 | rm -rf $RPM_BUILD_ROOT 46 | 47 | %files 48 | %defattr(-,root,root) 49 | %doc LICENSE CHANGES INSTALL.txt README.linux TODO VERSION CREDITS packaging/pcap.spec 50 | /usr/lib/libpcap.a 51 | /usr/share/man/man3/* 52 | /usr/share/man/man5/* 53 | /usr/share/man/man7/* 54 | /usr/include/pcap.h 55 | /usr/include/pcap/*.h 56 | /usr/include/pcap-bpf.h 57 | /usr/include/pcap-namedb.h 58 | /usr/lib/libpcap.so* 59 | -------------------------------------------------------------------------------- /libpcap/pcap-bt-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Paolo Abeni (Italy) 3 | * 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 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * Bluetooth sniffing API implementation for Linux platform 31 | * By Paolo Abeni 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap-bt-linux.h,v 1.5 2008-04-04 19:37:45 guy Exp $ (LBL) 34 | */ 35 | 36 | /* 37 | * Prototypes for Bluetooth-related functions 38 | */ 39 | int bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str); 40 | pcap_t *bt_create(const char *device, char *ebuf); 41 | -------------------------------------------------------------------------------- /libpcap/pcap-can-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Felix Obenhuber 3 | * 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 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | 32 | /* 33 | * Prototypes for SocketCAN related functions 34 | */ 35 | pcap_t* can_create(const char *device, char *ebuf); 36 | -------------------------------------------------------------------------------- /libpcap/pcap-common.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * We use the "receiver-makes-right" approach to byte order, 4 | * because time is at a premium when we are writing the file. 5 | * In other words, the pcap_file_header and pcap_pkthdr, 6 | * records are written in host byte order. 7 | * Note that the bytes of packet data are written out in the order in 8 | * which they were received, so multi-byte fields in packets are not 9 | * written in host byte order, they're written in whatever order the 10 | * sending machine put them in. 11 | * 12 | * ntoh[ls] aren't sufficient because we might need to swap on a big-endian 13 | * machine (if the file was written in little-end order). 14 | */ 15 | #define SWAPLONG(y) \ 16 | ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff)) 17 | #define SWAPSHORT(y) \ 18 | ( (((y)&0xff)<<8) | ((u_short)((y)&0xff00)>>8) ) 19 | 20 | extern int dlt_to_linktype(int dlt); 21 | 22 | extern int linktype_to_dlt(int linktype); 23 | 24 | extern void swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf, 25 | int header_len_64_bytes); 26 | -------------------------------------------------------------------------------- /libpcap/pcap-config.in: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # 4 | # Script to give the appropriate compiler flags and linker flags 5 | # to use when building code that uses libpcap. 6 | # 7 | static=0 8 | show_cflags=0 9 | show_libs=0 10 | while [ "$#" != 0 ] 11 | do 12 | case "$1" in 13 | 14 | --static) 15 | static=1 16 | ;; 17 | 18 | --cflags) 19 | show_cflags=1 20 | ;; 21 | 22 | --libs) 23 | show_libs=1 24 | ;; 25 | 26 | --additional-libs) 27 | show_additional_libs=1 28 | ;; 29 | esac 30 | shift 31 | done 32 | if [ "@V_RPATH_OPT@" != "" ] 33 | then 34 | # 35 | # If libdir isn't /usr/lib, add it to the run-time linker path. 36 | # 37 | if [ "@libdir@" != "/usr/lib" ] 38 | then 39 | RPATH=@V_RPATH_OPT@@libdir@ 40 | fi 41 | fi 42 | if [ "$static" = 1 ] 43 | then 44 | # 45 | # Include LIBS so that the flags include libraries containing 46 | # routines that libpcap uses. 47 | # 48 | if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] 49 | then 50 | echo "-I@includedir@ -L@libdir@ -lpcap @LIBS@" 51 | elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] 52 | then 53 | echo "-I@includedir@ -L@libdir@ @LIBS@" 54 | elif [ "$show_cflags" = 1 ] 55 | then 56 | echo "-I@includedir@" 57 | elif [ "$show_libs" = 1 ] 58 | then 59 | echo "-L@libdir@ -lpcap @LIBS@" 60 | elif [ "$show_additional_libs" = 1 ] 61 | then 62 | echo "@LIBS@" 63 | fi 64 | else 65 | # 66 | # Omit LIBS - libpcap is assumed to be linked with those 67 | # libraries, so there's no need to do so explicitly. 68 | # 69 | if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] 70 | then 71 | echo "-I@includedir@ -L@libdir@ $RPATH -lpcap" 72 | elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] 73 | then 74 | echo "-I@includedir@" 75 | elif [ "$show_cflags" = 1 ] 76 | then 77 | echo "-I@includedir@" 78 | elif [ "$show_libs" = 1 ] 79 | then 80 | echo "-L@libdir@ $RPATH -lpcap" 81 | fi 82 | fi 83 | -------------------------------------------------------------------------------- /libpcap/pcap-namedb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1996 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 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 | * @(#) $Header: /tcpdump/master/libpcap/pcap-namedb.h,v 1.13 2006-10-04 18:13:32 guy Exp $ (LBL) 34 | */ 35 | 36 | /* 37 | * For backwards compatibility. 38 | * 39 | * Note to OS vendors: do NOT get rid of this file! Some applications 40 | * might expect to be able to include . 41 | */ 42 | #include 43 | -------------------------------------------------------------------------------- /libpcap/pcap-null.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1995, 1996 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | #ifndef lint 22 | static const char rcsid[] _U_ = 23 | "@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.22 2008-04-04 19:37:45 guy Exp $ (LBL)"; 24 | #endif 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include "config.h" 28 | #endif 29 | 30 | #include /* optionally get BSD define */ 31 | 32 | #include 33 | 34 | #ifdef HAVE_OS_PROTO_H 35 | #include "os-proto.h" 36 | #endif 37 | 38 | #include "pcap-int.h" 39 | 40 | static char nosup[] = "live packet capture not supported on this system"; 41 | 42 | pcap_t * 43 | pcap_create(const char *device, char *ebuf) 44 | { 45 | (void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE); 46 | return (NULL); 47 | } 48 | 49 | int 50 | pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) 51 | { 52 | return (0); 53 | } 54 | -------------------------------------------------------------------------------- /libpcap/pcap-septel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pcap-septel.c: Packet capture interface for Intel Septel card 3 | * 4 | * The functionality of this code attempts to mimic that of pcap-linux as much 5 | * as possible. This code is only needed when compiling in the Intel/Septel 6 | * card code at the same time as another type of device. 7 | * 8 | * Authors: Gilbert HOYEK (gil_hoyek@hotmail.com), Elias M. KHOURY 9 | * (+961 3 485343); 10 | * 11 | * @(#) $Header: /tcpdump/master/libpcap/pcap-septel.h,v 1.2 2008-04-04 19:37:45 guy Exp $ 12 | */ 13 | 14 | pcap_t *septel_create(const char *device, char *ebuf); 15 | 16 | -------------------------------------------------------------------------------- /libpcap/pcap-sita.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pcap-sita.h: Packet capture interface for SITA WAN devices 3 | * 4 | * Authors: Fulko Hew (fulko.hew@sita.aero) (+1 905 6815570); 5 | * 6 | * @(#) $Header: /tcpdump/master/libpcap/pcap-sita.h 7 | */ 8 | 9 | extern int acn_parse_hosts_file(char *errbuf); 10 | extern int acn_findalldevs(char *errbuf); 11 | -------------------------------------------------------------------------------- /libpcap/pcap-snf.h: -------------------------------------------------------------------------------- 1 | pcap_t *snf_create(const char *, char *); 2 | int snf_platform_finddevs(pcap_if_t **devlistp, char *errbuf); 3 | -------------------------------------------------------------------------------- /libpcap/pcap-usb-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Paolo Abeni (Italy) 3 | * 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 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * USB sniffing API implementation for Linux platform 31 | * By Paolo Abeni 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.h,v 1.5 2008-04-04 19:37:45 guy Exp $ (LBL) 34 | */ 35 | 36 | /* 37 | * Prototypes for USB-related functions 38 | */ 39 | int usb_platform_finddevs(pcap_if_t **alldevsp, char *err_str); 40 | pcap_t *usb_create(const char *device, char *ebuf); 41 | -------------------------------------------------------------------------------- /libpcap/pcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 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 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the Computer Systems 16 | * Engineering Group at Lawrence Berkeley Laboratory. 17 | * 4. Neither the name of the University nor of the Laboratory may be used 18 | * to endorse or promote products derived from this software without 19 | * specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 | * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.59 2006-10-04 18:09:22 guy Exp $ (LBL) 34 | */ 35 | 36 | /* 37 | * For backwards compatibility. 38 | * 39 | * Note to OS vendors: do NOT get rid of this file! Many applications 40 | * expect to be able to include , and at least some of them 41 | * go through contortions in their configure scripts to try to detect 42 | * OSes that have "helpfully" moved pcap.h to without 43 | * leaving behind a file. 44 | */ 45 | #include 46 | -------------------------------------------------------------------------------- /libpcap/pcap/bluetooth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Paolo Abeni (Italy) 3 | * 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 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote 15 | * products derived from this software without specific prior written 16 | * permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * bluetooth data struct 31 | * By Paolo Abeni 32 | * 33 | * @(#) $Header: /tcpdump/master/libpcap/pcap/bluetooth.h,v 1.1 2007-09-22 02:10:17 guy Exp $ 34 | */ 35 | 36 | #ifndef _PCAP_BLUETOOTH_STRUCTS_H__ 37 | #define _PCAP_BLUETOOTH_STRUCTS_H__ 38 | 39 | /* 40 | * Header prepended libpcap to each bluetooth h:4 frame. 41 | * fields are in network byte order 42 | */ 43 | typedef struct _pcap_bluetooth_h4_header { 44 | u_int32_t direction; /* if first bit is set direction is incoming */ 45 | } pcap_bluetooth_h4_header; 46 | 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libpcap/pcap/ipnet.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * This code is derived from the Stanford/CMU enet packet filter, 6 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed 7 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 8 | * Berkeley Laboratory. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. All advertising materials mentioning features or use of this software 19 | * must display the following acknowledgement: 20 | * This product includes software developed by the University of 21 | * California, Berkeley and its contributors. 22 | * 4. Neither the name of the University nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 | * SUCH DAMAGE. 37 | */ 38 | 39 | #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */ 40 | #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */ 41 | 42 | #define IPNET_OUTBOUND 1 43 | #define IPNET_INBOUND 2 44 | -------------------------------------------------------------------------------- /libpcap/pcap/vlan.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 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 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 | * @(#) $Header: /tcpdump/master/libpcap/pcap/vlan.h,v 1.1 2008-08-06 07:45:00 guy Exp $ 34 | */ 35 | 36 | #ifndef lib_pcap_vlan_h 37 | #define lib_pcap_vlan_h 38 | 39 | struct vlan_tag { 40 | u_int16_t vlan_tpid; /* ETH_P_8021Q */ 41 | u_int16_t vlan_tci; /* VLAN TCI */ 42 | }; 43 | 44 | #define VLAN_TAG_LEN 4 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libpcap/pcap_can_set_rfmon.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_can_set_rfmon.3pcap,v 1.1 2008-04-06 02:53:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_CAN_SET_RFMON 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_can_set_rfmon \- check whether monitor mode can be set for a 25 | not-yet-activated capture handle 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .LP 31 | .ft B 32 | int pcap_can_set_rfmon(pcap_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_can_set_rfmon() 37 | checks whether monitor mode could be set on a capture handle when 38 | the handle is activated. 39 | .SH RETURN VALUE 40 | .B pcap_set_rfmon() 41 | returns 0 if monitor mode could not be set, 42 | 1 if monitor mode could be set, 43 | .B PCAP_ERROR_NO_SUCH_DEVICE 44 | if the device specified when the handle was created doesn't exist, 45 | .B PCAP_ERROR_ACTIVATED 46 | if called on a capture handle that has been activated, or 47 | .B PCAP_ERROR 48 | if an error occurred. 49 | If 50 | .B PCAP_ERROR 51 | is returned, 52 | .B pcap_geterr() 53 | or 54 | .B pcap_perror() 55 | may be called with 56 | .I p 57 | as an argument to fetch or display the error text. 58 | .SH SEE ALSO 59 | pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP), 60 | pcap_set_rfmon(3PCAP) 61 | -------------------------------------------------------------------------------- /libpcap/pcap_close.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_close.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_CLOSE 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_close \- close a capture device or savefile 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | void pcap_close(pcap_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_close() 37 | closes the files associated with 38 | .I p 39 | and deallocates resources. 40 | .SH SEE ALSO 41 | pcap(3PCAP) 42 | -------------------------------------------------------------------------------- /libpcap/pcap_datalink.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DATALINK 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_datalink \- get the link-layer header type 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_datalink(pcap_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_datalink() 37 | returns the link layer type for the live capture or ``savefile'' 38 | specified by 39 | .IR p . 40 | .SH SEE ALSO 41 | pcap(3PCAP), pcap-linktype(7) 42 | -------------------------------------------------------------------------------- /libpcap/pcap_datalink.3pcap.in: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DATALINK 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_datalink \- get the link-layer header type 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_datalink(pcap_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_datalink() 37 | returns the link layer type for the live capture or ``savefile'' 38 | specified by 39 | .IR p . 40 | .SH SEE ALSO 41 | pcap(3PCAP), pcap-linktype(@MAN_MISC_INFO@) 42 | -------------------------------------------------------------------------------- /libpcap/pcap_datalink_name_to_val.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink_name_to_val.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DATALINK_NAME_TO_VAL 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_datalink_name_to_val \- get the link-layer header type value 25 | corresponding to a header type name 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | int pcap_datalink_name_to_val(const char *name); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .B pcap_datalink_name_to_val() 38 | translates a data link type name, which is a 39 | .B DLT_ 40 | name with the 41 | .B DLT_ 42 | removed, to the corresponding data link type value. The translation 43 | is case-insensitive. 44 | .SH RETURN VALUE 45 | .B pcap_datalink_name_to_val() 46 | returns 0 on success and \-1 on failure. 47 | .SH SEE ALSO 48 | pcap(3PCAP) 49 | -------------------------------------------------------------------------------- /libpcap/pcap_datalink_val_to_name.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_datalink_val_to_name.3pcap,v 1.3 2008-12-24 21:45:25 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DATALINK_VAL_TO_NAME 3PCAP "24 December 2008" 23 | .SH NAME 24 | pcap_datalink_val_to_name, pcap_datalink_val_to_description \- get a 25 | name or description for a link-layer header type value 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | const char *pcap_datalink_val_to_name(int dlt); 34 | const char *pcap_datalink_val_to_description(int dlt); 35 | .ft 36 | .fi 37 | .SH DESCRIPTION 38 | .B pcap_datalink_val_to_name() 39 | translates a data link type value to the corresponding data link type 40 | name. NULL is returned on failure. 41 | .PP 42 | .B pcap_datalink_val_to_description() 43 | translates a data link type value to a short description of that data 44 | link type. NULL is returned on failure. 45 | -------------------------------------------------------------------------------- /libpcap/pcap_dump.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DUMP 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_dump \- write a packet to a capture file 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | void pcap_dump(u_char *user, struct pcap_pkthdr *h, 33 | .ti +8 34 | u_char *sp); 35 | .ft 36 | .fi 37 | .SH DESCRIPTION 38 | .B pcap_dump() 39 | outputs a packet to the ``savefile'' opened with 40 | .BR pcap_dump_open() . 41 | Note that its calling arguments are suitable for use with 42 | .B pcap_dispatch() 43 | or 44 | .BR pcap_loop() . 45 | If called directly, the 46 | .I user 47 | parameter is of type 48 | .B pcap_dumper_t 49 | as returned by 50 | .BR pcap_dump_open() . 51 | .SH SEE ALSO 52 | pcap(3PCAP), pcap_dump_open(3PCAP), pcap_dispatch(3PCAP), 53 | pcap_loop(3PCAP) 54 | -------------------------------------------------------------------------------- /libpcap/pcap_dump_close.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_close.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DUMP_CLOSE 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_dump_close \- close a savefile being written to 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | void pcap_dump_close(pcap_dumper_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_dump_close() 37 | closes the ``savefile.'' 38 | .SH SEE ALSO 39 | pcap(3PCAP), pcap_dump_open(3PCAP), pcap_dump(3PCAP) 40 | -------------------------------------------------------------------------------- /libpcap/pcap_dump_file.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_file.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DUMP_FILE 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_dump_file \- get the standard I/O stream for a savefile being written 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | FILE *pcap_dump_file(pcap_dumper_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_dump_file() 37 | returns the standard I/O stream of the ``savefile'' opened by 38 | .BR pcap_dump_open() . 39 | .SH SEE ALSO 40 | pcap(3PCAP) 41 | -------------------------------------------------------------------------------- /libpcap/pcap_dump_flush.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_flush.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DUMP_FLUSH 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_dump_flush \- flush to a savefile packets dumped 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_dump_flush(pcap_dumper_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_dump_flush() 37 | flushes the output buffer to the ``savefile,'' so that any packets 38 | written with 39 | .B pcap_dump() 40 | but not yet written to the ``savefile'' will be written. 41 | .SH RETURN VALUE 42 | .B pcap_dump_flush() 43 | returns 0 on success and \-1 on failure. 44 | .SH SEE ALSO 45 | pcap(3PCAP), pcap_dump_open(3PCAP), pcap_dump(3PCAP) 46 | -------------------------------------------------------------------------------- /libpcap/pcap_dump_ftell.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_dump_ftell.3pcap,v 1.3 2008-04-06 02:53:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_DUMP_FTELL 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_dump_ftell \- get the current file offset for a savefile being written 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | long pcap_dump_ftell(pcap_dumper_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_dump_ftell() 37 | returns the current file position for the ``savefile'', representing the 38 | number of bytes written by 39 | .B pcap_dump_open() 40 | and 41 | .BR pcap_dump() . 42 | \-1 is returned on error. 43 | .SH SEE ALSO 44 | pcap(3PCAP), pcap_dump_open(3PCAP), pcap_dump(3PCAP) 45 | -------------------------------------------------------------------------------- /libpcap/pcap_file.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_file.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_FILE 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_file \- get the standard I/O stream for a savefile being read 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | FILE *pcap_file(pcap_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_file() 37 | returns the standard I/O stream of the ``savefile,'' if a ``savefile'' 38 | was opened with 39 | .BR pcap_open_offline() , 40 | or NULL, if a network device was opened with 41 | .B pcap_create() 42 | and 43 | .BR pcap_activate() , 44 | or with 45 | .BR pcap_open_live() . 46 | .PP 47 | Note that the Packet Capture library is usually built with large file 48 | support, so the standard I/O stream of the ``savefile'' might refer to 49 | a file larger than 2 gigabytes; applications that use 50 | .B pcap_file() 51 | should, if possible, use calls that support large files on the return 52 | value of 53 | .B pcap_file() 54 | or the value returned by 55 | .B fileno() 56 | when passed the return value of 57 | .BR pcap_file() . 58 | .SH SEE ALSO 59 | pcap(3PCAP), pcap_open_offline(3PCAP) 60 | -------------------------------------------------------------------------------- /libpcap/pcap_fileno.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_fileno.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_FILENO 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_fileno \- get the file descriptor for a live capture 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_fileno(pcap_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | If 37 | .I p 38 | refers to a network device that was opened for a live capture using 39 | a combination of 40 | .B pcap_create() 41 | and 42 | .BR pcap_activate() , 43 | or using 44 | .BR pcap_open_live() , 45 | .B pcap_fileno() 46 | returns the file descriptor from which captured packets are read. 47 | .LP 48 | If 49 | .I p 50 | refers to a ``savefile'' that was opened using fuctions such as 51 | .BR pcap_open_offline() 52 | or 53 | .BR pcap_fopen_offline() , 54 | a ``dead'' 55 | .B pcap_t 56 | opened using 57 | .BR pcap_open_dead() , 58 | or a 59 | .B pcap_t 60 | that was created with 61 | .B pcap_create() 62 | but that has not yet been activated with 63 | .BR pcap_activate() , 64 | it returns \-1. 65 | .SH SEE ALSO 66 | pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP), 67 | pcap_open_live(3PCAP), pcap_open_offline(3PCAP), 68 | pcap_fopen_offline(3PCAP), pcap_open_dead(3PCAP) 69 | -------------------------------------------------------------------------------- /libpcap/pcap_free_datalinks.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_free_datalinks.3pcap,v 1.1 2008-05-26 19:58:06 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_FREE_DATALINKS 3PCAP "26 May 2008" 23 | .SH NAME 24 | pcap_free_datalinks \- free a list of link-layer header types from 25 | pcap_get_datalinks() 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | void pcap_free_datalinks(int *dlt_list); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .B pcap_free_datalinks() 38 | is used to free a list of supported data link types returned by 39 | .BR pcap_list_datalinks() . 40 | .SH SEE ALSO 41 | pcap(3PCAP), pcap_list_datalinks(3PCAP) 42 | -------------------------------------------------------------------------------- /libpcap/pcap_freealldevs.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_freealldevs.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_FREEALLDEVS 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_freealldevs \- free a list of capture devices 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | void pcap_freealldevs(pcap_if_t *alldevs); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_freealldevs() 37 | is used to free a list allocated by 38 | .BR pcap_findalldevs() . 39 | .SH SEE ALSO 40 | pcap(3PCAP), pcap_findalldevs(3PCAP) 41 | -------------------------------------------------------------------------------- /libpcap/pcap_freecode.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_freecode.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_FREECODE 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_freecode \- free a BPF program 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | void pcap_freecode(struct bpf_program *); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_freecode() 37 | is used to free up allocated memory pointed to by a 38 | .I bpf_program 39 | struct generated by 40 | .B pcap_compile() 41 | when that BPF program is no longer needed, for example after it 42 | has been made the filter program for a pcap structure by a call to 43 | .BR pcap_setfilter() . 44 | .SH SEE ALSO 45 | pcap(3PCAP), pcap_compile(3PCAP), pcap_setfilter(3PCAP) 46 | -------------------------------------------------------------------------------- /libpcap/pcap_geterr.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_geterr.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_GETERR 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_geterr, pcap_perror \- get or print libpcap error message text 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | char *pcap_geterr(pcap_t *p); 33 | void pcap_perror(pcap_t *p, char *prefix); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .B pcap_geterr() 38 | returns the error text pertaining to the last pcap library error. 39 | .BR NOTE : 40 | the pointer it returns will no longer point to a valid error message 41 | string after the 42 | .B pcap_t 43 | passed to it is closed; you must use or copy the string before closing 44 | the 45 | .BR pcap_t . 46 | .PP 47 | .B pcap_perror() 48 | prints the text of the last pcap library error on 49 | .BR stderr , 50 | prefixed by 51 | .IR prefix . 52 | .SH SEE ALSO 53 | pcap(3PCAP) 54 | -------------------------------------------------------------------------------- /libpcap/pcap_is_swapped.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_is_swapped.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_IS_SWAPPED 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_is_swapped \- find out whether a savefile has the native byte order 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_is_swapped(pcap_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_is_swapped() 37 | returns true if 38 | .I p 39 | refers to a ``savefile'' that uses a different byte order 40 | than the current system. For a live capture, it always returns false. 41 | .SH SEE ALSO 42 | pcap(3PCAP) 43 | -------------------------------------------------------------------------------- /libpcap/pcap_lib_version.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_lib_version.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_LIB_VERSION 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_lib_version \- get the version information for libpcap 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | const char *pcap_lib_version(void); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_lib_version() 37 | returns a pointer to a string giving information about the version of 38 | the libpcap library being used; note that it contains more information 39 | than just a version number. 40 | .SH SEE ALSO 41 | pcap(3PCAP) 42 | -------------------------------------------------------------------------------- /libpcap/pcap_list_datalinks.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_list_datalinks.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_LIST_DATALINKS 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_list_datalinks \- get a list of link-layer header types supported 25 | by a capture device 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | int pcap_list_datalinks(pcap_t *p, int **dlt_buf); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .B pcap_list_datalinks() 38 | is used to get a list of the supported data link types of the interface 39 | associated with the pcap descriptor. 40 | .B pcap_list_datalinks() 41 | allocates an array to hold the list and sets 42 | .IR *dlt_buf . 43 | The caller is responsible for freeing the array with 44 | .BR pcap_free_datalinks (3PCAP). 45 | .SH RETURN VALUE 46 | .B pcap_list_datalinks() 47 | returns the number of data link types in the array on success and \-1 48 | on failure. 49 | If \-1 is returned, 50 | .B pcap_geterr() 51 | or 52 | .B pcap_perror() 53 | may be called with 54 | .I p 55 | as an argument to fetch or display the error text. 56 | .SH SEE ALSO 57 | pcap(3PCAP), pcap_geterr(3PCAP), pcap_free_datalinks(3PCAP), 58 | pcap-linktype(7) 59 | -------------------------------------------------------------------------------- /libpcap/pcap_list_datalinks.3pcap.in: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_list_datalinks.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_LIST_DATALINKS 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_list_datalinks \- get a list of link-layer header types supported 25 | by a capture device 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | int pcap_list_datalinks(pcap_t *p, int **dlt_buf); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .B pcap_list_datalinks() 38 | is used to get a list of the supported data link types of the interface 39 | associated with the pcap descriptor. 40 | .B pcap_list_datalinks() 41 | allocates an array to hold the list and sets 42 | .IR *dlt_buf . 43 | The caller is responsible for freeing the array with 44 | .BR pcap_free_datalinks (3PCAP). 45 | .SH RETURN VALUE 46 | .B pcap_list_datalinks() 47 | returns the number of data link types in the array on success and \-1 48 | on failure. 49 | If \-1 is returned, 50 | .B pcap_geterr() 51 | or 52 | .B pcap_perror() 53 | may be called with 54 | .I p 55 | as an argument to fetch or display the error text. 56 | .SH SEE ALSO 57 | pcap(3PCAP), pcap_geterr(3PCAP), pcap_free_datalinks(3PCAP), 58 | pcap-linktype(@MAN_MISC_INFO@) 59 | -------------------------------------------------------------------------------- /libpcap/pcap_lookupdev.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_lookupdev.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_LOOKUPDEV 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_lookupdev \- find the default device on which to capture 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .nf 32 | .ft B 33 | char errbuf[PCAP_ERRBUF_SIZE]; 34 | .ft 35 | .LP 36 | .ft B 37 | char *pcap_lookupdev(char *errbuf); 38 | .ft 39 | .fi 40 | .SH DESCRIPTION 41 | .B pcap_lookupdev() 42 | returns a pointer to a string giving the name of a network device 43 | suitable for use with 44 | .B pcap_create() 45 | and 46 | .BR pcap_activate() , 47 | or with 48 | .BR pcap_open_live() , 49 | and with 50 | .BR pcap_lookupnet() . 51 | If there is an error, 52 | .B NULL 53 | is returned and 54 | .I errbuf 55 | is filled in with an appropriate error message. 56 | .I errbuf 57 | is assumed to be able to hold at least 58 | .B PCAP_ERRBUF_SIZE 59 | chars. 60 | .SH SEE ALSO 61 | pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP), 62 | pcap_open_live(3PCAP), pcap_lookupnet(3PCAP) 63 | -------------------------------------------------------------------------------- /libpcap/pcap_lookupnet.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_lookupnet.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_LOOKUPNET 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_lookupnet \- find the IPv4 network number and netmask for a device 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .nf 32 | .ft B 33 | char errbuf[PCAP_ERRBUF_SIZE]; 34 | .ft 35 | .LP 36 | .ft B 37 | int pcap_lookupnet(const char *device, bpf_u_int32 *netp, 38 | .ti +8 39 | bpf_u_int32 *maskp, char *errbuf); 40 | .ft 41 | .fi 42 | .SH DESCRIPTION 43 | .B pcap_lookupnet() 44 | is used to determine the IPv4 network number and mask 45 | associated with the network device 46 | .IR device . 47 | Both 48 | .I netp 49 | and 50 | .I maskp 51 | are 52 | .I bpf_u_int32 53 | pointers. 54 | .SH RETURN VALUE 55 | .B pcap_lookupnet() 56 | returns 0 on success and \-1 on failure. 57 | If \-1 is returned, 58 | .I errbuf 59 | is filled in with an appropriate error message. 60 | .I errbuf 61 | is assumed to be able to hold at least 62 | .B PCAP_ERRBUF_SIZE 63 | chars. 64 | .SH SEE ALSO 65 | pcap(3PCAP) 66 | -------------------------------------------------------------------------------- /libpcap/pcap_major_version.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_major_version.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_MAJOR_VERSION 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_major_version, pcap_minor_version \- get the version number of a savefile 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_major_version(pcap_t *p); 33 | int pcap_minor_version(pcap_t *p); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | If 38 | .I p 39 | refers to a savefile, 40 | .B pcap_major_version() 41 | returns the major number of the file format of the savefile and 42 | .B pcap_minor_version() 43 | returns the minor number of the file format of the savefile. The 44 | version number is stored in the header of the savefile. 45 | .PP 46 | If 47 | .I p 48 | refers to a live capture, the values returned by 49 | .B pcap_major_version() 50 | and 51 | .B pcap_minor_version() 52 | are not meaningful. 53 | .SH SEE ALSO 54 | pcap(3PCAP) 55 | -------------------------------------------------------------------------------- /libpcap/pcap_offline_filter.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_offline_filter.3pcap,v 1.1 2008-05-13 15:19:56 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_OFFLINE_FILTER 3PCAP "13 May 2008" 23 | .SH NAME 24 | pcap_offline_filter \- check whether a filter matches a packet 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_offline_filter(struct bpf_program *fp, 33 | .ti +8 34 | const struct pcap_pkthdr *h, const u_char *pkt) 35 | .ft 36 | .fi 37 | .SH DESCRIPTION 38 | .B pcap_offline_filter() 39 | checks whether a filter matches a packet. 40 | .I fp 41 | is a pointer to a 42 | .I bpf_program 43 | struct, usually the result of a call to 44 | .BR pcap_compile() . 45 | .I h 46 | points to the 47 | .I pcap_pkthdr 48 | structure for the packet, and 49 | .I pkt 50 | points to the data in the packet. 51 | .SH RETURN VALUE 52 | .B pcap_offline_filter() 53 | returns the return value of the filter program. This will be zero if 54 | the packet doesn't match the filter and non-zero if the packet matches 55 | the filter. 56 | .SH SEE ALSO 57 | pcap(3PCAP), pcap_compile(3PCAP) 58 | -------------------------------------------------------------------------------- /libpcap/pcap_open_dead.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_open_dead.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_OPEN_DEAD 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_open_dead \- open a fake pcap_t for compiling filters or opening a 25 | capture for output 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | pcap_t *pcap_open_dead(int linktype, int snaplen); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .PP 38 | .B pcap_open_dead() 39 | is used for creating a 40 | .B pcap_t 41 | structure to use when calling the other functions in libpcap. It is 42 | typically used when just using libpcap for compiling BPF code. 43 | .PP 44 | .I linktype 45 | specifies the link-layer type for the 46 | .BR pcap_t . 47 | .PP 48 | .I snaplen 49 | specifies the snapshot length for the 50 | .BR pcap_t . 51 | .SH SEE ALSO 52 | pcap(3PCAP), pcap-linktype(7) 53 | -------------------------------------------------------------------------------- /libpcap/pcap_open_dead.3pcap.in: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_open_dead.3pcap.in,v 1.1 2008-10-21 07:33:02 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_OPEN_DEAD 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_open_dead \- open a fake pcap_t for compiling filters or opening a 25 | capture for output 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | pcap_t *pcap_open_dead(int linktype, int snaplen); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .PP 38 | .B pcap_open_dead() 39 | is used for creating a 40 | .B pcap_t 41 | structure to use when calling the other functions in libpcap. It is 42 | typically used when just using libpcap for compiling BPF code. 43 | .PP 44 | .I linktype 45 | specifies the link-layer type for the 46 | .BR pcap_t . 47 | .PP 48 | .I snaplen 49 | specifies the snapshot length for the 50 | .BR pcap_t . 51 | .SH SEE ALSO 52 | pcap(3PCAP), pcap-linktype(@MAN_MISC_INFO@) 53 | -------------------------------------------------------------------------------- /libpcap/pcap_set_buffer_size.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_buffer_size.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_SET_BUFFER_SIZE 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_set_buffer_size \- set the buffer size for a not-yet-activated 25 | capture handle 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .LP 31 | .ft B 32 | int pcap_set_buffer_size(pcap_t *p, int buffer_size); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_set_buffer_size() 37 | sets the buffer size that will be used on a capture handle when 38 | the handle is activated to 39 | .IR buffer_size , 40 | which is in units of bytes. 41 | .SH RETURN VALUE 42 | .B pcap_set_buffer_size() 43 | returns 0 on success or 44 | .B PCAP_ERROR_ACTIVATED 45 | if called on a capture handle that has been activated. 46 | .SH SEE ALSO 47 | pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP) 48 | -------------------------------------------------------------------------------- /libpcap/pcap_set_datalink.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_datalink.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_SET_DATALINK 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_set_datalink \- set the link-layer header type to be used by a 25 | capture device 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .ft 31 | .LP 32 | .ft B 33 | int pcap_set_datalink(pcap_t *p, int dlt); 34 | .ft 35 | .fi 36 | .SH DESCRIPTION 37 | .B pcap_set_datalink() 38 | is used to set the current data link type of the pcap descriptor 39 | to the type specified by 40 | .IR dlt . 41 | .SH RETURN VALUE 42 | .B pcap_set_datalink() 43 | returns 0 on success and \-1 on failure. 44 | If \-1 is returned, 45 | .B pcap_geterr() 46 | or 47 | .B pcap_perror() 48 | may be called with 49 | .I p 50 | as an argument to fetch or display the error text. 51 | .SH SEE ALSO 52 | pcap(3PCAP), pcap_geterr(3PCAP) 53 | -------------------------------------------------------------------------------- /libpcap/pcap_set_promisc.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_promisc.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_SET_PROMISC 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_set_promisc \- set promiscuous mode for a not-yet-activated 25 | capture handle 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .LP 31 | .ft B 32 | int pcap_set_promisc(pcap_t *p, int promisc); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_set_promisc() 37 | sets whether promiscuous mode should be set on a capture handle when 38 | the handle is activated. 39 | If 40 | .I promisc 41 | is non-zero, promiscuous mode will be set, otherwise it will not be set. 42 | .SH RETURN VALUE 43 | .B pcap_set_promisc() 44 | returns 0 on success or 45 | .B PCAP_ERROR_ACTIVATED 46 | if called on a capture handle that has been activated. 47 | .SH SEE ALSO 48 | pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP) 49 | -------------------------------------------------------------------------------- /libpcap/pcap_set_rfmon.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_rfmon.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_SET_RFMON 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_set_rfmon \- set monitor mode for a not-yet-activated capture 25 | handle 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .LP 31 | .ft B 32 | int pcap_set_rfmon(pcap_t *p, int rfmon); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_set_rfmon() 37 | sets whether monitor mode should be set on a capture handle when 38 | the handle is activated. 39 | If 40 | .I rfmon 41 | is non-zero, monitor mode will be set, otherwise it will not be set. 42 | .SH RETURN VALUE 43 | .B pcap_set_rfmon() 44 | returns 0 on success or 45 | .B PCAP_ERROR_ACTIVATED 46 | if called on a capture handle that has been activated. 47 | .SH SEE ALSO 48 | pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP), 49 | pcap_can_set_rfmon(3PCAP) 50 | -------------------------------------------------------------------------------- /libpcap/pcap_set_snaplen.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_snaplen.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_SET_SNAPLEN 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_set_snaplen \- set the snapshot length for a not-yet-activated 25 | capture handle 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .LP 31 | .ft B 32 | int pcap_set_snaplen(pcap_t *p, int snaplen); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_set_snaplen() 37 | sets the snapshot length to be used on a capture handle when the handle 38 | is activated to 39 | .IR snaplen . 40 | .SH RETURN VALUE 41 | .B pcap_set_snaplen() 42 | returns 0 on success or 43 | .B PCAP_ERROR_ACTIVATED 44 | if called on a capture handle that has been activated. 45 | .SH SEE ALSO 46 | pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP) 47 | -------------------------------------------------------------------------------- /libpcap/pcap_set_timeout.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_set_timeout.3pcap,v 1.1 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_SET_TIMEOUT 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_set_timeout \- set the read timeout for a not-yet-activated 25 | capture handle 26 | .SH SYNOPSIS 27 | .nf 28 | .ft B 29 | #include 30 | .LP 31 | .ft B 32 | int pcap_set_timeout(pcap_t *p, int to_ms); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_set_timeout() 37 | sets the read timeout that will be used on a capture handle when 38 | the handle is activated to 39 | .IR to_ms , 40 | which is in units of milliseconds. 41 | .SH RETURN VALUE 42 | .B pcap_set_timeout() 43 | returns 0 on success or 44 | .B PCAP_ERROR_ACTIVATED 45 | if called on a capture handle that has been activated. 46 | .SH SEE ALSO 47 | pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP) 48 | -------------------------------------------------------------------------------- /libpcap/pcap_setfilter.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_setfilter.3pcap,v 1.4 2008-05-13 15:19:56 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_SETFILTER 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_setfilter \- set the filter 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_setfilter(pcap_t *p, struct bpf_program *fp); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_setfilter() 37 | is used to specify a filter program. 38 | .I fp 39 | is a pointer to a 40 | .I bpf_program 41 | struct, usually the result of a call to 42 | .BR pcap_compile() . 43 | .SH RETURN VALUE 44 | .B pcap_setfilter() 45 | returns 0 on success and \-1 on failure. 46 | If \-1 is returned, 47 | .B pcap_geterr() 48 | or 49 | .B pcap_perror() 50 | may be called with 51 | .I p 52 | as an argument to fetch or display the error text. 53 | .SH SEE ALSO 54 | pcap(3PCAP), pcap_compile(3PCAP), pcap_geterr(3PCAP) 55 | -------------------------------------------------------------------------------- /libpcap/pcap_snapshot.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_snapshot.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_SNAPSHOT 3PCAP "5 April 2008" 23 | .SH NAME 24 | pcap_snapshot \- get the snapshot length 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | int pcap_snapshot(pcap_t *p); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_snapshot() 37 | returns the snapshot length specified when 38 | .B pcap_set_snapshot() 39 | or 40 | .B pcap_open_live() 41 | was called, for a live capture, or the snapshot length from the capture 42 | file, for a ``savefile''. 43 | .SH SEE ALSO 44 | pcap(3PCAP) 45 | -------------------------------------------------------------------------------- /libpcap/pcap_statustostr.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_statustostr.3pcap,v 1.1 2008-04-09 21:39:21 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_STATUSTOSTR 3PCAP "9 April 2008" 23 | .SH NAME 24 | pcap_statustostr \- convert a PCAP_ERROR_ or PCAP_WARNING_ value to a string 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | const char *pcap_statustostr(int error); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_statustostr() 37 | converts a 38 | .B PCAP_ERROR_ 39 | or 40 | .B PCAP_WARNING_ 41 | value returned by a libpcap routine to an error string. 42 | .SH SEE ALSO 43 | pcap(3PCAP) 44 | -------------------------------------------------------------------------------- /libpcap/pcap_strerror.3pcap: -------------------------------------------------------------------------------- 1 | .\" @(#) $Header: /tcpdump/master/libpcap/pcap_strerror.3pcap,v 1.2 2008-04-05 20:26:56 guy Exp $ 2 | .\" 3 | .\" Copyright (c) 1994, 1996, 1997 4 | .\" The Regents of the University of California. All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that: (1) source code distributions 8 | .\" retain the above copyright notice and this paragraph in its entirety, (2) 9 | .\" distributions including binary code include the above copyright notice and 10 | .\" this paragraph in its entirety in the documentation or other materials 11 | .\" provided with the distribution, and (3) all advertising materials mentioning 12 | .\" features or use of this software display the following acknowledgement: 13 | .\" ``This product includes software developed by the University of California, 14 | .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | .\" the University nor the names of its contributors may be used to endorse 16 | .\" or promote products derived from this software without specific prior 17 | .\" written permission. 18 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | .\" 22 | .TH PCAP_STRERROR 3PCAP "4 April 2008" 23 | .SH NAME 24 | pcap_strerror \- convert an errno value to a string 25 | .SH SYNOPSIS 26 | .nf 27 | .ft B 28 | #include 29 | .ft 30 | .LP 31 | .ft B 32 | const char *pcap_strerror(int error); 33 | .ft 34 | .fi 35 | .SH DESCRIPTION 36 | .B pcap_strerror() 37 | is provided in case 38 | .BR strerror (3) 39 | isn't available. It returns an error message string corresponding to 40 | .IR error . 41 | .SH SEE ALSO 42 | strerror(3) 43 | -------------------------------------------------------------------------------- /libpcap/sf-pcap-ng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * sf-pcap-ng.h - pcap-ng-file-format-specific routines 22 | * 23 | * Used to read pcap-ng savefiles. 24 | */ 25 | 26 | #ifndef sf_pcap_ng_h 27 | #define sf_pcap_ng_h 28 | 29 | extern int pcap_ng_check_header(pcap_t *, bpf_u_int32, FILE *, char *); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libpcap/sf-pcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1995, 1996, 1997 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: (1) source code distributions 7 | * retain the above copyright notice and this paragraph in its entirety, (2) 8 | * distributions including binary code include the above copyright notice and 9 | * this paragraph in its entirety in the documentation or other materials 10 | * provided with the distribution, and (3) all advertising materials mentioning 11 | * features or use of this software display the following acknowledgement: 12 | * ``This product includes software developed by the University of California, 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 14 | * the University nor the names of its contributors may be used to endorse 15 | * or promote products derived from this software without specific prior 16 | * written permission. 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * sf-pcap.h - libpcap-file-format-specific routines 22 | * Extraction/creation by Jeffrey Mogul, DECWRL 23 | * Modified by Steve McCanne, LBL. 24 | * 25 | * Used to save the received packet headers, after filtering, to 26 | * a file, and then read them later. 27 | * The first record in the file contains saved values for the machine 28 | * dependent values so we can print the dump file on any architecture. 29 | */ 30 | 31 | #ifndef sf_pcap_h 32 | #define sf_pcap_h 33 | 34 | extern int pcap_check_header(pcap_t *, bpf_u_int32, FILE *, char *); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libpcap/sunatmpos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 Yen Yen Lim and North Dakota State University 3 | * 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 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by Yen Yen Lim and 16 | North Dakota State University 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 29 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | * POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * @(#) $Header: /tcpdump/master/libpcap/sunatmpos.h,v 1.1 2002-07-11 09:06:47 guy Exp $ (LBL) 33 | */ 34 | 35 | /* SunATM header for ATM packet */ 36 | #define SUNATM_DIR_POS 0 37 | #define SUNATM_VPI_POS 1 38 | #define SUNATM_VCI_POS 2 39 | #define SUNATM_PKT_BEGIN_POS 4 /* Start of ATM packet */ 40 | 41 | /* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */ 42 | #define PT_LANE 0x01 /* LANE */ 43 | #define PT_LLC 0x02 /* LLC encapsulation */ 44 | #define PT_ILMI 0x05 /* ILMI */ 45 | #define PT_QSAAL 0x06 /* Q.SAAL */ 46 | -------------------------------------------------------------------------------- /log.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOG_H_ 2 | #define _LOG_H_ 3 | 4 | /* 5 | syslog.h 6 | 7 | 54 #define LOG_ERR 3 error conditions 8 | 55 #define LOG_WARNING 4 warning conditions 9 | 56 #define LOG_NOTICE 5 normal but significant condition, success 10 | 57 #define LOG_INFO 6 informational 11 | 58 #define LOG_DEBUG 7 debug-level messages 12 | 13 | */ 14 | 15 | #define L_ERR 3 16 | #define L_WARN 4 17 | #define L_OK 5 18 | #define L_INFO 6 19 | #define L_DEBUG 7 20 | 21 | void log_init(const char *prefix, const char *format, const char *suffix, int level); 22 | 23 | #define dump(x,y...) _log(#x, x, ##y) 24 | 25 | void _log(const char *levelstring, int level, const char *fmt, ...); 26 | 27 | void log_change_level(); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /mysqlpcap-prepare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoterran/tcpcollect/44b1f8595992a922e848a3ff9a1a2a258cb3dd9e/mysqlpcap-prepare.png -------------------------------------------------------------------------------- /mysqlpcap.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSQLPCAP_ 2 | #define _MYSQLPCAP_ 3 | 4 | struct _MysqlPcap; 5 | typedef struct _MysqlPcap MysqlPcap; 6 | 7 | typedef int (*initFp) (MysqlPcap *); 8 | typedef int (*addFp) (MysqlPcap *, const char *fmt, ...); 9 | typedef int (*flushFp) (MysqlPcap *, int force); 10 | 11 | #include 12 | #include 13 | 14 | #define HOST_NAME_LEN 64 15 | 16 | struct _MysqlPcap { 17 | void *pd; 18 | char hostname[HOST_NAME_LEN]; 19 | int mysqlPort; 20 | char filter[10240]; /* 15(ip) * 100 */ 21 | char netDev[10]; 22 | bpf_u_int32 netmask; 23 | bpf_u_int32 localnet; 24 | char keyWord[256]; 25 | void *hash; 26 | 27 | pthread_mutex_t aux_mutex; 28 | pthread_t aux_thread_id; 29 | char *address; /* user input */ 30 | void *al; /* address list */ 31 | void *new_al; /* new list, lock then switch*/ 32 | 33 | int isShowSrcIp; 34 | void *focusUser; 35 | void *filterUser; 36 | time_t fakeNow; 37 | time_t lastReloadAddressTime; 38 | long packetSeq; /* packet sequence */ 39 | /* for debug */ 40 | ulong datalen; 41 | char is_in; 42 | uint32 tcp_seq; 43 | 44 | /* cache */ 45 | initFp initCache; 46 | addFp addCache; 47 | flushFp flushCache; 48 | 49 | char cacheFileName[256]; /* only use file cache */ 50 | char cacheConfigFileName[256]; /* redis config, mysql config */ 51 | 52 | void *config; /* fd, redisContext, MYSQL */ 53 | time_t cacheFlushTime; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /mysqlpcap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoterran/tcpcollect/44b1f8595992a922e848a3ff9a1a2a258cb3dd9e/mysqlpcap.png -------------------------------------------------------------------------------- /packet.h: -------------------------------------------------------------------------------- 1 | #ifndef PACKET_H 2 | #define PROCESS_PACKET_H 3 | 4 | #include 5 | #include 6 | 7 | #include "mysqlpcap.h" 8 | 9 | #define CAP_LEN 65536 10 | 11 | int start_packet(MysqlPcap * mp); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /stat.h: -------------------------------------------------------------------------------- 1 | 2 | void addPacketInfo(char incoming, uint32 datalen, uint32 tcp_seq, 3 | uint16 dport, uint16 sport, char *payload); 4 | 5 | void printPacketInfo(); 6 | 7 | void printLastPacketInfo(int count); 8 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1. 两个 大结果集 互相干扰 6 | 2. 绑定变量各种类型,时间,字符串,blob 7 | 3. 一个程序里两个绑定变量,交互执行 8 | 4. 绑定变量在任何阶段,mysqlpcap 启动进入 9 | 10 | 11 | 10.249.194.51 12 | 13 | admin/wangzy_2011 14 | 15 | /home/admin/legs/mysql-5.1.61/tests/mysql_client_test -htopmy.mysql.mysql.alibabalabs.com -ujc04 -pa1234561 -Ddbjc01 -P3306 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/a.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | char *c = "abcdefg"; 6 | printf("%3x\n", c); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/bak_p23.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(0))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | // simple 22 | char sql[100] = {}; 23 | 24 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)"); 25 | 26 | mysql_query(sock, sql); 27 | 28 | mysql_query(sock, "select * from blob_test"); 29 | 30 | result = mysql_store_result(mysql); 31 | mysql_free_result(result); 32 | 33 | #define INSERT_QUERY "INSERT INTO blob_test(a, b) VALUES(?,?)" 34 | 35 | MYSQL_STMT *stmt; 36 | MYSQL_BIND bind[2]; 37 | long length; 38 | int int_data = 10; 39 | char str[100]; 40 | int ret; 41 | 42 | stmt = mysql_stmt_init(mysql); 43 | 44 | mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY)); 45 | 46 | memset(bind, 0, sizeof(bind)); 47 | bind[0].buffer_type= MYSQL_TYPE_LONG; 48 | bind[0].buffer= (char *)&int_data; 49 | bind[0].is_null= 0; 50 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 51 | bind[1].buffer = (char*)&str; 52 | bind[1].is_null= 0; 53 | mysql_stmt_bind_param(stmt, bind); 54 | 55 | ret = mysql_stmt_send_long_data(stmt,1,"MySQL",5); 56 | 57 | ret = mysql_stmt_send_long_data(stmt,1," - The most popular Open Source database",40); 58 | 59 | mysql_stmt_execute(stmt); 60 | 61 | return 0; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /test/p10_use_db.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | char *sql; 23 | 24 | int i; 25 | 26 | for(i = 0; i < 10000; i++) { 27 | //1 28 | mysql_select_db(sock, "mysql"); 29 | 30 | //2 31 | sql = "use test"; 32 | mysql_query(sock, sql); 33 | 34 | mysql_query(sock, "select * from n"); 35 | 36 | result = mysql_store_result(sock); 37 | 38 | mysql_free_result(result); 39 | 40 | //3 41 | mysql_select_db(sock, "information_schema"); 42 | } 43 | 44 | mysql_close(mysql); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /test/p12_perf_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | int i; 23 | 24 | char *sql = "select 111111111111111111111111111111111111111111111111111111111111111111111111111"; 25 | 26 | while(1) { 27 | mysql_query(sock, sql); 28 | result = mysql_store_result(sock); 29 | mysql_free_result(result); 30 | } 31 | 32 | mysql_close(mysql); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /test/p13_com_field_list.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | char *sql; 23 | 24 | int i; 25 | 26 | mysql_list_fields(mysql, "a1", ""); 27 | 28 | sleep(3); 29 | 30 | mysql_close(mysql); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /test/p14_local_file.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | char *sql; 23 | 24 | int i; 25 | 26 | mysql_list_fields(mysql, "a1", ""); 27 | 28 | sleep(3); 29 | 30 | mysql_close(mysql); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /test/p15_com_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | char *sql; 23 | 24 | int i; 25 | 26 | /*list dbs*/ 27 | mysql_list_dbs(mysql, ""); 28 | result = mysql_store_result(mysql); 29 | mysql_free_result(result); 30 | 31 | /* COM_FERESH */ 32 | mysql_refresh(mysql, REFRESH_TABLES); 33 | 34 | /* COM_PROCESS_INFO */ 35 | mysql_list_processes(mysql); 36 | result = mysql_store_result(mysql); 37 | mysql_free_result(result); 38 | 39 | /* create db */ 40 | //mysql_create_db(mysql, "new_test"); 41 | 42 | mysql_set_server_option(mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); 43 | 44 | mysql_change_user(mysql, "kkk", "kkk", "test"); 45 | 46 | sleep(3); 47 | mysql_close(mysql); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /test/p19_null_prepare.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | #define STRING_SIZE 1024 9 | 10 | /* 11 | 12 | MYSQL_TYPE_TIMESTAMP TIMESTAMP field 13 | MYSQL_TYPE_DATE DATE field 14 | MYSQL_TYPE_TIME TIME field 15 | MYSQL_TYPE_DATETIME DATETIME field 16 | 17 | */ 18 | 19 | #define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table" 20 | #define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT, col2 varchar(40))" 21 | #define INSERT_SAMPLE "INSERT INTO test_table(col1,col2) VALUES(?,?)" 22 | 23 | int main (int argc, char *argv[]) { 24 | 25 | MYSQL *mysql; 26 | MYSQL_RES *result; 27 | MYSQL_ROW row; 28 | my_bool reconnect = 0; 29 | mysql = mysql_init(NULL); 30 | mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); 31 | 32 | CONN(0); 33 | 34 | MYSQL_STMT *stmt; 35 | MYSQL_BIND bind[2]; 36 | my_ulonglong affected_rows; 37 | int param_count; 38 | short small_data; 39 | int int_data; 40 | char str_data[STRING_SIZE]; 41 | unsigned long str_length; 42 | my_bool is_null; 43 | 44 | mysql_query(mysql, DROP_SAMPLE_TABLE); 45 | 46 | mysql_query(mysql, CREATE_SAMPLE_TABLE); 47 | 48 | stmt = mysql_stmt_init(mysql); 49 | 50 | char *sql = "select * from test_table"; 51 | 52 | mysql_stmt_prepare(stmt, sql, strlen(sql)); 53 | 54 | mysql_stmt_execute(stmt); // --------------------------2 ok 55 | 56 | while(!mysql_stmt_fetch(stmt)) { // here return resultset 57 | printf("%d - %s\n", int_data, str_data); 58 | } 59 | 60 | mysql_stmt_close(stmt); 61 | } 62 | -------------------------------------------------------------------------------- /test/p2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | #define INSERT_SQL "insert into player_copy(id, name) values(?, ?)" 9 | 10 | void main(int argc, char **argv) 11 | { 12 | MYSQL *mysql,*sock; 13 | MYSQL_STMT *st; 14 | MYSQL_BIND bind[2]; 15 | 16 | int param_count; 17 | int int_data; 18 | int i; 19 | char str_data[3]; 20 | unsigned long str_length; 21 | my_bool is_null; 22 | 23 | mysql = mysql_init(NULL); 24 | if (!(sock = CONN(0))) { 25 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 26 | perror(""); 27 | exit(1); 28 | } 29 | 30 | mysql_query(sock, "create table player_copy (id int, name varchar(20))"); 31 | 32 | st = mysql_stmt_init(mysql); 33 | mysql_stmt_prepare(st, INSERT_SQL, 47); 34 | param_count = mysql_stmt_param_count(st); 35 | fprintf(stdout, " total parameters in INSERT: %d\n", param_count); 36 | 37 | for (i = 1; i < 1000; i ++) { 38 | int_data = i; 39 | str_data[0] = 'a'; 40 | str_data[1] = 'b'; 41 | str_data[2] = 'c'; 42 | str_length = 3; 43 | is_null = 0; 44 | 45 | bind[0].buffer_type= MYSQL_TYPE_LONG; 46 | bind[0].buffer= &int_data; 47 | bind[0].is_null= &is_null; 48 | 49 | bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; 50 | bind[1].buffer= (char *)str_data; 51 | bind[1].is_null= &is_null; 52 | bind[1].length= &str_length; 53 | 54 | mysql_stmt_bind_param(st, bind); 55 | mysql_stmt_execute(st); 56 | } 57 | 58 | mysql_query(sock, "drop table player_copy"); 59 | } 60 | -------------------------------------------------------------------------------- /test/p22_blob.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(CLIENT_MULTI_STATEMENTS))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | // simple 22 | char sql[100] = {}; 23 | 24 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)"); 25 | 26 | mysql_query(sock, sql); 27 | 28 | mysql_query(sock, "select * from blob_test"); 29 | 30 | result = mysql_store_result(mysql); 31 | mysql_free_result(result); 32 | 33 | //prepare 34 | 35 | MYSQL_STMT *stmt; 36 | MYSQL_BIND bind[2]; 37 | my_ulonglong affected_rows; 38 | int param_count; 39 | short small_data; 40 | int int_data; 41 | char str_data[1000]; 42 | unsigned long str_length; 43 | my_bool is_null; 44 | 45 | stmt = mysql_stmt_init(mysql); 46 | 47 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (?, ?)"); 48 | mysql_stmt_prepare(stmt, sql, strlen(sql)); 49 | 50 | memset(bind, 0, sizeof(bind)); 51 | 52 | /* INTEGER PARAM */ 53 | /* This is a number type, so there is no need to specify buffer_length */ 54 | bind[0].buffer_type= MYSQL_TYPE_LONG; 55 | bind[0].buffer= (char *)&int_data; 56 | bind[0].is_null= 0; 57 | 58 | /* STRING PARAM */ 59 | my_bool a = 1; 60 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 61 | bind[1].buffer= (char *)str_data; 62 | bind[1].is_null= &a; 63 | bind[1].length= &str_length; //实际大小, bind_ 64 | 65 | mysql_stmt_bind_param(stmt, bind); 66 | 67 | /* Specify the data values for the first row -------------------------------------------------- */ 68 | int_data= 10; /* integer */ 69 | strncpy(str_data, "MySQL", 1000); /* string */ 70 | str_length= strlen(str_data); 71 | 72 | mysql_stmt_execute(stmt); 73 | 74 | mysql_stmt_close(stmt); 75 | 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /test/p23_stmt_send_long_data.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(0))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | // simple 22 | char sql[100] = {}; 23 | 24 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)"); 25 | 26 | mysql_query(sock, sql); 27 | 28 | mysql_query(sock, "select * from blob_test"); 29 | 30 | result = mysql_store_result(mysql); 31 | mysql_free_result(result); 32 | 33 | #define INSERT_QUERY "INSERT INTO blob_test(a, b) VALUES(?,?)" 34 | 35 | MYSQL_STMT *stmt; 36 | MYSQL_BIND bind[2]; 37 | long length; 38 | int int_data = 10; 39 | char str[100]; 40 | int ret; 41 | 42 | stmt = mysql_stmt_init(mysql); 43 | 44 | mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY)); 45 | 46 | memset(bind, 0, sizeof(bind)); 47 | bind[0].buffer_type= MYSQL_TYPE_LONG; 48 | bind[0].buffer= (char *)&int_data; 49 | bind[0].is_null= 0; 50 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 51 | bind[1].buffer = (char*)&str; 52 | bind[1].is_null= 0; 53 | mysql_stmt_bind_param(stmt, bind); 54 | 55 | ret = mysql_stmt_send_long_data(stmt,1,"MySQL",5); 56 | 57 | ret = mysql_stmt_send_long_data(stmt,1," - The most popular Open Source database",40); 58 | 59 | mysql_stmt_execute(stmt); 60 | 61 | return 0; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /test/p24_stmt_send_long_data2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(0))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | // simple 22 | char sql[100] = {}; 23 | 24 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)"); 25 | 26 | mysql_query(sock, sql); 27 | 28 | mysql_query(sock, "select * from blob_test"); 29 | 30 | result = mysql_store_result(mysql); 31 | mysql_free_result(result); 32 | 33 | #define INSERT_QUERY "INSERT INTO blob_test(a, b) VALUES(?,?)" 34 | 35 | MYSQL_STMT *stmt; 36 | MYSQL_BIND bind[2]; 37 | long length; 38 | int int_data = 10; 39 | char str[100]; 40 | int ret; 41 | 42 | stmt = mysql_stmt_init(mysql); 43 | 44 | mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY)); 45 | 46 | memset(bind, 0, sizeof(bind)); 47 | bind[0].buffer_type= MYSQL_TYPE_LONG; 48 | bind[0].buffer= (char *)&int_data; 49 | bind[0].is_null= 0; 50 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 51 | bind[1].buffer = (char*)&str; 52 | bind[1].is_null= 0; 53 | mysql_stmt_bind_param(stmt, bind); 54 | 55 | ret = mysql_stmt_send_long_data(stmt,1,"fails",5); 56 | 57 | ret = mysql_stmt_send_long_data(stmt,1," - The most popular Open Source database",40); 58 | 59 | mysql_stmt_execute(stmt); 60 | 61 | mysql_stmt_close(stmt); 62 | 63 | stmt = mysql_stmt_init(mysql); 64 | 65 | mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY)); 66 | 67 | size_t s = sizeof(str); 68 | 69 | memset(bind, 0, sizeof(bind)); 70 | bind[0].buffer_type= MYSQL_TYPE_LONG; 71 | bind[0].buffer= (char *)&int_data; 72 | bind[0].is_null= 0; 73 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 74 | bind[1].buffer = (char*)&str; 75 | bind[1].is_null= 0; 76 | bind[1].length= (char*)&s; 77 | mysql_stmt_bind_param(stmt, bind); 78 | 79 | snprintf(str, sizeof(str), "%s", "this success"); 80 | 81 | mysql_stmt_execute(stmt); 82 | 83 | mysql_stmt_close(stmt); 84 | 85 | return 0; 86 | } 87 | 88 | -------------------------------------------------------------------------------- /test/p28_compress.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | 9 | int main(int argc, char* argv[]) 10 | { 11 | MYSQL *mysql,*sock; 12 | MYSQL_ROW row; 13 | MYSQL_RES *result; 14 | 15 | /* add compress */ 16 | mysql = mysql_init(NULL); 17 | if (!(sock = CONN(CLIENT_COMPRESS))) { 18 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 19 | perror(""); 20 | exit(1); 21 | } 22 | 23 | char *sql = "select 1"; 24 | 25 | mysql_query(sock, sql); 26 | result= mysql_store_result(sock); 27 | row = mysql_fetch_row(result); 28 | 29 | mysql_set_server_option(mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /test/p3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | #define STRING_SIZE 1024 9 | 10 | #define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table" 11 | #define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT, col2 VARCHAR(40))" 12 | #define INSERT_SAMPLE "INSERT INTO test_table(col1,col2) VALUES(1, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")" 13 | 14 | #define INSERT_SAMPLE2 "INSERT INTO test_table select * from test_table" 15 | 16 | int main (int argc, char *argv[]) { 17 | 18 | MYSQL *mysql; 19 | MYSQL_RES *result; 20 | MYSQL_ROW row; 21 | my_bool reconnect = 0; 22 | mysql = mysql_init(NULL); 23 | mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); 24 | 25 | CONN(0); 26 | 27 | MYSQL_STMT *stmt; 28 | MYSQL_BIND bind[7]; 29 | my_ulonglong affected_rows; 30 | int param_count; 31 | short small_data; 32 | int int_data; 33 | char str_data[STRING_SIZE]; 34 | unsigned long str_length; 35 | my_bool is_null; 36 | 37 | if (mysql_query(mysql, DROP_SAMPLE_TABLE)) 38 | { 39 | fprintf(stderr, " DROP TABLE failed\n"); 40 | fprintf(stderr, " %s\n", mysql_error(mysql)); 41 | exit(0); 42 | } 43 | 44 | if (mysql_query(mysql, CREATE_SAMPLE_TABLE)) 45 | { 46 | fprintf(stderr, " CREATE TABLE failed\n"); 47 | fprintf(stderr, " %s\n", mysql_error(mysql)); 48 | exit(0); 49 | } 50 | 51 | int i = 0; 52 | mysql_query(mysql, INSERT_SAMPLE); 53 | for (; i < 16; i++) { 54 | mysql_query(mysql, INSERT_SAMPLE2); 55 | } 56 | mysql_query(mysql, "select * from test_table"); 57 | 58 | /*last data will miss */ 59 | 60 | } 61 | -------------------------------------------------------------------------------- /test/p4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "c.h" 8 | #define STRING_SIZE 1024 9 | 10 | #define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table" 11 | #define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT, col2 VARCHAR(40))" 12 | #define INSERT_SAMPLE "INSERT INTO test_table(col1,col2) VALUES(1, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")" 13 | 14 | #define INSERT_SAMPLE2 "INSERT INTO test_table select * from test_table" 15 | 16 | int main (int argc, char *argv[]) { 17 | 18 | MYSQL *mysql; 19 | MYSQL_RES *result; 20 | MYSQL_ROW row; 21 | my_bool reconnect = 0; 22 | mysql = mysql_init(NULL); 23 | mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); 24 | 25 | CONN(0); 26 | 27 | MYSQL_STMT *stmt; 28 | MYSQL_BIND bind[7]; 29 | my_ulonglong affected_rows; 30 | int param_count; 31 | short small_data; 32 | int int_data; 33 | char str_data[STRING_SIZE]; 34 | unsigned long str_length; 35 | my_bool is_null; 36 | 37 | mysql_query(mysql, "select * from d limit 100000"); 38 | 39 | result = mysql_store_result(mysql); 40 | 41 | while(mysql_fetch_row(result)); 42 | 43 | mysql_close(mysql); 44 | } 45 | -------------------------------------------------------------------------------- /test/p5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | 9 | #define SQL "select user(), current_user()" 10 | 11 | void main(int argc, char **argv) 12 | { 13 | MYSQL *mysql,*sock; 14 | MYSQL_STMT *st; 15 | char str[2][50]; 16 | MYSQL_BIND my_bind[2]; 17 | 18 | int param_count; 19 | int int_data; 20 | int i; 21 | char str_data[3]; 22 | unsigned long str_length; 23 | my_bool is_null; 24 | 25 | mysql = mysql_init(NULL); 26 | if (!(sock = CONN(0))) { 27 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 28 | perror(""); 29 | exit(1); 30 | } 31 | 32 | st = mysql_stmt_init(mysql); 33 | mysql_stmt_prepare(st, SQL, strlen(SQL)); 34 | param_count = mysql_stmt_param_count(st); 35 | 36 | bzero((char*) my_bind, sizeof(MYSQL_BIND)); 37 | my_bind[0].buffer_type= MYSQL_TYPE_STRING; 38 | my_bind[0].buffer= (void *)str[0]; 39 | my_bind[0].buffer_length= sizeof(str[0]); 40 | my_bind[1]= my_bind[0]; 41 | my_bind[1].buffer= (void *)str[1]; 42 | 43 | mysql_stmt_bind_param(st, my_bind); 44 | mysql_stmt_execute(st); 45 | 46 | while (mysql_stmt_fetch(st) != MYSQL_NO_DATA); 47 | } 48 | -------------------------------------------------------------------------------- /test/p7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | void main(int argc, char **argv) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_STMT *st; 12 | int rc; 13 | char *sql; 14 | int nData= 1; 15 | char tData= 1; 16 | short sData= 10; 17 | long bData= 20; 18 | MYSQL_BIND my_bind[1]; 19 | 20 | mysql = mysql_init(NULL); 21 | if (!(sock = CONN(0))) { 22 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 23 | perror(""); 24 | exit(1); 25 | } 26 | 27 | rc= mysql_query(sock, "DROP TABLE IF EXISTS a1"); 28 | 29 | sql= (char *)"CREATE TABLE a1(c1 int)"; 30 | 31 | rc= mysql_query(sock, sql); 32 | 33 | /* insert by prepare - all integers */ 34 | char *query = (char *)"INSERT INTO a1(c1) VALUES(?)"; 35 | st = mysql_stmt_init(mysql); 36 | mysql_stmt_prepare(st, query, strlen(query)); 37 | 38 | /* Always bzero all members of bind parameter */ 39 | bzero((char*) my_bind, sizeof(my_bind)); 40 | 41 | /*tinyint*/ 42 | my_bind[0].buffer_type= MYSQL_TYPE_LONG; 43 | my_bind[0].buffer= (void *)&nData; 44 | 45 | rc= mysql_stmt_bind_param(st, my_bind); 46 | 47 | rc= mysql_stmt_execute(st); 48 | 49 | mysql_stmt_close(st); 50 | 51 | mysql_close(sock); 52 | } 53 | -------------------------------------------------------------------------------- /test/p8_multi_sql.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(CLIENT_MULTI_STATEMENTS))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | char *sql = "select 1;select * from n"; 22 | 23 | mysql_query(sock, sql); 24 | do 25 | { 26 | printf("total affected rows: %lld\n", mysql_affected_rows(sock)); 27 | if (!(result= mysql_store_result(sock))) 28 | { 29 | printf("Got fatal error processing query\n"); 30 | exit(1); 31 | } 32 | row = mysql_fetch_row(result); 33 | printf("%s\n", row[0]); 34 | mysql_free_result(result); 35 | } while (!mysql_next_result(sock)); 36 | 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /test/stmt/a.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | char *c = "abcdefg"; 6 | printf("%3x\n", c); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/stmt/bak_p23.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(0))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | // simple 22 | char sql[100] = {}; 23 | 24 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)"); 25 | 26 | mysql_query(sock, sql); 27 | 28 | mysql_query(sock, "select * from blob_test"); 29 | 30 | result = mysql_store_result(mysql); 31 | mysql_free_result(result); 32 | 33 | #define INSERT_QUERY "INSERT INTO blob_test(a, b) VALUES(?,?)" 34 | 35 | MYSQL_STMT *stmt; 36 | MYSQL_BIND bind[2]; 37 | long length; 38 | int int_data = 10; 39 | char str[100]; 40 | int ret; 41 | 42 | stmt = mysql_stmt_init(mysql); 43 | 44 | mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY)); 45 | 46 | memset(bind, 0, sizeof(bind)); 47 | bind[0].buffer_type= MYSQL_TYPE_LONG; 48 | bind[0].buffer= (char *)&int_data; 49 | bind[0].is_null= 0; 50 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 51 | bind[1].buffer = (char*)&str; 52 | bind[1].is_null= 0; 53 | mysql_stmt_bind_param(stmt, bind); 54 | 55 | ret = mysql_stmt_send_long_data(stmt,1,"MySQL",5); 56 | 57 | ret = mysql_stmt_send_long_data(stmt,1," - The most popular Open Source database",40); 58 | 59 | mysql_stmt_execute(stmt); 60 | 61 | return 0; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /test/stmt/p10_use_db.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | char *sql; 23 | 24 | int i; 25 | 26 | for(i = 0; i < 10000; i++) { 27 | //1 28 | mysql_select_db(sock, "mysql"); 29 | 30 | //2 31 | sql = "use test"; 32 | mysql_query(sock, sql); 33 | 34 | mysql_query(sock, "select * from n"); 35 | 36 | result = mysql_store_result(sock); 37 | 38 | mysql_free_result(result); 39 | 40 | //3 41 | mysql_select_db(sock, "information_schema"); 42 | } 43 | 44 | mysql_close(mysql); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /test/stmt/p12_perf_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | int i; 23 | 24 | char *sql = "select 111111111111111111111111111111111111111111111111111111111111111111111111111"; 25 | 26 | while(1) { 27 | mysql_query(sock, sql); 28 | result = mysql_store_result(sock); 29 | mysql_free_result(result); 30 | } 31 | 32 | mysql_close(mysql); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /test/stmt/p13_com_field_list.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | char *sql; 23 | 24 | int i; 25 | 26 | mysql_list_fields(mysql, "a1", ""); 27 | 28 | sleep(3); 29 | 30 | mysql_close(mysql); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /test/stmt/p14_local_file.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | char *sql; 23 | 24 | int i; 25 | 26 | mysql_list_fields(mysql, "a1", ""); 27 | 28 | sleep(3); 29 | 30 | mysql_close(mysql); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /test/stmt/p15_com_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | 16 | if (!(sock = CONN(0))) { 17 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 18 | perror(""); 19 | exit(1); 20 | } 21 | 22 | char *sql; 23 | 24 | int i; 25 | 26 | /*list dbs*/ 27 | mysql_list_dbs(mysql, ""); 28 | result = mysql_store_result(mysql); 29 | mysql_free_result(result); 30 | 31 | /* COM_FERESH */ 32 | mysql_refresh(mysql, REFRESH_TABLES); 33 | 34 | /* COM_PROCESS_INFO */ 35 | mysql_list_processes(mysql); 36 | result = mysql_store_result(mysql); 37 | mysql_free_result(result); 38 | 39 | /* create db */ 40 | //mysql_create_db(mysql, "new_test"); 41 | 42 | mysql_set_server_option(mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); 43 | 44 | mysql_change_user(mysql, "kkk", "kkk", "test"); 45 | 46 | sleep(3); 47 | mysql_close(mysql); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /test/stmt/p19_null_prepare.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | #define STRING_SIZE 1024 9 | 10 | /* 11 | 12 | MYSQL_TYPE_TIMESTAMP TIMESTAMP field 13 | MYSQL_TYPE_DATE DATE field 14 | MYSQL_TYPE_TIME TIME field 15 | MYSQL_TYPE_DATETIME DATETIME field 16 | 17 | */ 18 | 19 | #define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table" 20 | #define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT, col2 varchar(40))" 21 | #define INSERT_SAMPLE "INSERT INTO test_table(col1,col2) VALUES(?,?)" 22 | 23 | int main (int argc, char *argv[]) { 24 | 25 | MYSQL *mysql; 26 | MYSQL_RES *result; 27 | MYSQL_ROW row; 28 | my_bool reconnect = 0; 29 | mysql = mysql_init(NULL); 30 | mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); 31 | 32 | CONN(0); 33 | 34 | MYSQL_STMT *stmt; 35 | MYSQL_BIND bind[2]; 36 | my_ulonglong affected_rows; 37 | int param_count; 38 | short small_data; 39 | int int_data; 40 | char str_data[STRING_SIZE]; 41 | unsigned long str_length; 42 | my_bool is_null; 43 | 44 | mysql_query(mysql, DROP_SAMPLE_TABLE); 45 | 46 | mysql_query(mysql, CREATE_SAMPLE_TABLE); 47 | 48 | stmt = mysql_stmt_init(mysql); 49 | 50 | char *sql = "select * from test_table"; 51 | 52 | mysql_stmt_prepare(stmt, sql, strlen(sql)); 53 | 54 | mysql_stmt_execute(stmt); // --------------------------2 ok 55 | 56 | while(!mysql_stmt_fetch(stmt)) { // here return resultset 57 | printf("%d - %s\n", int_data, str_data); 58 | } 59 | 60 | mysql_stmt_close(stmt); 61 | } 62 | -------------------------------------------------------------------------------- /test/stmt/p2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | #define INSERT_SQL "insert into player_copy(id, name) values(?, ?)" 9 | 10 | void main(int argc, char **argv) 11 | { 12 | MYSQL *mysql,*sock; 13 | MYSQL_STMT *st; 14 | MYSQL_BIND bind[2]; 15 | 16 | int param_count; 17 | int int_data; 18 | int i; 19 | char str_data[3]; 20 | unsigned long str_length; 21 | my_bool is_null; 22 | 23 | mysql = mysql_init(NULL); 24 | if (!(sock = CONN(0))) { 25 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 26 | perror(""); 27 | exit(1); 28 | } 29 | 30 | mysql_query(sock, "create table player_copy (id int, name varchar(20))"); 31 | 32 | st = mysql_stmt_init(mysql); 33 | mysql_stmt_prepare(st, INSERT_SQL, 47); 34 | param_count = mysql_stmt_param_count(st); 35 | fprintf(stdout, " total parameters in INSERT: %d\n", param_count); 36 | 37 | for (i = 1; i < 1000; i ++) { 38 | int_data = i; 39 | str_data[0] = 'a'; 40 | str_data[1] = 'b'; 41 | str_data[2] = 'c'; 42 | str_length = 3; 43 | is_null = 0; 44 | 45 | bind[0].buffer_type= MYSQL_TYPE_LONG; 46 | bind[0].buffer= &int_data; 47 | bind[0].is_null= &is_null; 48 | 49 | bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; 50 | bind[1].buffer= (char *)str_data; 51 | bind[1].is_null= &is_null; 52 | bind[1].length= &str_length; 53 | 54 | mysql_stmt_bind_param(st, bind); 55 | mysql_stmt_execute(st); 56 | } 57 | 58 | mysql_query(sock, "drop table player_copy"); 59 | } 60 | -------------------------------------------------------------------------------- /test/stmt/p22_blob.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(CLIENT_MULTI_STATEMENTS))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | // simple 22 | char sql[100] = {}; 23 | 24 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)"); 25 | 26 | mysql_query(sock, sql); 27 | 28 | mysql_query(sock, "select * from blob_test"); 29 | 30 | result = mysql_store_result(mysql); 31 | mysql_free_result(result); 32 | 33 | //prepare 34 | 35 | MYSQL_STMT *stmt; 36 | MYSQL_BIND bind[2]; 37 | my_ulonglong affected_rows; 38 | int param_count; 39 | short small_data; 40 | int int_data; 41 | char str_data[1000]; 42 | unsigned long str_length; 43 | my_bool is_null; 44 | 45 | stmt = mysql_stmt_init(mysql); 46 | 47 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (?, ?)"); 48 | mysql_stmt_prepare(stmt, sql, strlen(sql)); 49 | 50 | memset(bind, 0, sizeof(bind)); 51 | 52 | /* INTEGER PARAM */ 53 | /* This is a number type, so there is no need to specify buffer_length */ 54 | bind[0].buffer_type= MYSQL_TYPE_LONG; 55 | bind[0].buffer= (char *)&int_data; 56 | bind[0].is_null= 0; 57 | 58 | /* STRING PARAM */ 59 | my_bool a = 1; 60 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 61 | bind[1].buffer= (char *)str_data; 62 | bind[1].is_null= &a; 63 | bind[1].length= &str_length; //实际大小, bind_ 64 | 65 | mysql_stmt_bind_param(stmt, bind); 66 | 67 | /* Specify the data values for the first row -------------------------------------------------- */ 68 | int_data= 10; /* integer */ 69 | strncpy(str_data, "MySQL", 1000); /* string */ 70 | str_length= strlen(str_data); 71 | 72 | mysql_stmt_execute(stmt); 73 | 74 | mysql_stmt_close(stmt); 75 | 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /test/stmt/p23_stmt_send_long_data.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(0))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | // simple 22 | char sql[100] = {}; 23 | 24 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)"); 25 | 26 | mysql_query(sock, sql); 27 | 28 | mysql_query(sock, "select * from blob_test"); 29 | 30 | result = mysql_store_result(mysql); 31 | mysql_free_result(result); 32 | 33 | #define INSERT_QUERY "INSERT INTO blob_test(a, b) VALUES(?,?)" 34 | 35 | MYSQL_STMT *stmt; 36 | MYSQL_BIND bind[2]; 37 | long length; 38 | int int_data = 10; 39 | char str[100]; 40 | int ret; 41 | 42 | stmt = mysql_stmt_init(mysql); 43 | 44 | mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY)); 45 | 46 | memset(bind, 0, sizeof(bind)); 47 | bind[0].buffer_type= MYSQL_TYPE_LONG; 48 | bind[0].buffer= (char *)&int_data; 49 | bind[0].is_null= 0; 50 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 51 | bind[1].buffer = (char*)&str; 52 | bind[1].is_null= 0; 53 | mysql_stmt_bind_param(stmt, bind); 54 | 55 | ret = mysql_stmt_send_long_data(stmt,1,"MySQL",5); 56 | 57 | ret = mysql_stmt_send_long_data(stmt,1," - The most popular Open Source database",40); 58 | 59 | mysql_stmt_execute(stmt); 60 | 61 | return 0; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /test/stmt/p24_stmt_send_long_data2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(0))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | // simple 22 | char sql[100] = {}; 23 | 24 | sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)"); 25 | 26 | mysql_query(sock, sql); 27 | 28 | mysql_query(sock, "select * from blob_test"); 29 | 30 | result = mysql_store_result(mysql); 31 | mysql_free_result(result); 32 | 33 | #define INSERT_QUERY "INSERT INTO blob_test(a, b) VALUES(?,?)" 34 | 35 | MYSQL_STMT *stmt; 36 | MYSQL_BIND bind[2]; 37 | long length; 38 | int int_data = 10; 39 | char str[100]; 40 | int ret; 41 | 42 | stmt = mysql_stmt_init(mysql); 43 | 44 | mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY)); 45 | 46 | memset(bind, 0, sizeof(bind)); 47 | bind[0].buffer_type= MYSQL_TYPE_LONG; 48 | bind[0].buffer= (char *)&int_data; 49 | bind[0].is_null= 0; 50 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 51 | bind[1].buffer = (char*)&str; 52 | bind[1].is_null= 0; 53 | mysql_stmt_bind_param(stmt, bind); 54 | 55 | ret = mysql_stmt_send_long_data(stmt,1,"fails",5); 56 | 57 | ret = mysql_stmt_send_long_data(stmt,1," - The most popular Open Source database",40); 58 | 59 | mysql_stmt_execute(stmt); 60 | 61 | mysql_stmt_close(stmt); 62 | 63 | stmt = mysql_stmt_init(mysql); 64 | 65 | mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY)); 66 | 67 | size_t s = sizeof(str); 68 | 69 | memset(bind, 0, sizeof(bind)); 70 | bind[0].buffer_type= MYSQL_TYPE_LONG; 71 | bind[0].buffer= (char *)&int_data; 72 | bind[0].is_null= 0; 73 | bind[1].buffer_type= MYSQL_TYPE_BLOB; 74 | bind[1].buffer = (char*)&str; 75 | bind[1].is_null= 0; 76 | bind[1].length= (char*)&s; 77 | mysql_stmt_bind_param(stmt, bind); 78 | 79 | snprintf(str, sizeof(str), "%s", "this success"); 80 | 81 | mysql_stmt_execute(stmt); 82 | 83 | mysql_stmt_close(stmt); 84 | 85 | return 0; 86 | } 87 | 88 | -------------------------------------------------------------------------------- /test/stmt/p28_compress.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | 9 | int main(int argc, char* argv[]) 10 | { 11 | MYSQL *mysql,*sock; 12 | MYSQL_ROW row; 13 | MYSQL_RES *result; 14 | 15 | /* add compress */ 16 | mysql = mysql_init(NULL); 17 | if (!(sock = CONN(CLIENT_COMPRESS))) { 18 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 19 | perror(""); 20 | exit(1); 21 | } 22 | 23 | char *sql = "select 1"; 24 | 25 | mysql_query(sock, sql); 26 | result= mysql_store_result(sock); 27 | row = mysql_fetch_row(result); 28 | 29 | mysql_set_server_option(mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /test/stmt/p3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | #define STRING_SIZE 1024 9 | 10 | #define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table" 11 | #define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT, col2 VARCHAR(40))" 12 | #define INSERT_SAMPLE "INSERT INTO test_table(col1,col2) VALUES(1, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")" 13 | 14 | #define INSERT_SAMPLE2 "INSERT INTO test_table select * from test_table" 15 | 16 | int main (int argc, char *argv[]) { 17 | 18 | MYSQL *mysql; 19 | MYSQL_RES *result; 20 | MYSQL_ROW row; 21 | my_bool reconnect = 0; 22 | mysql = mysql_init(NULL); 23 | mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); 24 | 25 | CONN(0); 26 | 27 | MYSQL_STMT *stmt; 28 | MYSQL_BIND bind[7]; 29 | my_ulonglong affected_rows; 30 | int param_count; 31 | short small_data; 32 | int int_data; 33 | char str_data[STRING_SIZE]; 34 | unsigned long str_length; 35 | my_bool is_null; 36 | 37 | if (mysql_query(mysql, DROP_SAMPLE_TABLE)) 38 | { 39 | fprintf(stderr, " DROP TABLE failed\n"); 40 | fprintf(stderr, " %s\n", mysql_error(mysql)); 41 | exit(0); 42 | } 43 | 44 | if (mysql_query(mysql, CREATE_SAMPLE_TABLE)) 45 | { 46 | fprintf(stderr, " CREATE TABLE failed\n"); 47 | fprintf(stderr, " %s\n", mysql_error(mysql)); 48 | exit(0); 49 | } 50 | 51 | int i = 0; 52 | mysql_query(mysql, INSERT_SAMPLE); 53 | for (; i < 16; i++) { 54 | mysql_query(mysql, INSERT_SAMPLE2); 55 | } 56 | mysql_query(mysql, "select * from test_table"); 57 | 58 | /*last data will miss */ 59 | 60 | } 61 | -------------------------------------------------------------------------------- /test/stmt/p30_explain_error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "c.h" 8 | #define STRING_SIZE 1024 9 | 10 | #define SQL "explain select aaaa" 11 | 12 | int main (int argc, char *argv[]) { 13 | 14 | MYSQL *mysql; 15 | MYSQL_RES *result; 16 | MYSQL_ROW row; 17 | my_bool reconnect = 0; 18 | mysql = mysql_init(NULL); 19 | mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); 20 | 21 | CONN(0); 22 | 23 | MYSQL_STMT *stmt; 24 | MYSQL_BIND bind[7]; 25 | my_ulonglong affected_rows; 26 | int param_count; 27 | short small_data; 28 | int int_data; 29 | char str_data[STRING_SIZE]; 30 | unsigned long str_length; 31 | my_bool is_null; 32 | 33 | int id = mysql_query(mysql, SQL); 34 | 35 | result = mysql_store_result(mysql); 36 | 37 | printf("%d %d\n", id, mysql_errno(mysql)); 38 | 39 | if (result) 40 | while(mysql_fetch_row(result)) { 41 | printf("ok\n"); 42 | } 43 | 44 | mysql_close(mysql); 45 | } 46 | -------------------------------------------------------------------------------- /test/stmt/p4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "c.h" 8 | #define STRING_SIZE 1024 9 | 10 | #define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS test_table" 11 | #define CREATE_SAMPLE_TABLE "CREATE TABLE test_table(col1 INT, col2 VARCHAR(40))" 12 | #define INSERT_SAMPLE "INSERT INTO test_table(col1,col2) VALUES(1, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")" 13 | 14 | #define INSERT_SAMPLE2 "INSERT INTO test_table select * from test_table" 15 | 16 | int main (int argc, char *argv[]) { 17 | 18 | MYSQL *mysql; 19 | MYSQL_RES *result; 20 | MYSQL_ROW row; 21 | my_bool reconnect = 0; 22 | mysql = mysql_init(NULL); 23 | mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); 24 | 25 | CONN(0); 26 | 27 | MYSQL_STMT *stmt; 28 | MYSQL_BIND bind[7]; 29 | my_ulonglong affected_rows; 30 | int param_count; 31 | short small_data; 32 | int int_data; 33 | char str_data[STRING_SIZE]; 34 | unsigned long str_length; 35 | my_bool is_null; 36 | 37 | mysql_query(mysql, "select * from d limit 100000"); 38 | 39 | result = mysql_store_result(mysql); 40 | 41 | while(mysql_fetch_row(result)); 42 | 43 | mysql_close(mysql); 44 | } 45 | -------------------------------------------------------------------------------- /test/stmt/p5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | 9 | #define SQL "select user(), current_user()" 10 | 11 | void main(int argc, char **argv) 12 | { 13 | MYSQL *mysql,*sock; 14 | MYSQL_STMT *st; 15 | char str[2][50]; 16 | MYSQL_BIND my_bind[2]; 17 | 18 | int param_count; 19 | int int_data; 20 | int i; 21 | char str_data[3]; 22 | unsigned long str_length; 23 | my_bool is_null; 24 | 25 | mysql = mysql_init(NULL); 26 | if (!(sock = CONN(0))) { 27 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 28 | perror(""); 29 | exit(1); 30 | } 31 | 32 | st = mysql_stmt_init(mysql); 33 | mysql_stmt_prepare(st, SQL, strlen(SQL)); 34 | param_count = mysql_stmt_param_count(st); 35 | 36 | bzero((char*) my_bind, sizeof(MYSQL_BIND)); 37 | my_bind[0].buffer_type= MYSQL_TYPE_STRING; 38 | my_bind[0].buffer= (void *)str[0]; 39 | my_bind[0].buffer_length= sizeof(str[0]); 40 | my_bind[1]= my_bind[0]; 41 | my_bind[1].buffer= (void *)str[1]; 42 | 43 | mysql_stmt_bind_param(st, my_bind); 44 | mysql_stmt_execute(st); 45 | 46 | while (mysql_stmt_fetch(st) != MYSQL_NO_DATA); 47 | } 48 | -------------------------------------------------------------------------------- /test/stmt/p7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | void main(int argc, char **argv) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_STMT *st; 12 | int rc; 13 | char *sql; 14 | int nData= 1; 15 | char tData= 1; 16 | short sData= 10; 17 | long bData= 20; 18 | MYSQL_BIND my_bind[1]; 19 | 20 | mysql = mysql_init(NULL); 21 | if (!(sock = CONN(0))) { 22 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 23 | perror(""); 24 | exit(1); 25 | } 26 | 27 | rc= mysql_query(sock, "DROP TABLE IF EXISTS a1"); 28 | 29 | sql= (char *)"CREATE TABLE a1(c1 int)"; 30 | 31 | rc= mysql_query(sock, sql); 32 | 33 | /* insert by prepare - all integers */ 34 | char *query = (char *)"INSERT INTO a1(c1) VALUES(?)"; 35 | st = mysql_stmt_init(mysql); 36 | mysql_stmt_prepare(st, query, strlen(query)); 37 | 38 | /* Always bzero all members of bind parameter */ 39 | bzero((char*) my_bind, sizeof(my_bind)); 40 | 41 | /*tinyint*/ 42 | my_bind[0].buffer_type= MYSQL_TYPE_LONG; 43 | my_bind[0].buffer= (void *)&nData; 44 | 45 | rc= mysql_stmt_bind_param(st, my_bind); 46 | 47 | rc= mysql_stmt_execute(st); 48 | 49 | mysql_stmt_close(st); 50 | 51 | mysql_close(sock); 52 | } 53 | -------------------------------------------------------------------------------- /test/stmt/p8_multi_sql.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "c.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | MYSQL *mysql,*sock; 11 | MYSQL_ROW row; 12 | MYSQL_RES *result; 13 | 14 | mysql = mysql_init(NULL); 15 | if (!(sock = CONN(CLIENT_MULTI_STATEMENTS))) { 16 | fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql)); 17 | perror(""); 18 | exit(1); 19 | } 20 | 21 | char *sql = "select 1;select * from n"; 22 | 23 | mysql_query(sock, sql); 24 | do 25 | { 26 | printf("total affected rows: %lld\n", mysql_affected_rows(sock)); 27 | if (!(result= mysql_store_result(sock))) 28 | { 29 | printf("Got fatal error processing query\n"); 30 | exit(1); 31 | } 32 | row = mysql_fetch_row(result); 33 | printf("%s\n", row[0]); 34 | mysql_free_result(result); 35 | } while (!mysql_next_result(sock)); 36 | 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /test/stmt/p96_stmt_null.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "c.h" 8 | #define STRING_SIZE 1024 9 | 10 | /* 11 | MYSQL_TYPE_TIMESTAMP TIMESTAMP field 12 | MYSQL_TYPE_DATE DATE field 13 | MYSQL_TYPE_TIME TIME field 14 | MYSQL_TYPE_DATETIME DATETIME field 15 | */ 16 | 17 | #define DROP_SAMPLE_TABLE "DROP TABLE IF EXISTS SMALL111" 18 | #define CREATE_SAMPLE_TABLE "CREATE TABLE SMALL111(col1 bigint, col2 int, col21 varchar(40), col22 varchar(40), col3 SMALLINT, col4 TIMESTAMP, col5 datetime, col6 date, col7 time)" 19 | #define INSERT_SAMPLE "INSERT INTO SMALL111(col1,col2,col3, col4, col5, col6, col7, col21, col22) VALUES(10,2,1,1,1,1,1,1,1)" 20 | #define INSERT_SAMPLE1 "INSERT INTO SMALL111(col1,col2,col3, col4, col5, col6, col7, col21, col22) VALUES(2,2,1,1,1,1,1,1,1)" 21 | 22 | int main (int argc, char *argv[]) { 23 | 24 | MYSQL *mysql; 25 | MYSQL_RES *result; 26 | MYSQL_ROW row; 27 | my_bool reconnect = 0; 28 | mysql = mysql_init(NULL); 29 | mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); 30 | 31 | //CONN(0); 32 | mysql_real_connect(mysql, "10.250.7.14", "test", "test", "test", 3306, NULL, 0); 33 | 34 | mysql_query(mysql, DROP_SAMPLE_TABLE); 35 | mysql_query(mysql, CREATE_SAMPLE_TABLE); 36 | mysql_query(mysql, INSERT_SAMPLE); 37 | mysql_query(mysql, INSERT_SAMPLE1); 38 | 39 | MYSQL_STMT *stmt; 40 | MYSQL_BIND bind[1]; 41 | MYSQL_BIND bResult[1]; 42 | unsigned long length[1]; 43 | my_ulonglong affected_rows; 44 | int param_count; 45 | short small_data; 46 | //long int_data; 47 | char int_data[100] = "abc"; 48 | char str_data[STRING_SIZE]; 49 | unsigned long str_length; 50 | my_bool is_null[1]; 51 | 52 | is_null[0] = 0; 53 | stmt = mysql_stmt_init(mysql); 54 | if (!stmt) 55 | { 56 | fprintf(stderr, " mysql_stmt_init(), out of memory\n"); 57 | exit(0); 58 | } 59 | 60 | #define SELECT_EXAMPLE "select '111'" 61 | 62 | mysql_query(mysql, SELECT_EXAMPLE); 63 | 64 | result = mysql_store_result(mysql); 65 | while(mysql_fetch_row(result)); 66 | 67 | mysql_stmt_prepare(stmt, SELECT_EXAMPLE, strlen(SELECT_EXAMPLE)); 68 | 69 | mysql_stmt_execute(stmt); 70 | 71 | while(!mysql_stmt_fetch(stmt)) { 72 | printf("aaaa\n"); 73 | } 74 | sleep(3); 75 | } 76 | -------------------------------------------------------------------------------- /user.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "utils.h" 7 | #include "log.h" 8 | #include "adlist.h" 9 | 10 | /* conclude user in list */ 11 | #define USERNAMEMAXLEN 32 12 | #define TOKEN ',' 13 | 14 | int userMatch(void *ptr, void *key) { 15 | char *user = (char*)key; 16 | char *listValue = (char*)ptr; 17 | if (0 == strncmp(user, listValue, USERNAMEMAXLEN)) 18 | return 1; 19 | else 20 | return 0; 21 | } 22 | 23 | /* serperated by comma */ 24 | int initUserList(list *l, char *s) { 25 | ASSERT(l && s && (strlen(s) > 0)); 26 | 27 | l->match = userMatch; 28 | char *p1 = NULL; 29 | char *head = s; 30 | int i = 0; 31 | 32 | while (NULL != (p1 = strchr(head, TOKEN))) { 33 | p1[0] = '\0'; 34 | dump(L_DEBUG, "user:%s", head); 35 | listAddNodeHead(l, head); 36 | head = p1 + 1; 37 | i++; 38 | } 39 | 40 | dump(L_DEBUG, "user:%s", head); 41 | listAddNodeHead(l, head); 42 | i++; 43 | 44 | return i; 45 | } 46 | 47 | #ifdef _USER_TEST_ 48 | 49 | int main(int argc, char *argv[]) { 50 | 51 | list *l = listCreate(); 52 | char u[] = "user1,user2,user3"; 53 | ASSERT(3 == initUserList(l, u)); 54 | 55 | ASSERT(listSearchKey(l, "user1")); 56 | ASSERT(listSearchKey(l, "user2")); 57 | ASSERT(listSearchKey(l, "user3")); 58 | ASSERT(NULL == listSearchKey(l, "user4")); 59 | 60 | /* wrong 61 | ASSERT(NULL == listSearchKey(l, "user1")); 62 | */ 63 | 64 | return OK; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /user.h: -------------------------------------------------------------------------------- 1 | 2 | int initUserList(list *l, char *s); 3 | -------------------------------------------------------------------------------- /utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTILS_H_ 2 | #define _UTILS_H_ 3 | 4 | #ifdef DEBUG 5 | #define ASSERT(f) do {if(f) ((void)0); else _Assert(#f, __FILE__, __LINE__);} while(0) 6 | #else 7 | #define ASSERT(f) ((void)0) 8 | #endif 9 | 10 | void _Assert(char*, char*, unsigned); 11 | int daemon_init(void) ; 12 | 13 | int single_process(char *process_name); 14 | 15 | void sig_init(void); 16 | 17 | void select_sleep(unsigned int); 18 | 19 | #define OK (0) 20 | #define ERR (-1) 21 | #define BAD (-2) 22 | #define PEND (1) 23 | 24 | typedef unsigned short uint16; 25 | typedef unsigned int uint; 26 | typedef unsigned int uint32; 27 | typedef unsigned char uchar; 28 | typedef unsigned long ulong; 29 | 30 | #endif 31 | --------------------------------------------------------------------------------