Dillo v3.1.1-98-g318d1f14
|
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/un.h>
#include <signal.h>
#include <netinet/in.h>
#include "d_size.h"
Go to the source code of this file.
Classes | |
struct | dp |
struct | service |
Macros | |
#define | IPPORT_USERRESERVED 5000 |
#define | PATH_LEN 50 |
#define | CMDLEN 20 |
#define | MSGLEN 50 |
#define | DPID_BASE_PORT (IPPORT_USERRESERVED + 20) |
#define | SRS_NAME "dpid.srs" |
Functions | |
void | rm_dpi_sockets (struct dp *dpi_attr_list, int numdpis) |
void | cleanup (void) |
void | free_dpi_attr (struct dp *dpi_attr) |
void | free_plugin_list (struct dp **dpi_attr_list_ptr, int numdpis) |
void | free_services_list (Dlist *s_list) |
enum file_type | get_file_type (char *file_name) |
int | get_dpi_attr (char *dpi_dir, char *service, struct dp *dpi_attr) |
int | register_service (struct dp *dpi_attr, char *service) |
int | register_all (struct dp **attlist) |
int | fill_services_list (struct dp *attlist, int numdpis, Dlist **services_list) |
int | init_ids_srs_socket (void) |
int | init_dpi_socket (struct dp *dpi_attr) |
int | init_all_dpi_sockets (struct dp *dpi_attr_list) |
void | dpi_sigchld (int sig) |
void | handle_sigchld (void) |
void | est_dpi_sigchld (void) |
void | est_dpi_terminator (void) |
void | stop_active_dpis (struct dp *dpi_attr_list, int numdpis) |
void | ignore_dpi_sockets (struct dp *dpi_attr_list, int numdpis) |
int | register_all_cmd (void) |
char * | get_message (int sock, char *dpi_tag) |
int | service_match (const struct service *A, const char *B) |
void | send_sockport (int sock_fd, char *dpi_tag, struct dp *dpi_attr_list) |
Variables | |
char * | srs_name |
int | srs_fd |
int | numdpis |
int | numsocks |
struct dp * | dpi_attr_list |
Dlist * | services_list |
fd_set | sock_set |
volatile sig_atomic_t | caught_sigchld |
Main functions to set-up dpi information and to initialise sockets
Definition in file dpid.h.
#define DPID_BASE_PORT (IPPORT_USERRESERVED + 20) |
#define SRS_NAME "dpid.srs" |
void cleanup | ( | void | ) |
Remove dpid_comm_keys file. This avoids that dillo instances connect to a stale port after dpid has exited (e.g. after a reboot).
Definition at line 52 of file dpid.c.
References dFree(), dGethomedir(), dotDILLO_DPID_COMM_KEYS, and dStrconcat().
Referenced by est_dpi_terminator(), and terminator().
void dpi_sigchld | ( | int | sig | ) |
SIGCHLD handler
Definition at line 687 of file dpid.c.
References caught_sigchld.
Referenced by est_dpi_sigchld().
void est_dpi_sigchld | ( | void | ) |
Establish SIGCHLD handler
Definition at line 717 of file dpid.c.
References dpi_sigchld(), and ERRMSG.
Referenced by main().
void est_dpi_terminator | ( | void | ) |
Add services reading a dpidrc file each non empty or commented line has the form service = path_relative_to_dpidir \Return:
Definition at line 437 of file dpid.c.
References _MSG, dFree(), dGethomedir(), dGetline(), dList_append(), dList_length(), dList_new(), dList_sort(), dNew, dotDILLO_DPI, dotDILLO_DPIDRC, service::dp_index, dParser_parse_rc_line(), dStrconcat(), dStrdup(), ERRMSG, get_dpi_dir(), MSG_ERR, service::name, numdpis, path(), services_alpha_comp(), and services_list.
Referenced by main(), and register_all_cmd().
void free_dpi_attr | ( | struct dp * | dpi_attr | ) |
void free_plugin_list | ( | struct dp ** | dpi_attr_list_ptr, |
int | numdpis | ||
) |
Free memory used by the plugin list
Definition at line 77 of file dpid.c.
References dFree(), dpi_attr_list, free_dpi_attr(), and numdpis.
Referenced by register_all_cmd().
void free_services_list | ( | Dlist * | s_list | ) |
Free memory used by the services list
Definition at line 94 of file dpid.c.
References dFree(), dList_free(), dList_length(), dList_nth_data(), and service::name.
Referenced by register_all_cmd().
int get_dpi_attr | ( | char * | dpi_dir, |
char * | service, | ||
struct dp * | dpi_attr | ||
) |
Scans a service directory in dpi_dir and fills dpi_attr \Note Caller must allocate memory for dpi_attr. \Return
Definition at line 233 of file dpid.c.
References dFree(), DPI_FILE, dStrconcat(), dStrdup(), ERRMSG, dp::filter, get_file_type(), dp::id, MSG_ERR, dp::path, dp::pid, and dp::port.
Referenced by register_all(), and register_service().
enum file_type get_file_type | ( | char * | file_name | ) |
Identify a given file Currently there is only one file type associated with dpis. More file types will be added as needed
Definition at line 162 of file dpid.c.
References DPI_EXT, DPI_FILE, ends_with(), MSG_ERR, and UNKNOWN_FILE.
Referenced by get_dpi_attr().
char * get_message | ( | int | sock_fd, |
char * | dpi_tag | ||
) |
Get value of msg field from dpi_tag \Return message on success, NULL on failure
Definition at line 832 of file dpid.c.
References a_Dpip_build_cmd(), a_Dpip_get_attr(), CKD_WRITE, dFree(), and ERRMSG.
Referenced by send_sockport().
void handle_sigchld | ( | void | ) |
void ignore_dpi_sockets | ( | struct dp * | dpi_attr_list, |
int | numdpis | ||
) |
int init_all_dpi_sockets | ( | struct dp * | dpi_attr_list | ) |
Setup sockets for the plugins and add them to the set of sockets (sock_set) watched by select. \Return
Definition at line 671 of file dpid.c.
References dpi_attr_list, init_dpi_socket(), numdpis, and numsocks.
Referenced by main(), and register_all_cmd().
int init_dpi_socket | ( | struct dp * | dpi_attr | ) |
Initialize a single dpi socket \Return
Definition at line 647 of file dpid.c.
References bind_socket_fd(), DPID_BASE_PORT, dp::port, dp::sock_fd, and sock_set.
Referenced by init_all_dpi_sockets().
int init_ids_srs_socket | ( | void | ) |
Initialise the service request socket (IDS) \Return:
Definition at line 623 of file dpid.c.
References a_Misc_mksecret(), bind_socket_fd(), DPID_BASE_PORT, save_comm_keys(), SharedKey, sock_set, and srs_fd.
Referenced by main().
int register_all | ( | struct dp ** | attlist | ) |
Create dpi directory for available plugins and create plugin list. \Return
Definition at line 347 of file dpid.c.
References dFree(), dGethomedir(), dotDILLO_DPI, dotDILLO_DPIDRC, dRealloc(), dStrconcat(), dStrdup(), ERRMSG, get_dpi_attr(), get_dpi_dir(), and MSG_ERR.
Referenced by main(), and register_all_cmd().
int register_all_cmd | ( | void | ) |
Registers available dpis and stops active non-filter dpis. Called when dpid receives cmd='register' service='all' command \Return Number of available dpis
Definition at line 811 of file dpid.c.
References dpi_attr_list, fill_services_list(), free_plugin_list(), free_services_list(), init_all_dpi_sockets(), numdpis, numsocks, register_all(), services_list, sock_set, srs_fd, and stop_active_dpis().
Referenced by main().
int register_service | ( | struct dp * | dpi_attr, |
char * | service | ||
) |
Register a service Retrieves attributes for "service" and stores them in dpi_attr. It looks for "service" in ~/.dillo/dpi first, and then in the system wide dpi directory. Caller must allocate memory for dpi_attr. \Return
Definition at line 293 of file dpid.c.
References dFree(), dGethomedir(), dotDILLO_DPI, dotDILLO_DPIDRC, dStrconcat(), dStrdup(), ERRMSG, get_dpi_attr(), get_dpi_dir(), and MSG_ERR.
void rm_dpi_sockets | ( | struct dp * | dpi_attr_list, |
int | numdpis | ||
) |
void send_sockport | ( | int | sock_fd, |
char * | dpi_tag, | ||
struct dp * | dpi_attr_list | ||
) |
Send socket port that matches dpi_id to client
Definition at line 868 of file dpid.c.
References a_Dpip_build_cmd(), CKD_WRITE, dFree(), dList_find_custom(), service::dp_index, dpi_attr_list, dReturn_if_fail, get_message(), numdpis, service_match(), and services_list.
Referenced by main().
int service_match | ( | const struct service * | A, |
const char * | B | ||
) |
Definition at line 851 of file dpid.c.
References dStrnAsciiCasecmp(), MAX, and service::name.
Referenced by send_sockport().
void stop_active_dpis | ( | struct dp * | dpi_attr_list, |
int | numdpis | ||
) |
Send DpiBye command to all active non-filter dpis
Definition at line 748 of file dpid.c.
References a_Dpip_build_cmd(), ckd_connect(), CKD_WRITE, dClose(), dFree(), dpi_attr_list, ERRMSG, make_socket_fd(), MSG_ERR, numdpis, path(), and SharedKey.
Referenced by main(), and register_all_cmd().
|
extern |
Set to 1 by the SIGCHLD handler dpi_sigchld
Definition at line 218 of file downloads.cc.
Referenced by cleanup_cb(), dpi_sigchld(), main(), and raw_sigchld().
|
extern |
State information for each plugin.
Definition at line 47 of file main.c.
Referenced by free_plugin_list(), handle_sigchld(), ignore_dpi_sockets(), init_all_dpi_sockets(), main(), register_all_cmd(), send_sockport(), server_is_running(), and stop_active_dpis().
|
extern |
Number of available plugins
Definition at line 45 of file main.c.
Referenced by fill_services_list(), free_plugin_list(), handle_sigchld(), ignore_dpi_sockets(), init_all_dpi_sockets(), main(), register_all_cmd(), send_sockport(), server_is_running(), and stop_active_dpis().
|
extern |
Number of sockets being watched
Definition at line 49 of file main.c.
Referenced by handle_sigchld(), init_all_dpi_sockets(), main(), and register_all_cmd().
|
extern |
service served for each plugin
Definition at line 48 of file main.c.
Referenced by fill_services_list(), main(), register_all_cmd(), and send_sockport().
|
extern |
Set of sockets watched for connections
Definition at line 46 of file main.c.
Referenced by handle_sigchld(), ignore_dpi_sockets(), init_dpi_socket(), init_ids_srs_socket(), main(), and register_all_cmd().
|
extern |
dpid's service request socket file descriptor
Definition at line 50 of file main.c.
Referenced by init_ids_srs_socket(), main(), and register_all_cmd().
|
extern |
Definition at line 44 of file main.c.
Referenced by a_Dpi_srs().