]> mj.ucw.cz Git - nwho.git/blob - nwho.h
Moved calculation of packet size to an extra function
[nwho.git] / nwho.h
1 /*
2  *      The Remote User Info Distribution Protocol
3  *
4  *      (c) 1997--2010 Martin Mares <mj@ucw.cz>
5  */
6
7 #include <inttypes.h>
8
9 typedef uint32_t u32;
10
11 #define MAX_USERS 128
12
13 struct userinfo {
14   char name[10];
15   char con[8];
16   char mesg_y;
17   char pad;
18   u32 login_time;
19   u32 idle_time;
20 };
21
22 struct nwho_pkt {
23   u32 magic;                            /* Guard against ancient nwho versions */
24   u32 local_time;
25   u32 server_time;                      /* Reserved for use by the server */
26   u32 num_users;
27   u32 uptime;
28   u32 avl[3];
29   struct userinfo users[MAX_USERS];
30 };
31
32 #define NWHO_SPOOL_DIR "/var/state/nwho"
33 #define NWHO_MAGIC 0x21913332
34 #define NWHO_PORT 811
35
36 #define DEFAULT_SEND_TIME 30
37 #define DEFAULT_PRUNE_TIME 30
38 #define DEFAULT_DOWN_TIME 120
39 #define DEFAULT_DEAD_TIME 4*86400
40
41 #define STRINGIFY(x) STRINGIFY2(x)
42 #define STRINGIFY2(x) #x
43
44 static inline int nwho_pkt_size(struct nwho_pkt *pkt)
45 {
46   return sizeof(struct nwho_pkt) - (MAX_USERS - ntohl(pkt->num_users))*sizeof(struct userinfo);
47 }