Main Page Modules Data Structures File List Data Fields Globals Related Pages

# rpcapd.c File Reference

`#include <errno.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <pcap.h>`
`#include <signal.h>`
`#include <pthread.h>`
`#include "rpcapd.h"`
`#include "fileconf.h"`
`#include "pcap-remote.h"`
`#include "daemon.h"`
`#include "utils.h"`
`#include "sockutils.h"`
`#include "win32-svc.h"`

Go to the source code of this file.

## Functions
void | main_passive (void *ptr)
| 'true' main of the program.
void | main_active (void *ptr)
| 'true' main of the program in case the active mode is turned on.
void | printusage ()
| Prints the usage screen if it is launched in console mode.
int | main (int argc, char *argv[], char *envp[])
| Program main.
void | main_startup (void)
void | main_cleanup (int sign)
## Variables
char | hostlist [MAX_HOST_LIST+1]
| Keeps the list of the hosts that are allowed to connect to this server.
active_pars | activelist [MAX_ACTIVE_LIST]
| Keeps the list of the hosts (host, port) on which I want to connect to (active mode).
int | nullAuthAllowed
| '1' if we permit NULL authentication, '0' otherwise
SOCKET | sockmain
| keeps the main socket identifier
char | loadfile [MAX_LINE+1]
| Name of the file from which we have to load the configuration.
int | passivemode = 1
| '1' if we want to run in passive mode as well
addrinfo | mainhints
| temporary struct to keep settings needed to open the new socket
char | address [MAX_LINE+1]
| keeps the network address (either numeric or literal) to bind to
char | port [MAX_LINE+1]
| keeps the network port to bind to
char * | optarg

## Function Documentation

int main | ( | int | argc,
|  | char * | argv[],
|  | char * | envp[]
| ) |

| Program main. Definition at line 119 of file rpcapd.c. References errbuf, fileconf_read(), fileconf_save(), getopt(), hostlist, loadfile, main_startup(), mainhints, MAX_ACTIVE_LIST, MAX_LINE, nullAuthAllowed, passivemode, PCAP_ERRBUF_SIZE, printusage(), snprintf, SOCK_ASSERT, sock_init(), and svc_start().

void main_active | ( | void * | ptr | ) |

  | 'true' main of the program in case the active mode is turned on. It does not have any return value nor parameters. This function loops forever trying to connect to the remote host, until the daemon is turned down. Parameters:
  ptr: | it keeps the 'activepars' parameters. It is a 'void *' just because pthreads want this format.
Definition at line 634 of file rpcapd.c. References daemon_slpars::activeclose, daemon_serviceloop(), errbuf, daemon_slpars::isactive, nullAuthAllowed, daemon_slpars::nullAuthAllowed, PCAP_ERRBUF_SIZE, pcap_strerror(), pthread_suspend(), snprintf, SOCK_ASSERT, sock_initaddress(), sock_open(), daemon_slpars::sockctrl, and SOCKET. Referenced by main_startup().

void main_cleanup | ( | int | sign | ) |

| Definition at line 432 of file rpcapd.c. References SOCK_ASSERT, and sock_cleanup().

void main_passive | ( | void * | ptr | ) |

  | 'true' main of the program. It must be in a separate function because: if we're in 'console' mode, we have to put the main thread waiting for a Ctrl+C (in order to be able to stop everything) if we're in daemon mode, the main program must terminate and a new child must be created in order to create the daemon Parameters:
  ptr: | it keeps the main socket handler (what's called 'sockmain' in the main() ), that represents the socket used in the main connection. It is a 'void *' just because pthreads want this format.
Definition at line 505 of file rpcapd.c. References daemon_slpars::activeclose, daemon_serviceloop(), errbuf, daemon_slpars::isactive, nullAuthAllowed, daemon_slpars::nullAuthAllowed, PCAP_ERRBUF_SIZE, pcap_strerror(), rpcap_senderror(), snprintf, SOCK_ASSERT, sock_check_hostlist(), sock_close(), sock_geterror(), daemon_slpars::sockctrl, SOCKET, and sockmain. Referenced by main_startup().

void main_startup | ( | void |  | ) |

| Definition at line 302 of file rpcapd.c. References activelist, active_pars::address, active_pars::ai_family, errbuf, main_active(), main_passive(), mainhints, MAX_ACTIVE_LIST, PCAP_ERRBUF_SIZE, pthread_suspend(), SOCK_ASSERT, sock_initaddress(), sock_open(), and sockmain. Referenced by main(), and svc_main().

void printusage | ( |  | ) |

| Prints the usage screen if it is launched in console mode. Definition at line 86 of file rpcapd.c. References PROGRAM_NAME, and RPCAP_DEFAULT_NETPORT. Referenced by main().

## Variable Documentation

struct active_pars activelist[MAX_ACTIVE_LIST]

| Keeps the list of the hosts (host, port) on which I want to connect to (active mode). Definition at line 60 of file rpcapd.c. Referenced by fileconf_read(), fileconf_save(), and main_startup().

char address[MAX_LINE + 1]

| keeps the network address (either numeric or literal) to bind to Definition at line 66 of file rpcapd.c. Referenced by daemon_findalldevs(), fileconf_read(), and sock_getascii_addrport().

char hostlist[MAX_HOST_LIST + 1]

| Keeps the list of the hosts that are allowed to connect to this server. Definition at line 59 of file rpcapd.c. Referenced by fileconf_read(), main(), pcap_remoteact_list(), and sock_check_hostlist().

char loadfile[MAX_LINE + 1]

| Name of the file from which we have to load the configuration. Definition at line 63 of file rpcapd.c. Referenced by main().

struct addrinfo mainhints

| temporary struct to keep settings needed to open the new socket Definition at line 65 of file rpcapd.c. Referenced by main(), and main_startup().

int nullAuthAllowed

| '1' if we permit NULL authentication, '0' otherwise Definition at line 61 of file rpcapd.c. Referenced by daemon_checkauth(), fileconf_read(), main(), main_active(), and main_passive().

char* optarg

| Definition at line 69 of file rpcapd.c.

int passivemode = 1

| '1' if we want to run in passive mode as well Definition at line 64 of file rpcapd.c. Referenced by main().

char port[MAX_LINE + 1]

| keeps the network port to bind to Definition at line 67 of file rpcapd.c. Referenced by fileconf_read(), pcap_findalldevs_ex(), pcap_open(), pcap_open_live(), pcap_parsesrcstr(), pcap_remoteact_accept(), and sock_getascii_addrport().

SOCKET sockmain

| keeps the main socket identifier Definition at line 62 of file rpcapd.c.

documentation. Copyright (c) 2002-2003 Politecnico di Torino. All rights reserved.