commit package to go along with the last commit, thanks fofware
[packages.git] / net / remotectrl / src / remotectrl.h
1 /* Estos son los ficheros de cabecera usuales */
2 #include <stdio.h>          
3 #include <sys/types.h>
4 #include <sys/socket.h>
5 #include <netinet/in.h>
6 #include <errno.h>
7
8 #define PORT 15557 /* El puerto que ser? abierto */
9 #define BACKLOG 2 /* El n?mero de conexiones permitidas */
10 #define MAX_CLIENTS 10
11
12 enum 
13 {
14         MSG_OK              = 0,
15         MSG_START           = 1,
16         MSG_PART            = 2,
17         MSG_END             = 3,
18         QRY_STATUS          = 100,
19         QRY_CONNECTED_LIST  = 101,
20         QRY_MACADDR         = 102,
21         QRY_IPADDR          = 103,
22         QRY_USERNAME        = 104,
23 };
24
25 typedef struct msg_head_t {
26         uint32_t id;
27         uint32_t extra;
28         uint32_t len;
29 } msg_head_t;
30
31 typedef struct rmt_socket_t {
32         int fd;
33         struct sockaddr_in addr;
34         int Rx;
35         int Tx;
36 } rmt_socket_t;
37
38         
39 int write_msg( struct rmt_socket_t *sckHnd, uint32_t id, uint32_t extra, char *message );
40 int read_msg( struct rmt_socket_t *sckHnd, msg_head_t *head, char **message );
41
42 struct rmt_socket_t initSrv();
43 void rmtctrl_srv(struct rmt_socket_t srv, struct rmt_socket_t *client, int *activeClients);
44
45 void rmtctrl_accept (struct rmt_socket_t srv, struct rmt_socket_t *client );
46 void rmtctrl_cleanClients (struct rmt_socket_t *client, int *n);
47 void rmtctrl_msg_proccess(struct rmt_socket_t *client);
48 void rmtctrl_newClient(struct rmt_socket_t srv, struct rmt_socket_t *client, int *activeClients);
49 void rmtctrl_close ( struct rmt_socket_t *client );