@@ -107,19 +107,21 @@ typedef struct
107
107
* --------------------------------------------------------------------------------------
108
108
*/
109
109
110
+ /*-------------------------------------------------------------------------------------*/
110
111
/**
111
- * Initialize a socket address structure to hold an address of the given family
112
+ * @brief Initialize a socket address structure to hold an address of the given family
112
113
*
113
114
* The address is set to a suitable default value for the family.
114
115
*
115
- * @param Addr The address buffer to initialize
116
- * @param Domain The address family
116
+ * @param[out] Addr The address buffer to initialize
117
+ * @param[in] Domain The address family
117
118
* @returns OS_SUCCESS if successful
118
119
*/
119
120
int32 OS_SocketAddrInit (OS_SockAddr_t * Addr , OS_SocketDomain_t Domain );
120
121
122
+ /*-------------------------------------------------------------------------------------*/
121
123
/**
122
- * Get a string representation of a network host address
124
+ * @brief Get a string representation of a network host address
123
125
*
124
126
* The specific format of the output string depends on the address family.
125
127
*
@@ -129,15 +131,16 @@ int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain);
129
131
*
130
132
* @note For IPv4, this would typically be the dotted-decimal format (X.X.X.X).
131
133
*
132
- * @param buffer Buffer to hold the output string
133
- * @param buflen Maximum length of the output string
134
- * @param Addr The network address buffer to convert
134
+ * @param[out] buffer Buffer to hold the output string
135
+ * @param[in] buflen Maximum length of the output string
136
+ * @param[in] Addr The network address buffer to convert
135
137
* @returns OS_SUCCESS if successful
136
138
*/
137
139
int32 OS_SocketAddrToString (char * buffer , uint32 buflen , const OS_SockAddr_t * Addr );
138
140
141
+ /*-------------------------------------------------------------------------------------*/
139
142
/**
140
- * Set a network host address from a string representation
143
+ * @brief Set a network host address from a string representation
141
144
*
142
145
* The specific format of the output string depends on the address family.
143
146
*
@@ -150,34 +153,36 @@ int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Ad
150
153
* Since many embedded deployments do not have name services, this should
151
154
* not be relied upon.
152
155
*
153
- * @param Addr The address buffer to initialize
154
- * @param string The string to initialize the address from.
156
+ * @param[out] Addr The address buffer to initialize
157
+ * @param[in] string The string to initialize the address from.
155
158
* @returns OS_SUCCESS if successful
156
159
*/
157
160
int32 OS_SocketAddrFromString (OS_SockAddr_t * Addr , const char * string );
158
161
162
+ /*-------------------------------------------------------------------------------------*/
159
163
/**
160
- * Get the port number of a network address
164
+ * @brief Get the port number of a network address
161
165
*
162
166
* For network prototcols that have the concept of a port number (such
163
167
* as TCP/IP and UDP/IP) this function gets the port number from the
164
168
* address structure.
165
169
*
166
- * @param PortNum Buffer to store the port number
167
- * @param Addr The network address buffer
170
+ * @param[out] PortNum Buffer to store the port number
171
+ * @param[in] Addr The network address buffer
168
172
* @returns OS_SUCCESS if successful
169
173
*/
170
174
int32 OS_SocketAddrGetPort (uint16 * PortNum , const OS_SockAddr_t * Addr );
171
175
176
+ /*-------------------------------------------------------------------------------------*/
172
177
/**
173
- * Get the port number of a network address
178
+ * @brief Set the port number of a network address
174
179
*
175
180
* For network prototcols that have the concept of a port number (such
176
- * as TCP/IP and UDP/IP) this function gets the port number from the
181
+ * as TCP/IP and UDP/IP) this function sets the port number from the
177
182
* address structure.
178
183
*
179
- * @param PortNum Buffer to store the port number
180
- * @param Addr The network address buffer
184
+ * @param[in] PortNum The port number to set
185
+ * @param[out] Addr The network address buffer
181
186
* @returns OS_SUCCESS if successful
182
187
*/
183
188
int32 OS_SocketAddrSetPort (OS_SockAddr_t * Addr , uint16 PortNum );
@@ -202,19 +207,21 @@ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum);
202
207
*/
203
208
204
209
/**
205
- * Opens a socket.
210
+ * @brief Opens a socket.
206
211
*
207
212
* A new, unconnected and unbound socket is allocated of the given domain and type.
208
213
*
209
- * @param sock_id Buffer to hold the OSAL ID
210
- * @param Domain The domain / address family of the socket (INET or INET6, etc)
211
- * @param Type The type of the socket (STREAM or DATAGRAM)
214
+ * @param[out] sock_id Buffer to hold the OSAL ID
215
+ * @param[in] Domain The domain / address family of the socket (INET or INET6, etc)
216
+ * @param[in] Type The type of the socket (STREAM or DATAGRAM)
217
+ *
212
218
* @returns OS_SUCCESS if successful
213
219
*/
214
220
int32 OS_SocketOpen (uint32 * sock_id , OS_SocketDomain_t Domain , OS_SocketType_t Type );
215
221
222
+ /*-------------------------------------------------------------------------------------*/
216
223
/**
217
- * Binds a socket to a given local address.
224
+ * @brief Binds a socket to a given local address.
218
225
*
219
226
* The specified socket will be bound to the local address and port, if available.
220
227
*
@@ -223,28 +230,30 @@ int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t T
223
230
* If the socket is connection-oriented (stream), then this will also put the
224
231
* socket into a listening state for incoming connections at the local address.
225
232
*
226
- * @param sock_id The socket ID
227
- * @param Addr The local address to bind to
233
+ * @param[in] sock_id The socket ID
234
+ * @param[in] Addr The local address to bind to
228
235
* @returns OS_SUCCESS if successful
229
236
*/
230
237
int32 OS_SocketBind (uint32 sock_id , const OS_SockAddr_t * Addr );
231
238
239
+ /*-------------------------------------------------------------------------------------*/
232
240
/**
233
- * Connects a socket to a given remote address.
241
+ * @brief Connects a socket to a given remote address.
234
242
*
235
243
* The socket will be connected to the remote address and port, if available.
236
244
* This only applies to stream-oriented sockets. Calling this on a datagram
237
245
* socket will return an error (these sockets should use SendTo/RecvFrom).
238
246
*
239
- * @param sock_id The socket ID
240
- * @param Addr The remote address to connect to
241
- * @param timeout The maximum amount of time to wait, or OS_PEND to wait forever
247
+ * @param[in] sock_id The socket ID
248
+ * @param[in] Addr The remote address to connect to
249
+ * @param[in] timeout The maximum amount of time to wait, or OS_PEND to wait forever
242
250
* @returns OS_SUCCESS if successful
243
251
*/
244
252
int32 OS_SocketConnect (uint32 sock_id , const OS_SockAddr_t * Addr , int32 timeout );
245
253
254
+ /*-------------------------------------------------------------------------------------*/
246
255
/**
247
- * Waits for and accept the next incoming connection on the given socket
256
+ * @brief Waits for and accept the next incoming connection on the given socket
248
257
*
249
258
* This is used for sockets operating in a "server" role. The socket must be
250
259
* a stream type (connection-oriented) and previously bound to a local address
@@ -254,85 +263,113 @@ int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 timeout)
254
263
* The new stream connection is then returned to the caller and the original
255
264
* server socket ID can be reused for the next connection.
256
265
*
257
- * @param sock_id The server socket ID, previously bound using OS_SocketBind()
258
- * @param connsock_id The connection socket, a new ID that can be read/written
259
- * @param Addr The remote address of the incoming connection
260
- * @param timeout The maximum amount of time to wait, or OS_PEND to wait forever
266
+ * @param[in] sock_id The server socket ID, previously bound using OS_SocketBind()
267
+ * @param[out] connsock_id The connection socket, a new ID that can be read/written
268
+ * @param[in] Addr The remote address of the incoming connection
269
+ * @param[in] timeout The maximum amount of time to wait, or OS_PEND to wait forever
270
+ *
261
271
* @returns OS_SUCCESS if successful
262
272
*/
263
273
int32 OS_SocketAccept (uint32 sock_id , uint32 * connsock_id , OS_SockAddr_t * Addr , int32 timeout );
264
274
275
+ /*-------------------------------------------------------------------------------------*/
265
276
/**
266
- * Reads data from a message-oriented (datagram) socket
277
+ * @brief Reads data from a message-oriented (datagram) socket
267
278
*
268
279
* If a message is already available on the socket, this should immediately return
269
280
* that data without blocking. Otherwise, it may block up to the given timeout.
270
281
*
271
- * @param sock_id The socket ID, previously bound using OS_SocketBind()
272
- * @param buffer Pointer to message data receive buffer
273
- * @param buflen The maximum length of the message data to receive
274
- * @param RemoteAddr Buffer to store the remote network address (may be NULL)
275
- * @param timeout The maximum amount of time to wait, or OS_PEND to wait forever
276
- * @returns OS_SUCCESS if successful
282
+ * @param[in] sock_id The socket ID, previously bound using OS_SocketBind()
283
+ * @param[out] buffer Pointer to message data receive buffer
284
+ * @param[in] buflen The maximum length of the message data to receive
285
+ * @param[out] RemoteAddr Buffer to store the remote network address (may be NULL)
286
+ * @param[in] timeout The maximum amount of time to wait, or OS_PEND to wait forever
287
+ *
288
+ * @returns non-negative count of actual bytes received if successful, or an appropriate error code
277
289
*/
278
290
int32 OS_SocketRecvFrom (uint32 sock_id , void * buffer , uint32 buflen , OS_SockAddr_t * RemoteAddr , int32 timeout );
279
291
292
+ /*-------------------------------------------------------------------------------------*/
280
293
/**
281
- * Sends data to a message-oriented (datagram) socket
294
+ * @brief Sends data to a message-oriented (datagram) socket
282
295
*
283
296
* This sends data in a non-blocking mode. If the socket is not currently able to
284
297
* queue the message, such as if its outbound buffer is full, then this returns
285
298
* an error code.
286
299
*
287
- * @param sock_id The socket ID, which must be of the datagram type
288
- * @param buffer Pointer to message data to send
289
- * @param buflen The length of the message data to send
290
- * @param RemoteAddr Buffer containing the remote network address to send to
291
- * @returns OS_SUCCESS if successful
300
+ * @param[in] sock_id The socket ID, which must be of the datagram type
301
+ * @param[in] buffer Pointer to message data to send
302
+ * @param[in] buflen The length of the message data to send
303
+ * @param[in] RemoteAddr Buffer containing the remote network address to send to
304
+ *
305
+ * @returns non-negative count of actual bytes sent if successful, or an appropriate error code
292
306
*/
293
307
int32 OS_SocketSendTo (uint32 sock_id , const void * buffer , uint32 buflen , const OS_SockAddr_t * RemoteAddr );
294
308
309
+ /*-------------------------------------------------------------------------------------*/
295
310
/**
296
- * Gets an OSAL ID from a given name
311
+ * @brief Gets an OSAL ID from a given name
297
312
*
298
- * OSAL Sockets use generated names according to the address and type.
313
+ * @note OSAL Sockets use generated names according to the address and type.
299
314
*
300
315
* @sa OS_SocketGetInfo()
301
316
*
302
- * @param sock_id Buffer to hold result
303
- * @param sock_name Name of socket to find
304
- * @returns OS_SUCCESS if successful
317
+ * @param[out] sock_id Buffer to hold result
318
+ * @param[in] sock_name Name of socket to find
319
+ *
320
+ * @returns OS_SUCCESS if successful, or appropriate error code
321
+ * OS_INVALID_POINTER is id or name are NULL pointers
322
+ * OS_ERR_NAME_TOO_LONG if the name given is to long to have been stored
323
+ * OS_ERR_NAME_NOT_FOUND if the name was not found in the table
305
324
*/
306
325
int32 OS_SocketGetIdByName (uint32 * sock_id , const char * sock_name );
307
326
327
+ /*-------------------------------------------------------------------------------------*/
308
328
/**
309
- * Gets information about an OSAL Socket ID
329
+ * @brief Gets information about an OSAL Socket ID
310
330
*
311
331
* OSAL Sockets use generated names according to the address and type.
312
332
* This allows applications to find the name of a given socket.
313
333
*
314
- * @param sock_id The socket ID
315
- * @param sock_prop Buffer to hold socket information
316
- * @returns OS_SUCCESS if successful
334
+ * @param[in] sock_id The socket ID
335
+ * @param[out] sock_prop Buffer to hold socket information
336
+ *
337
+ * @returns OS_SUCCESS if successful, or appropriate error code
338
+ * OS_ERR_INVALID_ID if the id passed in is not a valid semaphore
339
+ * OS_INVALID_POINTER if the count_prop pointer is null
317
340
*/
318
341
int32 OS_SocketGetInfo (uint32 sock_id , OS_socket_prop_t * sock_prop );
319
342
320
343
321
- /*
322
- ** OS_NetworkGetID is currently [[deprecated]] as its behavior is
323
- ** unknown and not consistent across operating systems.
324
- */
344
+ /*-------------------------------------------------------------------------------------*/
345
+ /**
346
+ * @brief Gets the network ID of the local machine
347
+ *
348
+ * The ID is an implementation-defined value and may not be consistent
349
+ * in meaning across different platform types.
350
+ *
351
+ * @note this API may be removed in a future version of OSAL due to
352
+ * inconsistencies between platforms.
353
+ *
354
+ * @returns The ID or fixed value of -1 if the host id could not be found
355
+ *
356
+ * Note it is not possible to differentiate between error codes and valid
357
+ * network IDs here. It is assumed, however, that -1 is never a valid ID.
358
+ *
359
+ */
325
360
int32 OS_NetworkGetID (void );
326
361
327
362
363
+ /*-------------------------------------------------------------------------------------*/
328
364
/**
329
- * Gets the local machine network host name
365
+ * @brief Gets the local machine network host name
330
366
*
331
367
* If configured in the underlying network stack,
332
368
* this function retrieves the local hostname of the system.
333
369
*
334
- * @param host_name Buffer to hold name information
335
- * @param name_len Maximum length of host name buffer
370
+ * @param[out] host_name Buffer to hold name information
371
+ * @param[in] name_len Maximum length of host name buffer
372
+ *
336
373
* @returns OS_SUCCESS if successful
337
374
*/
338
375
int32 OS_NetworkGetHostName (char * host_name , uint32 name_len );
0 commit comments