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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2