annotate dpid/dpid.h @ 0:6ee11bf9e3ea

Initial revision
author jcid
date Sun, 07 Oct 2007 00:36:34 +0200
parents
children ec671a7ea6e2
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 <assert.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 #include <signal.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 #include <fcntl.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11 #include <sys/stat.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 #include <stdlib.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13 #include <stdio.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14 #include <sys/types.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15 #include <sys/wait.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16 #include <unistd.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 #include <string.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18 #include <sys/socket.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 #include <sys/time.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20 #include <sys/un.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 #include <errno.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23 #include "d_size.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 #define PATH_LEN 50
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 #define CMDLEN 20
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 #define MSGLEN 50
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 /*! \todo: Should read this from dillorc */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 #define SRS_NAME "dpid.srs"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 char *srs_name;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 /*! dpid service request socket */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 int srs;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 /*! plugin state information
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 struct dp {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39 char *id;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 char *path;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 char *sockpath;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 int socket;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43 struct sockaddr_un sa;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
44 pid_t pid;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 int filter;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 /*! Number of available plugins */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 int numdpis;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 /*! Number of sockets being watched */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 int numsocks;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54 /*! State information for each plugin. */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 struct dp *dpi_attr_list;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 /*! Set of sockets watched for connections */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58 fd_set sock_set;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
59
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
60 /*! Set to 1 by the SIGCHLD handler dpi_sigchld */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
61 extern volatile sig_atomic_t caught_sigchld;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
62
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
63 void rm_dpi_sockets(struct dp *dpi_attr_list, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
64
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
65 int rm_inactive_dpi_sockets(struct dp *dpi_attr_list, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
66
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
67 void cleanup(char *socket_dir);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
68
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
69 void free_dpi_attr(struct dp *dpi_attr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
70
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
71 void free_plugin_list(struct dp **dpi_attr_list_ptr, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
72
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
73 enum file_type get_file_type(char *file_name);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
74
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
75 int get_dpi_attr(char *dpi_dir, char *service, struct dp *dpi_attr);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
76
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77 int register_service(struct dp *dpi_attr, char *service);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
78
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
79 int register_all(struct dp **attlist);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
80
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
81 int init_srs_socket(char *sockdir);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
82
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
83 int init_dpi_socket(struct dp *dpi_attr, char *sockdir);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
84
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
85 int init_all_dpi_sockets(struct dp *dpi_attr_list, char *sockdir);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
86
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
87 void dpi_sigchld(int sig);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
88
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
89 void handle_sigchld(void);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
90
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
91 void est_dpi_sigchld(void);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
92
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
93 void stop_active_dpis(struct dp *dpi_attr_list, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
94
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
95 void ignore_dpi_sockets(struct dp *dpi_attr_list, int numdpis);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
96
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
97 int register_all_cmd(char *sockdir);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
98
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
99 char *get_message(int sock, char *dpi_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
100
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
101 void send_sockpath(int sock, char * dpi_tag, struct dp *dpi_attr_list);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
102
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
103 #endif