comparison src/g23m-fad/tcpip/rnet/rnet_rt/rnet_rt_api_bind.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_bind.c
3 *
4 * RNET_RT API
5 *
6 * @author Regis Feneon
7 * @version 0.1
8 */
9
10 /*
11 * $Id: rnet_rt_api_bind.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 * Binds the connection to a local IP address and port number.
32 *
33 * @param desc Connection identifier [IN].
34 * @param local_addr Local IP address
35 * The IP address can be specified as RNET_IP_ADDR_ANY
36 * in order to bind the connection to all local IP addresses [IN].
37 * @param local_port If the port is not specified, the allocation of a port
38 * is done automatically by the system [IN].
39 * @return RNET_IN_USE Another connection bound to the same address/port.
40 * RNET_NOT_INITIALIZED NET subsystem not initialized (internal error).
41 * RNET_INTERNAL_ERR Network subsystem failed.
42 * RNET_INVALID_PARAMETER Invalid connection ID.
43 * or Specified address not a valid address
44 * RNET_NOT_READY Still processing a callback function.
45 * RNET_MEMORY_ERR Not enough buffers available, too many connections.
46 * RNET_OK Connection successfully bound.
47 */
48
49 T_RNET_RET rnet_rt_bind (T_RNET_DESC * desc,
50 T_RNET_IP_ADDR local_addr,
51 T_RNET_PORT local_port)
52 {
53 NGsockaddr addr;
54 int err;
55
56 /* convert address to network-byte order */
57 addr.sin_port = ngHTONS( local_port);
58 addr.sin_addr = ngHTONL( local_addr);
59
60 /* bind local address & port */
61 rvf_lock_mutex( &rnet_rt_env_ctrl_blk_p->mutex);
62 err = ngSAIOBind( (NGsock *) desc, &addr);
63 rvf_unlock_mutex( &rnet_rt_env_ctrl_blk_p->mutex);
64
65 return( rnet_rt_ngip_error( err));
66 }
67
68 #endif /* ifdef RNET_CFG_REAL_TRANSPORT */
69