3 Copyright (C) 2004 Chris Porter.
10 #include <netinet/in.h>
19 #define SS_VERSIONED 0x01
20 #define SS_AUTHENTICATED 0x02
22 #define NTERFACER_PORT 2438
26 #define PROTOCOL_VERSION "4"
27 #define ANTI_FULL_VERSION "service_link " PROTOCOL_VERSION
31 typedef int (*handler_function
)(struct rline
*ri
, int argc
, char **argv
);
33 typedef struct handler
{
35 int args
; /* MINIMUM ARGUMENTS */
36 handler_function function
;
41 typedef struct service_node
{
43 struct handler
*handlers
;
44 struct service_node
*next
;
47 typedef struct rline
{
48 struct handler
*handler
;
50 struct service_node
*service
;
51 char buf
[MAX_BUFSIZE
];
55 struct esocket
*socket
;
58 typedef struct permitted
{
64 typedef struct sconnect
{
66 char response
[32 * 2 + 1], challenge
[32 * 2 + 1];
68 struct permitted
*permit
;
69 unsigned char ournonce
[16];
72 extern struct nterface_auto_log
*nrl
;
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
);
77 void deregister_handler(struct handler
*hp
);
78 int respond(struct rline
*li
, int argc
, ...);
79 int error_respond(struct rline
*li
, int error_code
, char *format
, ...);
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
);
85 int load_permits(void);
86 int setup_listening_socket(void);
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
);