1 /*---------------------------------------------------------------------------*
2   Project:  SO library
3   File:     so.h
4 
5   Copyright 2006 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: so.h,v $
14   Revision 1.8  2007/08/10 12:30:59  seiki_masashi
15   Changed SO_STARTUP_TIMEOUT from 600 seconds to 60 seconds.
16 
17   Revision 1.7  2007/01/29 07:47:21  terui
18   Definitions relating to public functions in the SO library were moved to SOBasic.h.
19   Settings relating to IPv6 were moved to SOPrivate.h.
20   include header declarations were moved to SOPrivate.h.
21 
22   Revision 1.6  2006/09/15 06:31:09  terui
23   Switched IPv6 support
24 
25   Revision 1.5  2006/09/14 07:42:43  yasu
26   IP4 support
27 
28   Revision 1.4  2006/08/08 14:00:31  terui
29   Fixed comments.
30 
31   Revision 1.3  2006/08/08 13:50:41  terui
32   Divided and set up SOBasic.h, SOIcmp.h and SOOption.h
33 
34   Revision 1.2  2006/08/08 06:46:50  terui
35   Provisional version during porting
36 
37   Revision 1.1  2006/08/07 02:16:30  terui
38   Uploaded the current state
39 
40   $NoKeywords: $
41  *---------------------------------------------------------------------------*/
42 
43 #ifndef REVOLUTION_SO_H_
44 #define REVOLUTION_SO_H_
45 
46 #ifdef  __cplusplus
47 extern "C" {
48 #endif
49 /*===========================================================================*/
50 
51 /*---------------------------------------------------------------------------*
52     Fixed numbers
53  *---------------------------------------------------------------------------*/
54 
55 /* Result codes */
56 #define     SO_SUCCESS              0
57 #define     SO_OK                   SO_SUCCESS
58 #define     SO_EFATAL               0x80000000
59 #define     SO_E2BIG                (-1)
60 #define     SO_EACCES               (-2)
61 #define     SO_EADDRINUSE           (-3)            // Address is already in use
62 #define     SO_EADDRNOTAVAIL        (-4)
63 #define     SO_EAFNOSUPPORT         (-5)            // Non-supported address family
64 #define     SO_EAGAIN               (-6)            // Posix.1
65 #define     SO_EALREADY             (-7)            // Already in progress
66 #define     SO_EBADF                (-8)            // Bad socket descriptor
67 #define     SO_EBADMSG              (-9)
68 #define     SO_EBUSY                (-10)           // Busy
69 #define     SO_ECANCELED            (-11)
70 #define     SO_ECHILD               (-12)
71 #define     SO_ECONNABORTED         (-13)           // Connection aborted
72 #define     SO_ECONNREFUSED         (-14)           // Connection refused
73 #define     SO_ECONNRESET           (-15)           // Connection reset
74 #define     SO_EDEADLK              (-16)
75 #define     SO_EDESTADDRREQ         (-17)           // Not bound to a local address
76 #define     SO_EDOM                 (-18)
77 #define     SO_EDQUOT               (-19)
78 #define     SO_EEXIST               (-20)
79 #define     SO_EFAULT               (-21)
80 #define     SO_EFBIG                (-22)
81 #define     SO_EHOSTUNREACH         (-23)
82 #define     SO_EIDRM                (-24)
83 #define     SO_EILSEQ               (-25)
84 #define     SO_EINPROGRESS          (-26)           // Still in progress
85 #define     SO_EINTR                (-27)           // Canceled
86 #define     SO_EINVAL               (-28)           // Invalid operation
87 #define     SO_EIO                  (-29)           // I/O error
88 #define     SO_EISCONN              (-30)           // Socket is already connected
89 #define     SO_EISDIR               (-31)
90 #define     SO_ELOOP                (-32)
91 #define     SO_EMFILE               (-33)           // No more socket descriptors
92 #define     SO_EMLINK               (-34)
93 #define     SO_EMSGSIZE             (-35)           // Too large to be sent
94 #define     SO_EMULTIHOP            (-36)
95 #define     SO_ENAMETOOLONG         (-37)
96 #define     SO_ENETDOWN             (-38)
97 #define     SO_ENETRESET            (-39)
98 #define     SO_ENETUNREACH          (-40)           // Unreachable
99 #define     SO_ENFILE               (-41)
100 #define     SO_ENOBUFS              (-42)           // Insufficient resources
101 #define     SO_ENODATA              (-43)
102 #define     SO_ENODEV               (-44)
103 #define     SO_ENOENT               (-45)
104 #define     SO_ENOEXEC              (-46)
105 #define     SO_ENOLCK               (-47)
106 #define     SO_ENOLINK              (-48)           // Network interface is unavailable
107 #define     SO_ENOMEM               (-49)           // Insufficient memory
108 #define     SO_ENOMSG               (-50)
109 #define     SO_ENOPROTOOPT          (-51)           // Non-supported option
110 #define     SO_ENOSPC               (-52)
111 #define     SO_ENOSR                (-53)
112 #define     SO_ENOSTR               (-54)
113 #define     SO_ENOSYS               (-55)
114 #define     SO_ENOTCONN             (-56)           // Not connected
115 #define     SO_ENOTDIR              (-57)
116 #define     SO_ENOTEMPTY            (-58)
117 #define     SO_ENOTSOCK             (-59)           // Not a socket
118 #define     SO_ENOTSUP              (-60)
119 #define     SO_ENOTTY               (-61)
120 #define     SO_ENXIO                (-62)           // Network interface device doesn't exist
121 #define     SO_EOPNOTSUPP           (-63)           // Non-supported operation
122 #define     SO_EOVERFLOW            (-64)
123 #define     SO_EPERM                (-65)
124 #define     SO_EPIPE                (-66)
125 #define     SO_EPROTO               (-67)
126 #define     SO_EPROTONOSUPPORT      (-68)           // Non-supported protocol
127 #define     SO_EPROTOTYPE           (-69)           // Non-supported socket type
128 #define     SO_ERANGE               (-70)
129 #define     SO_EROFS                (-71)
130 #define     SO_ESPIPE               (-72)
131 #define     SO_ESRCH                (-73)
132 #define     SO_ESTALE               (-74)
133 #define     SO_ETIME                (-75)
134 #define     SO_ETIMEDOUT            (-76)           // Timed out
135 #define     SO_ETXTBSY              (-77)
136 #define     SO_EWOULDBLOCK          SO_EAGAIN       // Posix.1g
137 #define     SO_EXDEV                (-78)
138 /* Host configuration error codes */
139 #define     SO_ERR_DHCP_TIMEOUT     (-100)          // Could not find any DHCP server.
140 #define     SO_ERR_DHCP_EXPIRED     (-101)
141 #define     SO_ERR_DHCP_NAK         (-102)
142     /* -103 to -106 are reserved */
143 #define     SO_ERR_LCP              (-107)          // LCP negotiation error
144 #define     SO_ERR_AUTH             (-108)          // Authentication error
145 #define     SO_ERR_IPCP             (-109)          // IPCP negotiation error
146     /* -110 is reserved */
147 #define     SO_ERR_ADDR_COLLISION   (-111)          // Duplicate IP address
148 #define     SO_ERR_LINK_DOWN        (-112)          // Link down
149 /* Connection error codes */
150 #define     SO_ERR_LINK_UP_TIMEOUT  (-121)          // Link-up timeout
151 
152 /* Name for allocator */
153     /* 0 to 9 are reserved */
154 #define     SO_MEM_ADDRINFO         10
155 #define     SO_MEM_RESOLVER         11
156 #define     SO_MEM_IPC              12
157 #define     SO_MEM_RECVFROM         13
158 #define     SO_MEM_SENDTO           14
159 
160 /* SOStartup() timeout default settings */
161 #define SO_STARTUP_TIMEOUT          60000
162 
163 /* Retry count of link-up */
164 #define SO_STARTUP_LINK_UP_RETRY_COUNT  4
165 
166 
167 /*---------------------------------------------------------------------------*
168     Structures
169  *---------------------------------------------------------------------------*/
170 
171 /* Allocator type definition */
172 typedef void*   ( *SOAlloc )    ( u32 name, s32 size );
173 typedef void    ( *SOFree )     ( u32 name, void* ptr, s32 size );
174 /*
175  * Notice !
176  * Allocator must supply 32-byte aligned buffer.
177  */
178 
179 /* Config of SOInit() */
180 typedef struct SOLibraryConfig
181 {
182     SOAlloc     alloc;
183     SOFree      free;
184 
185 } SOLibraryConfig;
186 
187 
188 /*---------------------------------------------------------------------------*
189     Functions
190  *---------------------------------------------------------------------------*/
191 
192 int     SOInit      ( SOLibraryConfig* config );
193 int     SOFinish    ( void );
194 int     SOStartup   ( void );
195 int     SOStartupEx ( int timeOut );
196 int     SOCleanup   ( void );
197 
198 
199 /*===========================================================================*/
200 #ifdef  __cplusplus
201 }       /* extern "C" */
202 #endif
203 #endif  /* REVOLUTION_SO_H_ */
204 
205 /*---------------------------------------------------------------------------*
206   End of file
207  *---------------------------------------------------------------------------*/
208