#include <pcap.h>
#include <pcap-int.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "pcap-remote.h"
#include "daemon.h"
#include "sockutils.h"
Go to the source code of this file.
Functions | |
int | daemon_checkauth (SOCKET sockctrl, int nullAuthAllowed, char *errbuf) |
It checks if the authentication credentials supplied by the user are valid. | |
int | daemon_AuthUserPwd (char *username, char *password, char *errbuf) |
int | daemon_findalldevs (SOCKET sockctrl, char *errbuf) |
int | daemon_opensource (SOCKET sockctrl, char *source, int srclen, uint32 plen, char *errbuf) |
pcap_t * | daemon_startcapture (SOCKET sockctrl, pthread_t *threaddata, char *source, int active, struct rpcap_sampling *samp_param, uint32 plen, char *errbuf) |
int | daemon_endcapture (pcap_t *fp, pthread_t *threaddata, char *errbuf) |
int | daemon_updatefilter (pcap_t *fp, uint32 plen) |
int | daemon_unpackapplyfilter (pcap_t *fp, unsigned int *nread, int *plen, char *errbuf) |
int | daemon_getstats (pcap_t *fp) |
int | daemon_getstatsnopcap (SOCKET sockctrl, unsigned int ifdrops, unsigned int ifrecv, unsigned int krnldrop, unsigned int svrcapt, char *errbuf) |
int | daemon_setsampling (SOCKET sockctrl, struct rpcap_sampling *samp_param, int plen, char *errbuf) |
Received the sampling parameters from remote host and it stores in the pcap_t structure. | |
void | daemon_seraddr (struct sockaddr_storage *sockaddrin, struct sockaddr_storage *sockaddrout) |
It serializes a network address. | |
void | daemon_thrdatamain (void *ptr) |
void | daemon_serviceloop (void *ptr) |
Main serving funtion This function is the one which does the job. It is the main() of the child thread, which is created as soon as a new connection is accepted. | |
void | pthread_suspend (int msec) |
Suspends a pthread for msec milliseconds. | |
Variables | |
char | fakeerrbuf [PCAP_ERRBUF_SIZE+1] |
|
Definition at line 626 of file daemon.c. References pcap_strerror(), and snprintf. Referenced by daemon_checkauth(). |
|
It checks if the authentication credentials supplied by the user are valid. This function is called each time the rpcap daemon starts a new serving thread. It reads the authentication message from the network and it checks that the user information are valid.
Definition at line 471 of file daemon.c. References daemon_AuthUserPwd(), nullAuthAllowed, pcap_strerror(), rpcap_checkmsg(), rpcap_createhdr(), RPCAP_MSG_AUTH_REQ, RPCAP_MSG_CLOSE, RPCAP_MSG_ERROR, RPCAP_RMTAUTH_NULL, RPCAP_RMTAUTH_PWD, snprintf, SOCK_ASSERT, sock_discard(), sock_recv(), and sock_send(). Referenced by daemon_serviceloop(). |
|
Definition at line 1166 of file daemon.c. References pcap_close(), rpcap_createhdr(), sock_close(), sock_send(), and SOCKET. Referenced by daemon_serviceloop(). |
|
Definition at line 729 of file daemon.c. References address, pcap_if::addresses, daemon_seraddr(), rpcap_findalldevs_if::desclen, pcap_if::description, pcap_if::flags, rpcap_findalldevs_if::flags, rpcap_findalldevs_if::naddr, pcap_if::name, rpcap_findalldevs_if::namelen, pcap_if::next, pcap_findalldevs(), pcap_freealldevs(), rpcap_createhdr(), RPCAP_NETBUF_SIZE, rpcap_senderror(), sock_bufferize(), sock_send(), and uint16. Referenced by daemon_serviceloop(). |
|
Definition at line 1349 of file daemon.c. References rpcap_stats::ifdrop, rpcap_stats::ifrecv, rpcap_stats::krnldrop, pcap_stats(), pcap_stat::ps_drop, pcap_stat::ps_ifdrop, pcap_stat::ps_recv, rpcap_createhdr(), RPCAP_NETBUF_SIZE, rpcap_senderror(), sock_bufferize(), sock_send(), and rpcap_stats::svrcapt. Referenced by daemon_serviceloop(). |
|
Definition at line 1390 of file daemon.c. References rpcap_stats::ifdrop, rpcap_stats::ifrecv, rpcap_stats::krnldrop, rpcap_createhdr(), RPCAP_NETBUF_SIZE, rpcap_senderror(), sock_bufferize(), sock_send(), and rpcap_stats::svrcapt. Referenced by daemon_serviceloop(). |
|
Definition at line 865 of file daemon.c. References rpcap_openreply::linktype, pcap_close(), pcap_open(), pcap_t, rpcap_createhdr(), RPCAP_NETBUF_SIZE, rpcap_senderror(), sock_bufferize(), sock_discard(), sock_recv(), sock_send(), and rpcap_openreply::tzoff. Referenced by daemon_serviceloop(). |
|
It serializes a network address. It accepts a 'sockaddr_storage' structure as input, and it converts it appropriately into a format that can be used to be sent on the network. Basically, it applies all the hton() conversion required to the input variable.
Definition at line 1558 of file daemon.c. Referenced by daemon_findalldevs(). |
|
|
Received the sampling parameters from remote host and it stores in the pcap_t structure.
Definition at line 1310 of file daemon.c. References rpcap_sampling::method, rpcap_createhdr(), rpcap_senderror(), sock_discard(), sock_recv(), sock_send(), and rpcap_sampling::value. Referenced by daemon_serviceloop(). |
|
Definition at line 950 of file daemon.c. References rpcap_startcapreply::bufsize, daemon_unpackapplyfilter(), rpcap_sampling::method, PCAP_BUF_SIZE, pcap_close(), pcap_open(), pcap_t, rpcap_startcapreply::portdata, rpcap_createhdr(), RPCAP_NETBUF_SIZE, rpcap_senderror(), RPCAP_STARTCAPREQ_FLAG_DGRAM, RPCAP_STARTCAPREQ_FLAG_SERVEROPEN, snprintf, sock_bufferize(), sock_close(), sock_discard(), sock_geterror(), sock_initaddress(), sock_open(), sock_recv(), sock_send(), SOCKET, and rpcap_sampling::value. Referenced by daemon_serviceloop(). |
|
Definition at line 1428 of file daemon.c. References rpcap_pkthdr::caplen, pcap_pkthdr::caplen, errbuf, pcap_pkthdr::len, rpcap_pkthdr::len, rpcap_pkthdr::npkt, PCAP_ERRBUF_SIZE, pcap_geterr(), pcap_next_ex(), PCAP_SAMP_1_EVERY_N, PCAP_SAMP_FIRST_AFTER_N_MS, pcap_t, rpcap_createhdr(), RPCAP_NETBUF_SIZE, rpcap_senderror(), snprintf, SOCK_ASSERT, sock_bufferize(), sock_send(), rpcap_pkthdr::timestamp_sec, rpcap_pkthdr::timestamp_usec, and pcap_pkthdr::ts. |
|
Definition at line 1197 of file daemon.c. References bpf_program::bf_len, bpf_validate(), bpf_insn::code, bpf_insn::jf, bpf_insn::jt, bpf_insn::k, pcap_compile(), pcap_setfilter(), pcap_strerror(), RPCAP_UPDATEFILTER_BPF, snprintf, and sock_recv(). Referenced by daemon_startcapture(), and daemon_updatefilter(). |
|
Definition at line 1269 of file daemon.c. References daemon_unpackapplyfilter(), rpcap_createhdr(), rpcap_senderror(), sock_discard(), and sock_send(). Referenced by daemon_serviceloop(). |
|
Suspends a pthread for msec milliseconds. This function is provided since pthreads do not have a suspend() call. Definition at line 1597 of file daemon.c. Referenced by daemon_serviceloop(), main_active(), and main_startup(). |
|
|
documentation. Copyright (c) 2002-2003 Politecnico di Torino. All rights reserved.