comparison src/g23m-fad/tcpip/rnet/rnet_rt/rnet_rt_api_getbufsize.c @ 174:90eb61ecd093

src/g23m-fad: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Oct 2016 05:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
173:bf64d785238a 174:90eb61ecd093
1 /**
2 * @file rnet_rt_api_getbufsize.c
3 *
4 * RNET_RT API
5 *
6 * @author Regis Feneon
7 * @version 0.1
8 */
9
10 /*
11 * $Id: rnet_rt_api_getbufsize.c,v 1.3 2002/10/30 15:23:34 rf Exp $
12 * $Name: ti_20021030 $
13 *
14 * History:
15 *
16 * Date Author Modification
17 * --------------------------------------------------
18 * 3/22/2002 Regis Feneon Create
19 *
20 * (C) Copyright 2002 by TI, All Rights Reserved
21 *
22 */
23
24 #include "rnet_cfg.h"
25 #ifdef RNET_CFG_REAL_TRANSPORT
26
27 #include "rnet_rt_i.h"
28 #include "rnet_rt_env.h"
29
30 /**
31 * Use to determine the amount of data pending in the network's input buffer
32 * that can be read from the connection ID.
33 *
34 * If desc is stream oriented (TCP), returns the amount of data that can be read
35 * in a single call to the rnet_recv function; this might not be the same as the
36 * total amount of data queued on the socket.
37 * If desc is message oriented (UDP), returns the size of the first datagram
38 * (message) queued on the socket.
39 *
40 * Use the socket option SO_NREAD.
41 *
42 * @param desc Connection identifier [IN].
43 * @param size_p Pointer to an unsigned int in which the result is stored [OUT].
44 * @return RNET_NOT_INITIALIZED NET subsystem not initialized (internal error).
45 * RNET_INTERNAL_ERR Network subsystem failed.
46 * RNET_INVALID_PARAMETER The connection ID is invalid.
47 * RNET_NOT_READY Still processing a callback function.
48 * RNET_OK Value successfully get.
49 */
50
51 T_RNET_RET rnet_rt_get_buff_size (T_RNET_DESC * desc,
52 UINT32 * size_p)
53 {
54 int err, len, nread;
55
56 len = sizeof( nread);
57
58 /* get number of bytes in receive buffer */
59 rvf_lock_mutex( &rnet_rt_env_ctrl_blk_p->mutex);
60 err = ngSAIOGetOption( (NGsock *) desc, NG_IOCTL_SOCKET, NG_SO_NREAD,
61 &nread, &len);
62 rvf_unlock_mutex( &rnet_rt_env_ctrl_blk_p->mutex);
63
64 if( err == NG_EOK) {
65 *size_p = nread;
66 return( RNET_OK);
67 }
68
69 return( rnet_rt_ngip_error( err));
70 }
71
72 #endif /* ifdef RNET_CFG_REAL_TRANSPORT */
73