003 File Manager
Current Path:
/usr/src/contrib/libpcap
usr
/
src
/
contrib
/
libpcap
/
📁
..
📄
CHANGES
(41.04 KB)
📄
CMakeLists.txt
(84.97 KB)
📄
CONTRIBUTING.md
(1.41 KB)
📄
CREDITS
(11.47 KB)
📁
ChmodBPF
📄
INSTALL.md
(15.44 KB)
📄
LICENSE
(868 B)
📄
Makefile-devel-adds
(614 B)
📄
Makefile.in
(23.68 KB)
📄
README.md
(3.71 KB)
📄
TODO
(1.51 KB)
📄
VERSION
(6 B)
📁
Win32
📄
aclocal.m4
(30.92 KB)
📄
arcnet.h
(2.39 KB)
📄
atmuni31.h
(3.87 KB)
📄
bpf_dump.c
(1.9 KB)
📄
bpf_filter.c
(12.22 KB)
📄
bpf_image.c
(7.38 KB)
📄
chmod_bpf
(757 B)
📁
cmake
📄
cmake_uninstall.cmake.in
(1.01 KB)
📄
cmakeconfig.h.in
(11.15 KB)
📄
config.guess
(43.17 KB)
📄
config.h.in
(10.25 KB)
📄
config.sub
(34.93 KB)
📄
configure
(331.21 KB)
📄
configure.ac
(64.36 KB)
📄
diag-control.h
(8.3 KB)
📄
dlpisubs.c
(9.41 KB)
📄
dlpisubs.h
(702 B)
📁
doc
📄
etherent.c
(3.43 KB)
📄
ethertype.h
(3.47 KB)
📄
extract.h
(9.23 KB)
📄
fad-getad.c
(8.62 KB)
📄
fad-gifc.c
(12.84 KB)
📄
fad-glifc.c
(9.37 KB)
📄
fmtutils.c
(6.35 KB)
📄
fmtutils.h
(2.19 KB)
📄
ftmacros.h
(4.22 KB)
📄
gencode.c
(257 KB)
📄
gencode.h
(11.44 KB)
📄
grammar.y
(24.66 KB)
📄
ieee80211.h
(5.25 KB)
📄
install-sh
(5.45 KB)
📁
lbl
📄
libpcap.pc.in
(484 B)
📄
llc.h
(2.56 KB)
📁
missing
📄
mkdep
(2.43 KB)
📁
msdos
📄
nametoaddr.c
(18.83 KB)
📄
nametoaddr.h
(2.12 KB)
📄
nlpid.h
(1.66 KB)
📄
nomkdep
(135 B)
📄
optimize.c
(62.27 KB)
📄
optimize.h
(1.29 KB)
📄
org.tcpdump.chmod_bpf.plist
(441 B)
📁
pcap
📄
pcap-bpf.c
(84.02 KB)
📄
pcap-bpf.h
(2.24 KB)
📄
pcap-bt-linux.c
(11.42 KB)
📄
pcap-bt-linux.h
(1.76 KB)
📄
pcap-bt-monitor-linux.c
(7.84 KB)
📄
pcap-bt-monitor-linux.h
(1.64 KB)
📄
pcap-common.c
(47.14 KB)
📄
pcap-common.h
(2.29 KB)
📄
pcap-config.1
(2.27 KB)
📄
pcap-config.in
(1.8 KB)
📄
pcap-dag.c
(37.15 KB)
📄
pcap-dag.h
(457 B)
📄
pcap-dbus.c
(10.03 KB)
📄
pcap-dbus.h
(112 B)
📄
pcap-dll.rc
(1.03 KB)
📄
pcap-dlpi.c
(47.56 KB)
📄
pcap-dos.c
(35.9 KB)
📄
pcap-dos.h
(6.7 KB)
📄
pcap-enet.c
(4.74 KB)
📄
pcap-filter.manmisc.in
(33.54 KB)
📄
pcap-int.h
(16.94 KB)
📄
pcap-libdlpi.c
(12.11 KB)
📄
pcap-linktype.manmisc.in
(2.33 KB)
📄
pcap-linux.c
(207.89 KB)
📄
pcap-namedb.h
(1.98 KB)
📄
pcap-netfilter-linux.c
(20.48 KB)
📄
pcap-netfilter-linux.h
(1.67 KB)
📄
pcap-netmap.c
(7.82 KB)
📄
pcap-netmap.h
(126 B)
📄
pcap-new.c
(12.79 KB)
📄
pcap-nit.c
(10.2 KB)
📄
pcap-npf.c
(51.61 KB)
📄
pcap-null.c
(1.9 KB)
📄
pcap-pf.c
(18.48 KB)
📄
pcap-rdmasniff.c
(10.98 KB)
📄
pcap-rdmasniff.h
(140 B)
📄
pcap-rpcap-int.h
(3.43 KB)
📄
pcap-rpcap.c
(96.91 KB)
📄
pcap-rpcap.h
(2.19 KB)
📄
pcap-savefile.manfile.in
(5.11 KB)
📄
pcap-septel.c
(8.69 KB)
📄
pcap-septel.h
(512 B)
📄
pcap-sita.c
(36.34 KB)
📄
pcap-sita.h
(224 B)
📄
pcap-sita.html
(37.43 KB)
📄
pcap-snf.c
(14.75 KB)
📄
pcap-snf.h
(110 B)
📄
pcap-snit.c
(12.67 KB)
📄
pcap-snoop.c
(13.26 KB)
📄
pcap-tc.c
(34.21 KB)
📄
pcap-tc.h
(1.9 KB)
📄
pcap-tstamp.manmisc.in
(7.7 KB)
📄
pcap-types.h
(1.93 KB)
📄
pcap-usb-linux.c
(35.89 KB)
📄
pcap-usb-linux.h
(1.75 KB)
📄
pcap.3pcap.in
(29.62 KB)
📄
pcap.c
(103.69 KB)
📄
pcap.h
(2.17 KB)
📄
pcap_activate.3pcap
(3.8 KB)
📄
pcap_breakloop.3pcap
(3.98 KB)
📄
pcap_can_set_rfmon.3pcap
(2.63 KB)
📄
pcap_close.3pcap
(1.47 KB)
📄
pcap_compile.3pcap.in
(3.02 KB)
📄
pcap_create.3pcap
(2.19 KB)
📄
pcap_datalink.3pcap.in
(2.39 KB)
📄
pcap_datalink_name_to_val.3pcap
(1.82 KB)
📄
pcap_datalink_val_to_name.3pcap
(2.47 KB)
📄
pcap_dump.3pcap
(1.73 KB)
📄
pcap_dump_close.3pcap
(1.49 KB)
📄
pcap_dump_file.3pcap
(1.54 KB)
📄
pcap_dump_flush.3pcap
(1.69 KB)
📄
pcap_dump_ftell.3pcap
(2.11 KB)
📄
pcap_dump_open.3pcap.in
(3.31 KB)
📄
pcap_file.3pcap
(2.06 KB)
📄
pcap_fileno.3pcap
(2 KB)
📄
pcap_findalldevs.3pcap
(6.25 KB)
📄
pcap_freecode.3pcap
(1.67 KB)
📄
pcap_get_required_select_timeout.3pcap
(3.04 KB)
📄
pcap_get_selectable_fd.3pcap
(4.66 KB)
📄
pcap_get_tstamp_precision.3pcap.in
(1.83 KB)
📄
pcap_geterr.3pcap
(1.84 KB)
📄
pcap_inject.3pcap
(3.34 KB)
📄
pcap_is_swapped.3pcap
(1.91 KB)
📄
pcap_lib_version.3pcap
(1.6 KB)
📄
pcap_list_datalinks.3pcap.in
(2.54 KB)
📄
pcap_list_tstamp_types.3pcap.in
(2.98 KB)
📄
pcap_lookupdev.3pcap
(2.47 KB)
📄
pcap_lookupnet.3pcap
(1.95 KB)
📄
pcap_loop.3pcap
(6.58 KB)
📄
pcap_major_version.3pcap
(1.96 KB)
📄
pcap_next_ex.3pcap
(4.86 KB)
📄
pcap_offline_filter.3pcap
(1.95 KB)
📄
pcap_open_dead.3pcap.in
(2.65 KB)
📄
pcap_open_live.3pcap
(2.65 KB)
📄
pcap_open_offline.3pcap.in
(3.8 KB)
📄
pcap_set_buffer_size.3pcap
(1.79 KB)
📄
pcap_set_datalink.3pcap
(1.84 KB)
📄
pcap_set_immediate_mode.3pcap.in
(3.27 KB)
📄
pcap_set_promisc.3pcap
(1.82 KB)
📄
pcap_set_protocol_linux.3pcap
(2.81 KB)
📄
pcap_set_rfmon.3pcap
(1.82 KB)
📄
pcap_set_snaplen.3pcap
(1.74 KB)
📄
pcap_set_timeout.3pcap
(2.15 KB)
📄
pcap_set_tstamp_precision.3pcap.in
(2.38 KB)
📄
pcap_set_tstamp_type.3pcap.in
(2.73 KB)
📄
pcap_setdirection.3pcap
(2.36 KB)
📄
pcap_setfilter.3pcap
(1.79 KB)
📄
pcap_setnonblock.3pcap
(2.82 KB)
📄
pcap_snapshot.3pcap
(1.91 KB)
📄
pcap_stats.3pcap
(3.35 KB)
📄
pcap_statustostr.3pcap
(1.55 KB)
📄
pcap_strerror.3pcap
(1.54 KB)
📄
pcap_tstamp_type_name_to_val.3pcap
(1.87 KB)
📄
pcap_tstamp_type_val_to_name.3pcap
(1.99 KB)
📄
portability.h
(5.46 KB)
📄
ppp.h
(2.62 KB)
📄
rpcap-protocol.c
(6.67 KB)
📄
rpcap-protocol.h
(18.61 KB)
📁
rpcapd
📄
savefile.c
(13.72 KB)
📄
scanner.l
(14.36 KB)
📄
sf-pcap.c
(30.33 KB)
📄
sf-pcap.h
(1.69 KB)
📄
sf-pcapng.c
(38.9 KB)
📄
sf-pcapng.h
(1.41 KB)
📄
sockutils.c
(52.26 KB)
📄
sockutils.h
(5.22 KB)
📄
sunatmpos.h
(2.09 KB)
📁
testprogs
📁
tests
📄
varattrs.h
(2.38 KB)
Editing: pcap-septel.c
/* * pcap-septel.c: Packet capture interface for Intel/Septel card. * * Authors: Gilbert HOYEK (gil_hoyek@hotmail.com), Elias M. KHOURY * (+961 3 485243) */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <sys/param.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include "pcap-int.h" #include <ctype.h> #include <netinet/in.h> #include <sys/mman.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <msg.h> #include <ss7_inc.h> #include <sysgct.h> #include <pack.h> #include <system.h> #include "pcap-septel.h" static int septel_setfilter(pcap_t *p, struct bpf_program *fp); static int septel_stats(pcap_t *p, struct pcap_stat *ps); static int septel_getnonblock(pcap_t *p); static int septel_setnonblock(pcap_t *p, int nonblock); /* * Private data for capturing on Septel devices. */ struct pcap_septel { struct pcap_stat stat; } /* * Read at most max_packets from the capture queue and call the callback * for each of them. Returns the number of packets handled, -1 if an * error occured, or -2 if we were told to break out of the loop. */ static int septel_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { struct pcap_septel *ps = p->priv; HDR *h; MSG *m; int processed = 0 ; int t = 0 ; /* identifier for the message queue of the module(upe) from which we are capturing * packets.These IDs are defined in system.txt . By default it is set to 0x2d * so change it to 0xdd for technical reason and therefore the module id for upe becomes: * LOCAL 0xdd * upe - Example user part task */ unsigned int id = 0xdd; /* process the packets */ do { unsigned short packet_len = 0; int caplen = 0; int counter = 0; struct pcap_pkthdr pcap_header; u_char *dp ; /* * Has "pcap_breakloop()" been called? */ loop: if (p->break_loop) { /* * Yes - clear the flag that indicates that * it has, and return -2 to indicate that * we were told to break out of the loop. */ p->break_loop = 0; return -2; } /*repeat until a packet is read *a NULL message means : * when no packet is in queue or all packets in queue already read */ do { /* receive packet in non-blocking mode * GCT_grab is defined in the septel library software */ h = GCT_grab(id); m = (MSG*)h; /* a couter is added here to avoid an infinite loop * that will cause our capture program GUI to freeze while waiting * for a packet*/ counter++ ; } while ((m == NULL)&& (counter< 100)) ; if (m != NULL) { t = h->type ; /* catch only messages with type = 0xcf00 or 0x8f01 corrsponding to ss7 messages*/ /* XXX = why not use API_MSG_TX_REQ for 0xcf00 and API_MSG_RX_IND * for 0x8f01? */ if ((t != 0xcf00) && (t != 0x8f01)) { relm(h); goto loop ; } /* XXX - is API_MSG_RX_IND for an MTP2 or MTP3 message? */ dp = get_param(m);/* get pointer to MSG parameter area (m->param) */ packet_len = m->len; caplen = p->snapshot ; if (caplen > packet_len) { caplen = packet_len; } /* Run the packet filter if there is one. */ if ((p->fcode.bf_insns == NULL) || bpf_filter(p->fcode.bf_insns, dp, packet_len, caplen)) { /* get a time stamp , consisting of : * * pcap_header.ts.tv_sec: * ---------------------- * a UNIX format time-in-seconds when he packet was captured, * i.e. the number of seconds since Epoch time (January 1,1970, 00:00:00 GMT) * * pcap_header.ts.tv_usec : * ------------------------ * the number of microseconds since that second * when the packet was captured */ (void)gettimeofday(&pcap_header.ts, NULL); /* Fill in our own header data */ pcap_header.caplen = caplen; pcap_header.len = packet_len; /* Count the packet. */ ps->stat.ps_recv++; /* Call the user supplied callback function */ callback(user, &pcap_header, dp); processed++ ; } /* after being processed the packet must be *released in order to receive another one */ relm(h); }else processed++; } while (processed < cnt) ; return processed ; } static int septel_inject(pcap_t *handle, const void *buf _U_, size_t size _U_) { pcap_strlcpy(handle->errbuf, "Sending packets isn't supported on Septel cards", PCAP_ERRBUF_SIZE); return (-1); } /* * Activate a handle for a live capture from the given Septel device. Always pass a NULL device * The promisc flag is ignored because Septel cards have built-in tracing. * The timeout is also ignored as it is not supported in hardware. * * See also pcap(3). */ static pcap_t *septel_activate(pcap_t* handle) { /* Initialize some components of the pcap structure. */ handle->linktype = DLT_MTP2; /* * Turn a negative snapshot value (invalid), a snapshot value of * 0 (unspecified), or a value bigger than the normal maximum * value, into the maximum allowed value. * * If some application really *needs* a bigger snapshot * length, we should just increase MAXIMUM_SNAPLEN. */ if (handle->snapshot <= 0 || handle->snapshot > MAXIMUM_SNAPLEN) handle->snapshot = MAXIMUM_SNAPLEN; handle->bufsize = 0; /* * "select()" and "poll()" don't work on Septel queues */ handle->selectable_fd = -1; handle->read_op = septel_read; handle->inject_op = septel_inject; handle->setfilter_op = septel_setfilter; handle->set_datalink_op = NULL; /* can't change data link type */ handle->getnonblock_op = septel_getnonblock; handle->setnonblock_op = septel_setnonblock; handle->stats_op = septel_stats; return 0; } pcap_t *septel_create(const char *device, char *ebuf, int *is_ours) { const char *cp; pcap_t *p; /* Does this look like the Septel device? */ cp = strrchr(device, '/'); if (cp == NULL) cp = device; if (strcmp(cp, "septel") != 0) { /* Nope, it's not "septel" */ *is_ours = 0; return NULL; } /* OK, it's probably ours. */ *is_ours = 1; p = pcap_create_common(ebuf, sizeof (struct pcap_septel)); if (p == NULL) return NULL; p->activate_op = septel_activate; /* * Set these up front, so that, even if our client tries * to set non-blocking mode before we're activated, or * query the state of non-blocking mode, they get an error, * rather than having the non-blocking mode option set * for use later. */ p->getnonblock_op = septel_getnonblock; p->setnonblock_op = septel_setnonblock; return p; } static int septel_stats(pcap_t *p, struct pcap_stat *ps) { struct pcap_septel *handlep = p->priv; /*handlep->stat.ps_recv = 0;*/ /*handlep->stat.ps_drop = 0;*/ *ps = handlep->stat; return 0; } int septel_findalldevs(pcap_if_list_t *devlistp, char *errbuf) { /* * XXX - do the notions of "up", "running", or "connected" apply here? */ if (add_dev(devlistp,"septel",0,"Intel/Septel device",errbuf) == NULL) return -1; return 0; } /* * Installs the given bpf filter program in the given pcap structure. There is * no attempt to store the filter in kernel memory as that is not supported * with Septel cards. */ static int septel_setfilter(pcap_t *p, struct bpf_program *fp) { if (!p) return -1; if (!fp) { strncpy(p->errbuf, "setfilter: No filter specified", sizeof(p->errbuf)); return -1; } /* Make our private copy of the filter */ if (install_bpf_program(p, fp) < 0) return -1; return (0); } /* * We don't support non-blocking mode. I'm not sure what we'd * do to support it and, given that we don't support select()/ * poll()/epoll_wait()/kevent() etc., it probably doesn't * matter. */ static int septel_getnonblock(pcap_t *p) { fprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Non-blocking mode not supported on Septel devices"); return (-1); } static int septel_setnonblock(pcap_t *p, int nonblock _U_) { fprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Non-blocking mode not supported on Septel devices"); return (-1); } #ifdef SEPTEL_ONLY /* * This libpcap build supports only Septel cards, not regular network * interfaces. */ /* * There are no regular interfaces, just Septel interfaces. */ int pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf) { return (0); } /* * Attempts to open a regular interface fail. */ pcap_t * pcap_create_interface(const char *device, char *errbuf) { pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "This version of libpcap only supports Septel cards"); return (NULL); } /* * Libpcap version string. */ const char * pcap_lib_version(void) { return (PCAP_VERSION_STRING " (Septel-only)"); } #endif
Upload File
Create Folder