annotate dpid/dpid.h @ 2048:5060d415a85a

clickable menu items (even those introducing submenus) MUST have callbacks I clicked on the "Panel size" item itself instead of any of the options in its submenu, and: Segfault!
author corvid <corvid@lavabit.com>
date Thu, 26 May 2011 02:51:18 +0000
parents 3a159d7e5098
children
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*! \file
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * Main functions to set-up dpi information and to initialise sockets
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 #ifndef DPID_H
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 #define DPID_H
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 #include <sys/socket.h>
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
9 #include <sys/select.h> /* for fd_set */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 #include <sys/un.h>
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
11 #include <signal.h> /* for sig_atomic_t */
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
12 #include <netinet/in.h> /* for ntohl, IPPORT_USERRESERVED and stuff */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14 #include "d_size.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15
1404
d4a8309dc63c define IPPORT_USERRESERVED when the system doesn't provide it (FreeBSD)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
16 /* FreeBSD 6.4 doesn't have it */
d4a8309dc63c define IPPORT_USERRESERVED when the system doesn't provide it (FreeBSD)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
17 #ifndef IPPORT_USERRESERVED
d4a8309dc63c define IPPORT_USERRESERVED when the system doesn't provide it (FreeBSD)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
18 #define IPPORT_USERRESERVED 5000
d4a8309dc63c define IPPORT_USERRESERVED when the system doesn't provide it (FreeBSD)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1382
diff changeset
19 #endif
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 #define PATH_LEN 50
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22 #define CMDLEN 20
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23 #define MSGLEN 50
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
24 #define DPID_BASE_PORT (IPPORT_USERRESERVED + 20)
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
25
368
2242da885677 - s/todo:/TODO:/g
jcid
parents: 67
diff changeset
26 /*! \TODO: Should read this from dillorc */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 #define SRS_NAME "dpid.srs"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 char *srs_name;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
30 /*! dpid's service request socket file descriptor */
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
31 int srs_fd;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 /*! plugin state information
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 struct dp {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 char *id;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 char *path;
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
38 int sock_fd;
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
39 int port;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 pid_t pid;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 int filter;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43
67
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
44 /*! bind dpi with service
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
45 */
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
46 struct service {
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
47 char *name;
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
48 int dp_index;
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
49 };
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
50
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 /*! Number of available plugins */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 int numdpis;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54 /*! Number of sockets being watched */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 int numsocks;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 /*! State information for each plugin. */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58 struct dp *dpi_attr_list;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
59
67
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
60 /*! service served for each plugin */
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
61 Dlist *services_list;
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
62
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
63 /*! Set of sockets watched for connections */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
64 fd_set sock_set;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
65
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
66 /*! Set to 1 by the SIGCHLD handler dpi_sigchld */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
67 extern volatile sig_atomic_t caught_sigchld;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
68
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
69 void rm_dpi_sockets(struct dp *dpi_attr_list, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
70
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
71 void cleanup();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
72
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
73 void free_dpi_attr(struct dp *dpi_attr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
74
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
75 void free_plugin_list(struct dp **dpi_attr_list_ptr, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
76
67
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
77 void free_services_list(Dlist *s_list);
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
78
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
79 enum file_type get_file_type(char *file_name);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
80
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
81 int get_dpi_attr(char *dpi_dir, char *service, struct dp *dpi_attr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
82
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
83 int register_service(struct dp *dpi_attr, char *service);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
84
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
85 int register_all(struct dp **attlist);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
86
67
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
87 int fill_services_list(struct dp *attlist, int numdpis, Dlist **services_list);
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
88
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
89 int init_ids_srs_socket();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
90
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
91 int init_dpi_socket(struct dp *dpi_attr);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
92
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
93 int init_all_dpi_sockets(struct dp *dpi_attr_list);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
94
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
95 void dpi_sigchld(int sig);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
96
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
97 void handle_sigchld(void);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
98
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
99 void est_dpi_sigchld(void);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
100
1550
3a159d7e5098 remove ~/.dillo/dpid_comm_keys on exit of dpid
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1404
diff changeset
101 void est_dpi_terminator(void);
3a159d7e5098 remove ~/.dillo/dpid_comm_keys on exit of dpid
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1404
diff changeset
102
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
103 void stop_active_dpis(struct dp *dpi_attr_list, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
104
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
105 void ignore_dpi_sockets(struct dp *dpi_attr_list, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
106
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
107 int register_all_cmd();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
108
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
109 char *get_message(int sock, char *dpi_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
110
67
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
111 int service_match(const struct service *A, const char *B);
ec671a7ea6e2 - * Improved the dpi framework. Now dpi-programs can be specified in dpidrc,
jcid
parents: 0
diff changeset
112
1382
7faa2c7a544f Switch the DPI framework from Unix sockets to Internet sockets
Jorge Arellano Cid <jcid@dillo.org>
parents: 1223
diff changeset
113 void send_sockport(int sock_fd, char * dpi_tag, struct dp *dpi_attr_list);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
114
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
115 #endif