1 //%2006////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //==============================================================================
31 /*****************************************************************************
32 * Description: portability routines for nucleus RTOS
34 * Originated: December 17, 2001
35 * Original Author: Mike Day md@soft-hackle.net
37 * $Header: /cvs/MSB/pegasus/src/slp/slp_client/src/cmd-utils/slp_client/Attic/lslp-nucleus.h,v 1.4 2006/01/31 14:50:42 karl Exp $
39 * Copyright (c) 2001 - 2003 IBM
40 * Copyright (c) 2000 - 2003 Michael Day
42 * Permission is hereby granted, free of charge, to any person obtaining a
43 * copy of this software and associated documentation files (the "Software"),
44 * to deal in the Software without restriction, including without limitation
45 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
46 * and/or sell copies of the Software, and to permit persons to whom the
47 * Software is furnished to do so, subject to the following conditions:
49 * The above copyright notice and this permission notice shall be included in
50 * all copies or substantial portions of the Software.
53 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
54 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
55 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
56 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
57 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
58 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
59 * DEALINGS IN THE SOFTWARE.
61 *****************************************************************************/
67 #ifndef _LSLP_NUCLEUS_INCL_
68 #define LSLP_NUCLEUS_INCL_
82 #include "tcpsprt.h" //define for net version
83 #include "net\target.h"
84 #include "net\inc\nu_net.h"
85 #include "net\inc\arp.h"
86 #include "net\inc\socketd.h"
87 #include "net\inc\sockdefs.h"
89 UINT32 tcpst_inet_addr(char *);
91 /* DELETE these lines after you are ready to proceed ! */
92 //jeb#error "Remember to define the correct BYTE ORDER in the file endian.h"
93 //jeb#error "Check to ensure there is a nucleus implementation of inet_addr(char *) - I can write one if you need it"
94 //jeb#error "Check to ensure there is a nucleus implementation of htons(short int) - I can write one if you need it"
95 //jeb#error "Check to ensure there is a nucleus implementation of inet_ntoa(unsigned int) - I can write one if you need it"
96 //jeb#error "Need a gethostname function (returns a string holding the hostname of the management module)"
97 //jeb#error "prototype is int gethostname(char *buffer, int buffer_size) ; return zero upon success "
98 //jeb#error "need to define _LSLP_STRTOK( char *string, char *delimitors, char **state), which is a thread-safe version of strtok"
99 /* #error "errno is a global variable holding the code for the most recent failure" */
101 /*** nucleus include files ***/
103 /** below are posix include files that may or may not be appropriate to Nucleus ***/
104 /*** modify to include the correct files for the nucleus runtimes ***/
105 //jeb#include <signal.h>
106 //jeb#include <stdio.h>
107 //jeb#include <stdlib.h>
108 //jeb#include <stdarg.h>
109 //jeb#include <unistd.h>
110 //jeb#include <time.h>
111 //jeb#include <sys/types.h>
112 //jeb#include <sys/time.h>
113 //jeb#include <netinet/in.h>
114 //jeb#include <arpa/inet.h>
115 //jeb#include <sys/ioctl.h>
116 //jeb#include <sys/socket.h>
117 //jeb#include <sys/select.h>
118 //jeb#include <netdb.h>
119 //jeb#include <assert.h>
120 //jeb#include <memory.h>
121 //jeb#include <string.h>
122 //jeb#include <ctype.h>
131 typedef unsigned char uint8;
132 typedef unsigned char byte;
138 typedef unsigned short uint16;
139 typedef UINT16 uint16;
142 typedef unsigned long uint32;
144 //jeb chg typedef int INT;
149 /* ATTN << Thu Dec 20 11:35:36 2001 mdd >> */
157 /* ATTN << Tue Dec 18 09:40:43 2001 mdd >> */
158 /* this is a variable structure that probably has an option
159 id and then a variable sized buffer to hold the results */
160 /* typedef unsigned int SCK_IOCTL_OPTION ; */
162 /* probably don't need long longs */
163 /** typedef __int64 int64; **/
164 /** typedef unsigned __int64 uint64; **/ //jeb fix
173 typedef struct sockaddr
181 typedef struct sockaddr_in
186 struct in_addr sin_addr;
197 // char *h_addr; //jeb
201 //jeb extern NU_Host_Ent * nucleus_gethostbyname(const char *name);
202 //jeb extern NU_Host_Ent * nucleus_gethostbyaddr( const void *addr, int len, int type);
203 extern NU_HOSTENT * nucleus_gethostbyname(const char *name);
204 extern NU_HOSTENT * nucleus_gethostbyaddr( const void *addr, int len, int type);
213 #define SOCK_DGRAM NU_TYPE_DGRAM
214 #define SOCK_STREAM NU_TYPE_STREAM
215 #define UNUSED_NU_PARM 0
217 #define INVALID_SOCKET NU_INVALID_SOCKET
218 #define SOCKET_ERROR NU_INVALID_SOCKET
220 #define AF_INET SK_FAM_IP
221 #define INADDR_NONE 0
222 #define INADDR_ANY INADDR_NONE
225 /* ATTN need to define these error constants for nucleus << Tue Dec 18 16:22:28 2001 mdd >> */
227 #define EINTR /* call was interrupted */
228 #define ENOTSOCK INVALID_SOCKET
229 #define EADDRNOTAVAIL
241 /*** function macros ***/
243 /*** << Mon Dec 17 17:28:24 2001 mdd >>
245 NOTE: Many of these calls require unused or null values for parameters.
246 I've substituted (hardcoded) these parameters where I could find them.
247 This is not very portable nor maintainable; perhaps you will find a better solution !
251 #define _LSLP_CLOSESOCKET(a) NU_Close_Socket((int)(a))
252 #define _LSLP_SOCKET(a, b, c) NU_Socket( NU_FAMILY_IP, ((INT16)(b)), NU_NONE )
254 #define _LSLP_BIND(a, b, c) \
255 NU_Bind ((INT)(a),((struct addr_struct *)(b)),UNUSED_NU_PARM )
256 #define _LSLP_CONNECT(a, b, c ) \
257 NU_Connect ((INT)(a), \
258 ((struct addr_struct *)(b)), \
260 #define _LSLP_LISTEN(a, b) NU_Listen ((INT)(a), (UINT16)(b))
261 #define _LSLP_ACCEPT(a, b, c) \
262 NU_Accept ((INT)(a), \
263 ((struct addr_struct *)(b)), \
265 #define _LSLP_SEND(a, b, c, d) NU_Send ((INT)(a), (CHAR *)(b), (UINT16)(c), UNUSED_NU_PARM)
266 #define _LSLP_SENDTO(a, b, c, d, e, f) \
267 NU_Send_To ((INT)(a), (char *)(b), (UINT16)(c), (UNUSED_NU_PARM), \
268 ((struct addr_struct *)(e)), \
270 #define _LSLP_RECV(a, b, c, d) NU_Recv ((INT)(a), (char *)(b), (UINT16)(c), UNUSED_NU_PARM )
271 #define _LSLP_RECV_FROM(a, b, c, d, e, f) \
272 NU_Recv_From ((INT)(a), (char *)(b), (INT16)(c), (UNUSED_NU_PARM), \
273 ((struct addr_struct *)(e)), \
276 /* << Tue Dec 18 07:53:12 2001 mdd >> ATTN need to redefine these gethost functions */
277 /* for all platforms */
279 #define _LSLP_GETHOSTBYNAME(a) \
280 (struct hostent *) nucleus_gethostbyname((const char *)(a))
281 #define _LSLP_GETHOSTBYADDR(a, b, c ) \
282 (struct hostent *) nucleus_gethostbyaddr( (const void *)(a), (int)(b), (int)(c))
284 #define _LSLP_SETSOCKOPT(a, b, c, d, e) \
285 NU_Setsockopt(((INT)(a)), ((INT)(b)), ((INT)(c)), ((void *)(d)), ((INT)(e)))
286 #define _LSLP_GETSOCKOPT(a, b, c, d, e) \
287 NU_Getsockopt(((INT)(a)), ((INT)(b)), ((INT)(c)), ((void *)(d)), ((INT *)(e)))
289 #define _LSLP_SET_TTL(s, t) NU_Setsockopt((s), IPPROTO_IP, IP_MULTICAST_TTL, (void *)&(t), sizeof((t))) //jeb
291 /* << Tue Dec 18 08:16:59 2001 mdd >> ATTN need to redefine abort to be shutdown & close */
292 #define _LSLP_ABORT(a) NU_Abort(((INT)(a)))
294 #define _LSLP_SLEEP(a) _sleep((int)(a))
297 #define _LSLP_STRTOK(s, d, x) strtok(((char*)(s)),((const char *)(d)))
303 #define assert(a) _system_info((!(a)),"ASSERT:%s/%d", __FILE__, __LINE__)
305 //#define assert(a) ((void)0)
308 #define htons(x) INTSWAP((unsigned short)(x))
309 #define ntohs(x) INTSWAP((unsigned short)(x))
310 #define ntohl(x) LONGSWAP((unsigned long)(x))
311 #define inet_addr(x) tcpst_inet_addr((char *)(x))
313 #define _itoa(a,b,c) itoa(((int)(a)),((char*)(b)),((int)(c)))
316 /* << Tue Dec 18 09:54:25 2001 mdd >> ATTN the final parameter is a pointer on windows */
317 /* and unix, but is an integer on Nucleus that specifies timer ticks */
332 //jeb typedef TIMEVAL timeval;
335 #define _LSLP_SELECT(a, b, c, d, e ) \
336 NU_Select(((INT)(a)), ((FD_SET *)(b)), ((FD_SET *)(c)), ((FD_SET *)(d)), \
337 ((UNSIGNED)(((struct _lslp_timeval *)(e))->tv_usec)))
339 #define _LSLP_SELECT(a, b, c, d, e ) \
340 NU_Select(((INT)(a)), ((FD_SET *)(b)), ((FD_SET *)(c)), ((FD_SET *)(d)), \
341 (sint)((((struct _lslp_timeval *)(e))->tv_usec) & 0x7fffffff ) )
343 #define LSLP_FD_SET FD_SET
344 #define _LSLP_FD_ISSET(a, b) NU_FD_Check(((INT)(a)), ((FD_SET *)(b)))
345 #define _LSLP_FD_SET(a, b) NU_FD_Set(((INT)(a)), ((FD_SET *)(b)))
346 #define _LSLP_FD_ZERO(a) NU_FD_Init(((FD_SET *)(a)))
347 #define _LSLP_FD_CLR(a, b) NU_FD_Reset(((INT)(a)), ((FD_SET *)(b)))
350 /* ATTN << Tue Dec 18 10:42:19 2001 mdd >> */
352 //jeb #define _LSLP_IOCTLSOCKET(a, b, c) #error "See Nucleus NET Reference Manual for limitations on usage of ioctl\n"
354 /* ATTN << Tue Dec 18 12:54:40 2001 mdd >> */
355 #define _LSLP_GETLASTERROR()
360 We probably don't need these to be defined << Tue Dec 18 16:21:23 2001 mdd >>
362 STATUS NU_Send_To_Raw(INT socketd, char *buff, UINT16 nbytes, INT16 flags,
363 struct addr_struct *to, INT16 addrlen);
365 INT16 NU_Get_IPRaw_PCB(INT socketd, struct sock_struct *);
368 STATUS NU_Recv_From_No_Suspend (INT16, char *, INT16, INT16, struct addr_struct *, INT16 *);
369 STATUS NU_Find_Open_Sckts_For_Dev (UINT8 sck_type, INT skt, DV_DEVICE_ENTRY *dev_ptr);
372 STATUS NU_Recv_From_Raw (INT, char *, INT16, INT16, struct addr_struct *, INT16 *);
374 STATUS NU_Push (INT);
375 STATUS NU_Is_Connected (INT);
376 INT16 NU_GetPnum (struct sock_struct *);
377 INT16 NU_Get_UDP_Pnum (struct sock_struct *);
378 STATUS NU_Fcntl (INT socketd, INT16 command, INT16 arguement);
379 STATUS NU_Get_Peer_Name(INT, struct sockaddr_struct *, INT16 *);
384 char *inet_ntoa(struct in_addr in);
392 #endif /* nucleus include */