]>
Commit | Line | Data |
---|---|---|
18f8bd28 CP |
1 | /* |
2 | nterfacer | |
3 | Copyright (C) 2004 Chris Porter. | |
4 | */ | |
5 | ||
6 | #ifndef __nterfacer_H | |
7 | #define __nterfacer_H | |
8 | ||
6bc02131 | 9 | #include <sys/types.h> |
18f8bd28 CP |
10 | #include <netinet/in.h> |
11 | ||
12 | #include "esockets.h" | |
13 | #include "library.h" | |
14 | ||
15 | #define BF_OK 0x00 | |
16 | #define BF_OVER 0xFF | |
17 | ||
18 | #define SS_IDLE 0x00 | |
19 | #define SS_VERSIONED 0x01 | |
20 | #define SS_AUTHENTICATED 0x02 | |
21 | ||
22 | #define NTERFACER_PORT 2438 | |
23 | ||
24 | #define MAX_ARGS 100 | |
25 | ||
1ac1d43c | 26 | #define PROTOCOL_VERSION "3" |
18f8bd28 CP |
27 | #define ANTI_FULL_VERSION "service_link " PROTOCOL_VERSION |
28 | ||
a690fb9f CP |
29 | struct rline; |
30 | ||
31 | typedef int (*handler_function)(struct rline *ri, int argc, char **argv); | |
32 | ||
18f8bd28 CP |
33 | typedef struct handler { |
34 | sstring *command; | |
35 | int args; /* MINIMUM ARGUMENTS */ | |
a690fb9f | 36 | handler_function function; |
18f8bd28 | 37 | struct handler *next; |
504f62c7 | 38 | void *service; |
18f8bd28 CP |
39 | } handler; |
40 | ||
41 | typedef struct service_node { | |
42 | sstring *name; | |
43 | struct handler *handlers; | |
44 | struct service_node *next; | |
45 | } service_node; | |
46 | ||
47 | typedef struct rline { | |
48 | struct handler *handler; | |
49 | int id; | |
50 | struct service_node *service; | |
51 | char buf[MAX_BUFSIZE]; | |
52 | char *curpos; | |
53 | struct rline *next; | |
54 | void *tag; | |
55 | struct esocket *socket; | |
56 | } rline; | |
57 | ||
58 | typedef struct permitted { | |
59 | sstring *hostname; | |
60 | sstring *password; | |
61 | in_addr_t ihost; | |
62 | } permitted; | |
63 | ||
64 | typedef struct sconnect { | |
65 | int status; | |
1ac1d43c CP |
66 | char response[32 * 2 + 1], challenge[32 * 2 + 1]; |
67 | unsigned char iv[16]; | |
18f8bd28 | 68 | struct permitted *permit; |
1ac1d43c | 69 | unsigned char ournonce[16]; |
18f8bd28 CP |
70 | } sconnect; |
71 | ||
72 | extern struct nterface_auto_log *nrl; | |
73 | ||
18f8bd28 CP |
74 | struct service_node *register_service(char *name); |
75 | struct handler *register_handler(struct service_node *service, char *command, int args, handler_function fp); | |
76 | void deregister_service(struct service_node *service); | |
504f62c7 | 77 | void deregister_handler(struct handler *hp); |
18f8bd28 CP |
78 | int respond(struct rline *li, int argc, ...); |
79 | int error_respond(struct rline *li, int error_code, char *format, ...); | |
80 | ||
81 | int ri_append(struct rline *li, char *format, ...); | |
82 | int ri_error(struct rline *li, int error_code, char *format, ...); | |
83 | int ri_final(struct rline *li); | |
84 | ||
85 | int load_permits(void); | |
86 | int setup_listening_socket(void); | |
87 | ||
88 | void nterfacer_accept_event(struct esocket *socket); | |
89 | void nterfacer_disconnect_event(struct esocket *socket); | |
90 | int nterfacer_line_event(struct esocket *socket, char *newline); | |
91 | int nterfacer_new_rline(char *line, struct esocket *socket, int *number); | |
92 | struct sconnect *find_sconnect_from_fd(int fd); | |
93 | ||
94 | #endif | |
95 |