]> mj.ucw.cz Git - nwho.git/blob - nwho.h
Debian: Fixed service dependency on network
[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 #include <netinet/in.h>
9
10 typedef uint32_t u32;
11
12 #define MAX_USERS 128
13
14 struct userinfo {
15   char name[10];
16   char con[8];
17   char mesg_y;
18   char pad;
19   u32 login_time;
20   u32 idle_time;
21 };
22
23 struct nwho_pkt {
24   u32 magic;                            /* Guard against ancient nwho versions */
25   u32 local_time;
26   u32 server_time;                      /* Reserved for use by the server */
27   u32 num_users;
28   u32 uptime;
29   u32 avl[3];
30   struct userinfo users[MAX_USERS];
31 };
32
33 #define NWHO_SPOOL_DIR "/var/state/nwho"
34 #define NWHO_MAGIC 0x21913332
35 #define NWHO_PORT 811
36
37 #define DEFAULT_SEND_TIME 30
38 #define DEFAULT_PRUNE_TIME 30
39 #define DEFAULT_DOWN_TIME 120
40 #define DEFAULT_DEAD_TIME 4*86400
41
42 #define STRINGIFY(x) STRINGIFY2(x)
43 #define STRINGIFY2(x) #x
44
45 static inline int nwho_pkt_size(struct nwho_pkt *pkt)
46 {
47   return sizeof(struct nwho_pkt) - (MAX_USERS - ntohl(pkt->num_users))*sizeof(struct userinfo);
48 }
49
50 /* util.c */
51
52 void die(char *msg, ...) __attribute__((noreturn));