17 #include <netinet/in.h>
19 #define NSM2_PORT 8120
21 #define NSM2_MEMSIZ (4096*1024)
23 #define NSMENV_HOST "NSM2_HOST"
24 #define NSMENV_PORT "NSM2_PORT"
25 #define NSMENV_SHMKEY "NSM2_SHMKEY"
27 #define NSMDENV_USER "NSMD2_USER"
28 #define NSMDENV_GROUP "NSMD2_GROUP"
29 #define NSMDENV_DEBUG "NSMD2_DEBUG"
30 #define NSMDENV_LOGDIR "NSMD2_LOGDIR"
31 #define NSMDENV_PRIORITY "NSMD2_PRIORITY"
32 #define NSMDENV_TCPBUF "NSMD2_TCPBUF"
34 #ifndef __nsm2_typedef_nonstdint__
35 #define __nsm2_typedef_nonstdint__
36 typedef unsigned char byte8;
37 typedef unsigned short uint16;
38 typedef unsigned int uint32;
39 typedef unsigned long long uint64;
40 typedef signed short int16;
41 typedef signed int int32;
42 typedef signed long long int64;
45 #ifndef __nsm2_typedef_sockad__
46 #define __nsm2_typedef_sockad__
47 typedef struct sockaddr SOCKAD;
48 typedef struct sockaddr_in SOCKAD_IN;
51 #define NSMSYS_NAME_SIZ 31
52 #define NSMSYS_MAX_NOD 1024
53 #define NSMSYS_MAX_REF 4096
54 #define NSMSYS_MAX_REG 8192
55 #define NSMSYS_MAX_DAT 1024
56 #define NSMSYS_MAX_CON 1024
57 #define NSMSYS_MAX_REQ 1024
58 #define NSMSYS_MAX_HASH 2039
59 #define NSMSYS_MAX_SCH 256
60 #define NSMSYS_DNAM_SIZ 31
61 #define NSMSYS_DFMT_SIZ 63
62 #define NSMSYS_LOGDIR_SIZ 200
63 #define NSMSYS_LOGNAME_SIZ 256
69 #define NSM_MTUSIZ 1500
70 #define NSM_IPHEADSIZ 20
71 #define NSM_UDPHEADSIZ 8
72 #define NSM_UDPMSGSIZ 1472
73 #define NSM_UDPDATSIZ 1464
75 #define NSM_TCPHEADSIZ 16
76 #define NSM_TCPPARMAX 256
77 #define NSM_TCPDATSIZ 65536
78 #define NSM_TCPBUFSIZ (256*4 + NSM_TCPDATSIZ)
79 #define NSM_TCPMSGSIZ (16 + NSM_TCPBUFSIZ)
80 #define NSM_TCPTHRESHOLD (16 + 256*4)
82 #define NSM_DATCHUNKSIZ 1464
83 #define NSM_DATMAXCHUNK 44
84 #define NSM_DATMAXSIZ (NSM_DATCHUNKSIZ*NSM_DATMAXCHUNK)
86 #define NSMD_MAXINVFMT 32
87 #define NSMD_TIMINVFMT 3600
96 char dat[NSM_UDPDATSIZ];
131 #define NSMCMD_FIRST (0xff00)
132 #define NSMCMD_LAST (0xff1c)
134 #define NSMCMD_NEWCLIENT (NSMCMD_FIRST + 0x00)
135 #define NSMCMD_NEWCLIENTOB (NSMCMD_FIRST + 0x01)
136 #define NSMCMD_NEWMASTER (NSMCMD_FIRST + 0x02)
137 #define NSMCMD_DELCLIENT (NSMCMD_FIRST + 0x03)
138 #define NSMCMD_ALLOCMEM (NSMCMD_FIRST + 0x04)
139 #define NSMCMD_FREEMEM (NSMCMD_FIRST + 0x05)
140 #define NSMCMD_FLUSHMEM (NSMCMD_FIRST + 0x06)
141 #define NSMCMD_REQCPYMEM (NSMCMD_FIRST + 0x07)
142 #define NSMCMD_SYSCPYMEM (NSMCMD_FIRST + 0x08)
143 #define NSMCMD_OPENMEM (NSMCMD_FIRST + 0x09)
144 #define NSMCMD_CLOSEMEM (NSMCMD_FIRST + 0x0a)
145 #define NSMCMD_DUMPNODE (NSMCMD_FIRST + 0x0b)
146 #define NSMCMD_DUMPALLOC (NSMCMD_FIRST + 0x0c)
147 #define NSMCMD_DUMPDATA (NSMCMD_FIRST + 0x0d)
148 #define NSMCMD_DUMPCONN (NSMCMD_FIRST + 0x0e)
149 #define NSMCMD_DUMPINFO (NSMCMD_FIRST + 0x0f)
150 #define NSMCMD_DEBUGFLAG (NSMCMD_FIRST + 0x10)
151 #define NSMCMD_KILLDAEMON (NSMCMD_FIRST + 0x11)
152 #define NSMCMD_CLEANUP (NSMCMD_FIRST + 0x12)
153 #define NSMCMD_TOUCHMEM (NSMCMD_FIRST + 0x13)
154 #define NSMCMD_PING (NSMCMD_FIRST + 0x14)
155 #define NSMCMD_PONG (NSMCMD_FIRST + 0x15)
156 #define NSMCMD_READY (NSMCMD_FIRST + 0x16)
157 #define NSMCMD_NOP (NSMCMD_FIRST + 0x17)
158 #define NSMCMD_NEWREQ (NSMCMD_FIRST + 0x18)
159 #define NSMCMD_DELREQ (NSMCMD_FIRST + 0x19)
161 #define NSMCMD_UDPOFFSET (0xff00)
162 #define NSMCMD_NEWDAEMON (NSMCMD_FIRST + 0x1a)
163 #define NSMCMD_ACKDAEMON (NSMCMD_FIRST + 0x1b)
164 #define NSMCMD_USRCPYMEM (NSMCMD_FIRST + 0x1c)
168 char name[NSMSYS_NAME_SIZ + 1];
181 char name[NSMSYS_NAME_SIZ + 1];
201 char dtnam[NSMSYS_DNAM_SIZ + 1];
202 char dtfmt[NSMSYS_DFMT_SIZ + 1];
236 #define NSMCON_NON (-1)
284 char mem[NSM2_MEMSIZ];
294 int16_t sock_updated;
300 NSMnod nod[NSMSYS_MAX_NOD];
301 NSMref ref[NSMSYS_MAX_REF];
302 NSMdat dat[NSMSYS_MAX_DAT];
303 NSMreq req[NSMSYS_MAX_REQ];
304 NSMreg reg[NSMSYS_MAX_REG];
307 int32_t nodhash[NSMSYS_MAX_HASH + 1];
308 int32_t dathash[NSMSYS_MAX_HASH + 1];
309 int32_t reqhash[NSMSYS_MAX_HASH + 1];
311 NSMcon con[NSMSYS_MAX_CON];
312 NSMsch sch[NSMSYS_MAX_SCH];
315 int16_t conid[NSMSYS_MAX_NOD];
332 char logfile[NSMSYS_LOGNAME_SIZ];
345 char buf[NSM_TCPTHRESHOLD];