FreeCalypso > hg > fc-selenite
comparison src/g23m-fad/tcpip/rnet/rnet_rt/rnet_rt_api_getproto.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_getproto.c | |
3 * | |
4 * RNET_RT API | |
5 * | |
6 * @author Regis Feneon | |
7 * @version 0.1 | |
8 */ | |
9 | |
10 /* | |
11 * $Id: rnet_rt_api_getproto.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/29/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 * Retrieves the protocol associated to a connection descriptor. | |
32 * The protocol is retrieved with the SO_TYPE socket option. | |
33 * | |
34 * @param desc Connection identifier. | |
35 * @return A value of the T_RNET_IPPROTO enumeration. | |
36 */ | |
37 | |
38 T_RNET_IPPROTO rnet_rt_get_proto (T_RNET_DESC *desc) | |
39 { | |
40 int err, len, type; | |
41 | |
42 len = sizeof( type); | |
43 | |
44 /* get type of socket */ | |
45 rvf_lock_mutex( &rnet_rt_env_ctrl_blk_p->mutex); | |
46 err = ngSAIOGetOption( (NGsock *) desc, NG_IOCTL_SOCKET, NG_SO_TYPE, | |
47 &type, &len); | |
48 rvf_unlock_mutex( &rnet_rt_env_ctrl_blk_p->mutex); | |
49 | |
50 if( err == NG_EOK) { | |
51 switch( type) { | |
52 case NG_SOCK_STREAM: | |
53 return( RNET_IPPROTO_TCP); | |
54 case NG_SOCK_DGRAM: | |
55 return( RNET_IPPROTO_UDP); | |
56 default: | |
57 break; | |
58 } | |
59 } | |
60 | |
61 /* should not happen... */ | |
62 return( RNET_IPPROTO_UNDEFINED); | |
63 } | |
64 | |
65 #endif /* ifdef RNET_CFG_REAL_TRANSPORT */ | |
66 |