comparison src/g23m-fad/tcpip/rnet/rnet_rt/rnet_rt_api_getlocaladdr.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
1 /**
2 * @file rnet_rt_api_getlocaladdr.c
3 *
4 * RNET_RT API
5 *
6 * @author Regis Feneon
7 * @version 0.1
8 */
9
10 /*
11 * $Id: rnet_rt_api_getlocaladdr.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 * Gets the local address and port of a connection ID.
32 *
33 * @param desc Connection identifier [IN].
34 * @param local_addr_p Local IP address [OUT].
35 * @param local_port_p Local port [OUT].
36 * @return RNET_NOT_INITIALIZED NET subsystem not initialized (internal error).
37 * RNET_INTERNAL_ERR Network subsystem failed.
38 * RNET_INVALID_PARAMETER The connection ID is invalid.
39 * or Not bound to an address with bind.
40 * or ADDR_ANY is specified in bind but connection not yet occurred.
41 * RNET_NOT_READY Still processing a callback function.
42 * RNET_OK Local address/port successfully get.
43 */
44
45 T_RNET_RET rnet_rt_get_local_addr_port (T_RNET_DESC * desc,
46 T_RNET_IP_ADDR * local_addr_p,
47 T_RNET_PORT * local_port_p)
48 {
49 int err, len;
50 NGsockaddr addr;
51
52 len = sizeof( addr);
53
54 /* get socket name */
55 rvf_lock_mutex( &rnet_rt_env_ctrl_blk_p->mutex);
56 err = ngSAIOGetOption( (NGsock *) desc, NG_IOCTL_SOCKET, NG_SO_SOCKNAME,
57 &addr, &len);
58 rvf_unlock_mutex( &rnet_rt_env_ctrl_blk_p->mutex);
59
60 if( err == NG_EOK) {
61 *local_addr_p = ngNTOHL( addr.sin_addr);
62 *local_port_p = ngNTOHS( addr.sin_port);
63 return( RNET_OK);
64 }
65
66 return( rnet_rt_ngip_error( err));
67 }
68
69 #endif /* ifdef RNET_CFG_REAL_TRANSPORT */
70