(file) Return to lslp-perl.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / slp

  1 mike  1.3 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3 kumpf 1.5 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4           // The Open Group, Tivoli Systems
  5 mike  1.3 //
  6           // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.5 // of this software and associated documentation files (the "Software"), to
  8           // deal in the Software without restriction, including without limitation the
  9           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10 mike  1.3 // sell copies of the Software, and to permit persons to whom the Software is
 11           // furnished to do so, subject to the following conditions:
 12           // 
 13 kumpf 1.5 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.3 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16 kumpf 1.5 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19 mike  1.3 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21           //
 22           //==============================================================================
 23 mday  1.4 
 24 mday  1.1 
 25           #ifndef _LSLPDEFS_INCLUDE
 26           #define _LSLPDEFS_INCLUDE
 27           
 28           
 29           #ifdef __linux__
 30           #include <endian.h>
 31           #else
 32           #define	__LITTLE_ENDIAN__	1234
 33           #define	__BIG_ENDIAN__	4321
 34           #define	__PDP_ENDIAN__	3412
 35           #define __BYTE_ORDER__ __LITTLE_ENDIAN__
 36           #endif
 37           
 38           
 39             /********* circular list macros *********************/
 40           
 41             /*---------------------------------------------------------------------**
 42             ** structures used with these macros MUST have the following elements: **
 43             ** struct type-name {                                                  **
 44             ** 	struct type-name *next;                                            **
 45 mday  1.1   ** 	struct type-name *prev;                                            **
 46             ** 	BOOL isHead;                                                       **
 47             ** 	}                                                                  **
 48             **---------------------------------------------------------------------*/
 49           
 50             /*  is node x the head of the list? */
 51             /* BOOL IS_HEAD(node *x); */
 52           #define _LSLP_IS_HEAD(x) ((x)->isHead )
 53           
 54             /* where h is the head of the list */
 55             /* BOOL _LSLP_IS_EMPTY(head);          */
 56           #define _LSLP_IS_EMPTY(h) \
 57           	((((h)->next == (h)) && ((h)->prev == (h)) ) ? TRUE : FALSE)
 58           
 59             /* where n is the new node, insert it immediately after node x */
 60             /* x can be the head of the list                               */
 61             /* void _LSLP_INSERT(new, after);                                  */
 62           #define _LSLP_INSERT(n, x)   	\
 63           	{(n)->prev = (x); 		\
 64           	(n)->next = (x)->next; 	\
 65           	(x)->next->prev = (n); 	\
 66 mday  1.1 	(x)->next = (n); }		
 67           
 68           #define _LSLP_INSERT_AFTER _LSLP_INSERT
 69           #define _LSLP_INSERT_BEFORE(n, x)   \
 70           	{(n)->next = (x);					\
 71           	(n)->prev = (x)->prev;				\
 72           	(x)->prev->next = (n);				\
 73           	(x)->prev = (n); }
 74           
 75           #define _LSLP_INSERT_WORKNODE_LAST(n, x)    \
 76                   {gettimeofday(&((n)->timer));  \
 77           	(n)->next = (x);	       \
 78           	(n)->prev = (x)->prev;	       \
 79           	(x)->prev->next = (n);	       \
 80           	(x)->prev = (n); }
 81           
 82           #define _LSLP_INSERT_WORKNODE_FIRST(n, x)    \
 83                   {gettimeofday(&((n)->timer));  \
 84           	(n)->prev = (x); 	       \
 85           	(n)->next = (x)->next; 	       \
 86           	(x)->next->prev = (n); 	       \
 87 mday  1.1 	(x)->next = (n); }		
 88           
 89           
 90             /* delete node x  - harmless if mib is empty */
 91             /* void _LSLP_DELETE_(x);                        */
 92           #define _LSLP_UNLINK(x)				\
 93           	{(x)->prev->next = (x)->next;	\
 94           	(x)->next->prev = (x)->prev;}	
 95           
 96             /* given the head of the list h, determine if node x is the last node */
 97             /* BOOL _LSLP_IS_LAST(head, x);                                           */
 98           #define _LSLP_IS_LAST(h, x) \
 99           	(((x)->prev == (h) && (h)->prev == (x)) ? TRUE : FALSE)
100           
101             /* given the head of the list h, determine if node x is the first node */
102             /* BOOL _LSLP_IS_FIRST(head, x);                                           */
103           #define _LSLP_IS_FIRST(h, x) \
104           	(((x)->prev == (h) && (h)->next == (x)) ? TRUE : FALSE)
105           
106             /* given the head of the list h, determine if node x is the only node */
107             /* BOOL _LSLP_IS_ONLY(head, x);                                           */
108 mday  1.1 #define _LSLP_IS_ONLY(h, x) \
109           	(((x)->next == (h) && (h)->prev == (x)) ? TRUE : FALSE)
110             /* void _LSLP_LINK_HEAD(dest, src); */
111           #define _LSLP_LINK_HEAD(d, s) \
112           	{(d)->next = (s)->next;  \
113           	(d)->prev = (s)->prev;  \
114           	(s)->next->prev = (d);  \
115           	(s)->prev->next = (d) ; \
116                   (s)->prev = (s)->next = (s); }
117           
118           
119             /************* bit-set macros *********************************/
120             /* how many dwords do we need to allocate to hold b bits ? */
121           #define _LSLP_SIZEOF_BITARRAY(b) (((b) >> 5) + 1)
122             /*  operating on an array of dwords */
123           #define _LSLP_IS_BIT_SET(b, a) (*((a) + ((b) >> 5))	& (1 << (((b)%32) - 1)))
124           #define _LSLP_SET_BIT(b, a) (*((a) + ((b) >> 5)) |= (1 << (((b)%32) - 1)))
125           #define _LSLP_CLEAR_BIT(b, a) (*((a) + ((b) >> 5)) ^= (1 << (((b)%32) - 1)))
126           
127             /* the usual */
128           #define _LSLP_MIN(a, b) ((a) < (b) ? (a) : (b))
129 mday  1.1 #define _LSLP_MAX(a, b) ((a) > (b) ? (a) : (b))
130           
131             /********************** SLP V2 MACROS *************************/
132             /**************************************************************/
133           #define LSLP_PROTO_VER 2
134           #define LSLP_PORT 427
135           #define _LSLP_LOCAL_BCAST inet_addr("255.255.255.255") 
136           #define _LSLP_MCAST       inet_addr("239.255.255.253")
137             /* derive an address for a directed broadcast */
138             /* a = uint32 addr, m = uint32 mask */
139             /* #define _LSLP_DIR_BCAST(a, m) ((((a) &= (m)) &&  ((a) |= ~(m))) ? (a) : (a) ) */
140           
141           #define LSLP_EN_US "en-USA\0\0"
142           #define LSLP_EN_US_LEN 8
143             /* the absolute minimum hdr size */
144           #define LSLP_MIN_HDR  14
145           
146             /* slp v2 message types */
147           #define LSLP_SRVRQST 		 1
148           #define LSLP_SRVRPLY 		 2
149           #define LSLP_SRVREG 		 3
150 mday  1.1 #define LSLP_SRVDEREG		 4
151           #define LSLP_SRVACK		 5
152           #define LSLP_ATTRREQ		 6
153           #define LSLP_ATTRRPLY		 7
154           #define LSLP_DAADVERT		 8
155           #define LSLP_SRVTYPERQST	 9
156           #define LSLP_SRVTYPERPLY        10
157           #define LSLP_SAADVERT		11
158           #define LSLP_MESHCTRL           12
159           #define LSLP_MESHCTRL_NULL       0
160           #define LSLP_MESHCTRL_DATA       2
161           #define LSLP_MESHCTRL_PEER_IND   3
162           #define LSLP_MESHCTRL_DA_IND     4
163           #define LSLP_MESHCTRL_KEEPALIVE  5 
164           #define LSLP_MESHCTRL_EXT        0x0006
165           #define LSLP_MESHCTRL_FORWARD    1
166           
167             /* slp error codes */
168           #define LSLP_LANGUAGE_NOT_SUPPORTED 	 1
169           #define LSLP_PARSE_ERROR 		 2
170           #define LSLP_INVALID_REGISTRATION	 3
171 mday  1.1 #define LSLP_SCOPE_NOT_SUPPORTED 	 4
172           #define LSLP_AUTHENTICATION_UNKNOWN 	 5
173           #define LSLP_AUTHENTICATION_ABSENT       6
174           #define LSLP_AUTHENTICATION_FAILED       7
175           #define LSLP_VERSION_NOT_SUPPORTED       9
176           #define LSLP_INTERNAL_ERROR 	   	10
177           #define LSLP_DA_BUSY 			11
178           #define LSLP_OPTION_NOT_UNDERSTOOD      12
179           #define LSLP_INVALID_UPDATE 		13
180           #define LSLP_MSG_NOT_SUPPORTED 	        14
181           #define LSLP_REFRESH_REJECTED 		15
182           
183             /*SLP error codes */
184           #define LSLP_OK				0x00000000
185           #define LSLPERR_BASE 			0x00002000
186           #define LSLPERR_INVALID_SEM 	        LSLPERR_BASE + 	0x00000001
187           #define LSLP_NOT_INITIALIZED            LSLPERR_BASE + 	0x00000002	
188           #define LSLP_TIMEOUT			LSLPERR_BASE + 	0x00000003
189           #define LSLP_MALLOC_ERROR		LSLPERR_BASE + 	0x00000004
190           #define LSLP_FILE_ERROR                 LSLPERR_BASE +  0x00000005
191           #define LSLP_LDAP_BIND_ERROR            LSLPERR_BASE +  0x00000006
192 mday  1.1 #define LSLP_LDAP_MODIFY_ERROR          LSLPERR_BASE +  0x00000007
193           #define LSLP_LDAP_NOT_INITIALIZED       LSLPERR_BASE +  0x00000008
194           
195           
196             /* offsets into the SLPv2 header */
197           #define LSLP_VERSION 	 0
198           #define LSLP_FUNCTION 	 1
199           #define LSLP_LENGTH 	 2
200           #define LSLP_FLAGS 		 5
201           #define LSLP_NEXT_EX 	 7
202           #define LSLP_XID 		10
203           #define LSLP_LAN_LEN 	12
204           #define LSLP_LAN 		14
205           
206           
207             /* macros to gain access to SLP header fields */
208             /* h = (uint8 *)slpHeader */
209             /* o = int32 offset */
210             /* i = int32 value */
211           #if __BYTE_ORDER == __LITTLE_ENDIAN
212           #define _LSLP_GETBYTE(h, o)  (0x00ff  & *(uint8 *) &((h)[(o)]))
213 mday  1.1 #define _LSLP_GETSHORT(h, o) ((0xff00 & _LSLP_GETBYTE((h), (o)) << 8) + \
214           				 (0x00ff & _LSLP_GETBYTE((h), (o) + 1)) ) 
215           #define _LSLP_SETBYTE(h, i, o) ((h)[(o)] = (uint8)i)
216           #define _LSLP_SETSHORT(h, i, o) { _LSLP_SETBYTE((h), (0xff & ((i) >> 8)), (o)); \
217           				     _LSLP_SETBYTE((h), (0xff & (i)), (o) + 1); }
218           #define _LSLP_GETLONG(h, o) ( (0xffff0000 & _LSLP_GETSHORT((h), (o)) << 16) + \
219           				  (0x0000ffff & _LSLP_GETSHORT((h), (o) + 2)) )
220           #define _LSLP_SETLONG(h, i, o) 	{ _LSLP_SETSHORT((h), (0xffff & ((i) >> 16)), (o) ); \
221           				  _LSLP_SETSHORT((h), (0xffff & (i)), (o) + 2); }
222             /* length is a 3-byte value */
223           #define _LSLP_GETLENGTH(h) ((0xff0000 & (*(uint8 *) &((h)[LSLP_LENGTH]) << 16)) + \
224           			(0x00ff00 & (*(uint8 *) &((h)[LSLP_LENGTH + 1]) << 8)) + \
225           			(0x0000ff & (*(uint8 *) &((h)[LSLP_LENGTH + 2]))))
226           #define _LSLP_SETLENGTH(h, i) {_LSLP_SETSHORT( (h), (((i) & 0xffff00) >> 8), LSLP_LENGTH ); \
227           			  _LSLP_SETBYTE((h), ((i) & 0x0000ff), LSLP_LENGTH + 2);}
228             /* next option offset is a 3-byte value */
229           #define _LSLP_GETFIRSTEXT(h) ((0xff0000 & (*(uint8 *) &((h)[LSLP_NEXT_EX]) << 16)) + \
230           			(0x00ff00 & (*(uint8 *) &((h)[LSLP_NEXT_EX + 1]) << 8)) + \
231           				(0x0000ff & (*(uint8 *) &((h)[LSLP_NEXT_EX + 2]))))
232           #define _LSLP_SETFIRSTEXT(h, i) {_LSLP_SETSHORT((h), (((i) & 0xffff00) >> 8), LSLP_NEXT_EX ); \
233           			  _LSLP_SETBYTE((h), ((i) & 0x0000ff), LSLP_NEXT_EX + 2);}
234 mday  1.1 
235           #define _LSLP_GETNEXTEXT(h, o) ((0xff0000 & (*(uint8 *) &((h)[(o)]) << 16)) + \
236           			(0x00ff00 & (*(uint8 *) &((h)[(o) + 1]) << 8)) + \
237           				(0x0000ff & (*(uint8 *) &((h)[(o) + 2]))))
238           #define _LSLP_SETNEXTEXT(h, i, o) {_LSLP_SETSHORT((h), (((i) & 0xffff00) >> 8), (o) ); \
239           			  _LSLP_SETBYTE((h), ((i) & 0x0000ff), (o) + 2);}
240           
241           #else /* BIG ENDIAN */
242           
243           #define _LSLP_GETBYTE(h, o)  (0x00ff  & *((uint8 *) &((h)[(o)])))
244           #define _LSLP_GETSHORT(h, o) (0xffff & *((uint16 *) &((h)[(o)])))
245           #define _LSLP_SETBYTE(h, i, o) ((h)[(o)] = (uint8)(i))
246           #define _LSLP_SETSHORT(h, i, o) (*((uint16 *) &((h)[(o)])) = (0xffff & (i)))
247           #define _LSLP_GETLONG(h, o)  (0xffffffff & *((uint32 *)&((h)[(o)])))
248           #define _LSLP_SETLONG(h, i, o) 	(*((uint32 *)&((h)[(o)])) = (0xffffffff * (i)))
249             /* length is a 3-byte value */
250           #define _LSLP_GETLENGTH(h) (0x00ffffff & *((uint32 *)(&h[LSLP_LENGTH])))
251           #define _LSLP_SETLENGTH(h, i) {_LSLP_SETSHORT((h), (0x00ffff00 & (i)), LSLP_LENGTH) ; \
252                                           _LSLP_SETBYTE((h), (0x000000ff & (i)), LSLP_LENGTH + 2);}
253             /* next option offset is a 3-byte value */
254           #define _LSLP_GETFIRSTEXT(h) (0x00ffffff & *((uint32 *)(&h[LSLP_NEXT_EX])))
255 mday  1.1 #define _LSLP_SETFIRSTEXT(h, i) {_LSLP_SETSHORT((h), (0x00ffff00 & (i)), LSLP_NEXT_EX) ; \
256                                           _LSLP_SETBYTE((h), (0x000000ff & (i)), LSLP_NEXT_EX + 2);}
257           #define _LSLP_GETNEXTEXT(h, o) (0x00ffffff & *((uint32 *)(&h[(o)])))
258           #define _LSLP_SETNEXTEXT(h, i, o) {_LSLP_SETSHORT((h), (0x00ffff00 & (i)), (o)) ; \
259                                           _LSLP_SETBYTE((h), (0x000000ff & (i)), (o) + 2);}
260           
261           
262           #endif /* ENDIAN definitions */
263           
264             /* macros to get and set header fields */
265           #define _LSLP_GETVERSION(h) _LSLP_GETBYTE((h), LSLP_VERSION)
266           #define _LSLP_SETVERSION(h, i) _LSLP_SETBYTE((h), (i), LSLP_VERSION)
267           #define _LSLP_GETFUNCTION(h) _LSLP_GETBYTE((h), LSLP_FUNCTION)
268           #define _LSLP_SETFUNCTION(h, i) _LSLP_SETBYTE((h), (i), LSLP_FUNCTION)
269           #define _LSLP_GETFLAGS(h) _LSLP_GETBYTE((h), LSLP_FLAGS)
270           #define _LSLP_SETFLAGS(h, i) _LSLP_SETBYTE((h), (i), LSLP_FLAGS)
271           #define _LSLP_GETLANLEN(h) _LSLP_GETSHORT((h), LSLP_LAN_LEN)
272           #define _LSLP_SETLANLEN(h, i) _LSLP_SETSHORT((h), (i), LSLP_LAN_LEN)
273             /* s = int8 *language-string */
274           #define _LSLP_SETLAN(h, s) {_LSLP_SETSHORT((h),(_LSLP_MIN( (strlen((s)) + 2), 17)), LSLP_LAN_LEN); \
275           		    memcpy(&(h)[LSLP_LAN],(s),(_LSLP_MIN( (strlen((s)) + 2) , 17)));}
276 mday  1.1 #define _LSLP_GETXID(h) _LSLP_GETSHORT((h), LSLP_XID) 
277           #define _LSLP_SETXID(h, i) _LSLP_SETSHORT((h), (i), LSLP_XID)
278           #define _LSLP_HDRLEN(h) (14 + _LSLP_GETLANLEN((h))) 
279             /* give (work *), how big is the msg header ? */
280           #define _LSLP_HDRLEN_WORK(work) (14 + (work)->hdr.langLen ) 
281             /* given (work *), how big is the data field ? */
282           #define _LSLP_DATALEN_WORK(work) (((work)->hdr.len) - _LSLP_HDRLEN_WORK((work)))
283           
284           #define LSLP_FLAGS_OVERFLOW 0x80
285           #define LSLP_FLAGS_FRESH    0x40
286           #define LSLP_FLAGS_MCAST    0x20
287           
288             /******** internal slp message definitions ********/
289           
290             /* URL entry definitions */
291           #define LSLP_URL_LIFE    1
292           #define LSLP_URL_LEN	 3
293           #define _LSLP_GETURLLIFE(h) _LSLP_GETSHORT((h), LSLP_URL_LIFE)
294           #define _LSLP_SETURLLIFE(h, i) _LSLP_SETSHORT((h), (i), LSLP_URL_LIFE)
295           #define _LSLP_GETURLLEN(h) _LSLP_GETSHORT((h), LSLP_URL_LEN)
296           #define _LSLP_SETURLLEN(h, i) _LSLP_SETSHORT((h), (i), LSLP_URL_LEN)
297 mday  1.1 
298           #define LSLP_MTU 1432
299           
300           
301           
302           #endif /* _LSLPDEFS_INCLUDE */
303           
304           

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2