PageRenderTime 57ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/peek-build/m23/g23m/condat/com/include/socket_api.h

https://bitbucket.org/C0deMaver1ck/peeklinux
C Header | 854 lines | 269 code | 103 blank | 482 comment | 0 complexity | c31a41bb71f29e20b6bd3c89513bf047 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0
  1. /*
  2. +------------------------------------------------------------------------------
  3. | File: socket.h
  4. +------------------------------------------------------------------------------
  5. | Copyright 2002 Texas Instruments Berlin, AG
  6. | All rights reserved.
  7. |
  8. | This file is confidential and a trade secret of Texas
  9. | Instruments Berlin, AG
  10. | The receipt of or possession of this file does not convey
  11. | any rights to reproduce or disclose its contents or to
  12. | manufacture, use, or sell anything it may describe, in
  13. | whole, or in part, without the specific written consent of
  14. | Texas Instruments Berlin, AG.
  15. +-----------------------------------------------------------------------------
  16. | Purpose : This file implements the socket specific definitions to be used by applications in order to
  17. | set up a connection(GPRS or CSD) or create sockets for data receiption.
  18. | For a description of the socket API read g23m\condat\doc\8462_601.doc
  19. +-----------------------------------------------------------------------------
  20. */
  21. #ifndef __SOCKET_H__
  22. #define __SOCKET_H__
  23. #include "typedefs.h"
  24. #include "vsi.h"
  25. #include "gsm.h"
  26. #include "prim.h" // to get the DCM defines
  27. /***************** Defines added for TCPIP testing with the application. ***********/
  28. /*
  29. * Value constants for VAL_bearer_select
  30. */
  31. #define DCM_SOCK_BEARER_ANY (0x1) /* DCM will decide which connection type to be used */
  32. #define DCM_SOCK_BEARER_GPRS (0x2) /* Use a GPRS context as bearer, DCM will decide which GPRS settings to be used */
  33. #define DCM_SOCK_BEARER_GSM (0x3) /* Use GSM data connection as bearer DCM will decide which GSM settings to be used */
  34. #define DCM_SOCK_BEARER_USE_PROFILE (0x4) /* Use a specific data account for this connection */
  35. #define DCM_SOCK_BEARER_AS_SPECIFIED (0x5) /* Use the data account information which is which is delivered within this signal */
  36. /*
  37. * Value constants for VAL_authtype
  38. */
  39. #define DCM_SOCK_AUTH_PAP (0x1) /* PAP authentification protocol */
  40. #define DCM_SOCK_AUTH_CHAP (0x2) /* CHAP authentification protocol !!! NOT SUPPORTED */
  41. #define DCM_SOCK_AUTH_NO (0x3) /* No authentication */
  42. /*
  43. * user defined constants
  44. */
  45. #define CDCM_APN_MAX_LEN (0x64)
  46. #define CDCM_PHONE_NR_LEN (0x54)
  47. #define CDCM_USER_MAX_LEN (0x19)
  48. #define CDCM_PASSWORD_MAX_LEN (0x19)
  49. /************************************************************************************/
  50. /*
  51. * Maximum length of the full-qualified domain name of an Internet host
  52. */
  53. #define SOCK_MAXHOSTNAMELEN 255
  54. /* Maximum length (in octets) of a GPRS Access Point Name (APN). */
  55. #define SOCK_MAX_APN_LEN CDCM_APN_MAX_LEN
  56. /* Maximum length (in octets) of a telephone number. */
  57. #define SOCK_MAX_PHONENUM_LEN CDCM_PHONE_NR_LEN
  58. /* Maximum length (in octets) of a user id. */
  59. #define SOCK_MAX_USERID_LEN CDCM_USER_MAX_LEN
  60. /* Maximum length (in octets) of a user password. */
  61. #define SOCK_MAX_PASSWORD_LEN CDCM_PASSWORD_MAX_LEN
  62. /*
  63. * Type of an IP protocol
  64. * The values of this type are used as the 'ipproto' argument when creating
  65. * a socket to specify if a UDP socket or a TCP socket shall be created.
  66. */
  67. typedef enum {
  68. SOCK_IPPROTO_TCP = 6,
  69. SOCK_IPPROTO_UDP = 17
  70. } T_SOCK_IPPROTO;
  71. /*
  72. * Type of a socket descriptor
  73. */
  74. typedef unsigned long T_SOCK_SOCKET;
  75. /*
  76. * Type of an API instance
  77. */
  78. typedef unsigned long T_SOCK_API_INSTANCE;
  79. /*
  80. * Type of an IP version 4 addresses in network byte order
  81. */
  82. typedef unsigned long T_SOCK_IPADDR;
  83. #define SOCK_IPADDR_ANY (T_SOCK_IPADDR)0 /* Unspecified IP address */
  84. /*
  85. * UDP or TCP port number in network byte order
  86. */
  87. typedef unsigned short T_SOCK_PORT;
  88. #define SOCK_PORT_ANY (T_SOCK_PORT)0 /* Unspecified port number */
  89. /*
  90. * Convert U32 value from host byte order to network byte order
  91. */
  92. #define SOCK_HTONL( x ) \
  93. ((U32)((((U32)( x ) & 0x000000ffU) << 24) | \
  94. (((U32)( x ) & 0x0000ff00U) << 8) | \
  95. (((U32)( x ) & 0x00ff0000U) >> 8) | \
  96. (((U32)( x ) & 0xff000000U) >> 24)))
  97. /*
  98. * Convert U16 value from host byte order to network byte order
  99. */
  100. #define SOCK_HTONS( x ) \
  101. ((U16)((((U16)( x ) & 0x00ff) << 8) | \
  102. (((U16)( x ) & 0xff00) >> 8)))
  103. /*
  104. * Convert U32 value from network byte order to host byte order
  105. */
  106. #define SOCK_NTOHL( x ) \
  107. ((U32)((((U32)( x ) & 0x000000ffU) << 24) | \
  108. (((U32)( x ) & 0x0000ff00U) << 8) | \
  109. (((U32)( x ) & 0x00ff0000U) >> 8) | \
  110. (((U32)( x ) & 0xff000000U) >> 24)))
  111. /*
  112. * Convert U16 value from network byte order to host byte order
  113. */
  114. #define SOCK_NTOHS( x ) \
  115. ((U16)((((U16)( x ) & 0x00ff) << 8) | \
  116. (((U16)( x ) & 0xff00) >> 8)))
  117. /*
  118. * Construct IP address in network byte order from single octets.
  119. */
  120. #define SOCK_MK_IPADDR( a, b, c, d ) \
  121. ((T_SOCK_IPADDR)((a << 24) | (b << 16) | (c << 8) | d))
  122. /*
  123. * Type of a Socket API event
  124. */
  125. typedef enum {
  126. SOCK_CREATE_CNF = 1, /* Result event of sock_create() */
  127. SOCK_CLOSE_CNF = 2, /* Result event of sock_close() */
  128. SOCK_BIND_CNF = 3, /* Result event of sock_bind() */
  129. SOCK_LISTEN_CNF = 4, /* Result event of sock_listen() */
  130. SOCK_CONNECT_CNF = 5, /* Result event of sock_connect() */
  131. SOCK_SOCKNAME_CNF = 6, /* Result event of sock_getsockname() */
  132. SOCK_PEERNAME_CNF = 7, /* Result event of sock_getpeername() */
  133. SOCK_HOSTINFO_CNF = 8, /* Result event of sock_gethostbyname() or sock_gethostbyaddr() */
  134. SOCK_MTU_SIZE_CNF = 9, /* Result event of sock_get_mtu_size() */
  135. SOCK_RECV_IND = 10, /* Network event: data has been received */
  136. SOCK_CONNECT_IND = 11, /* Network event: an incoming connection has been accepted. */
  137. SOCK_CONN_CLOSED_IND = 12, /* Network event: connection has been closed by the remote peer */
  138. SOCK_ERROR_IND = 13, /* Network event: an asynchronous error has occurred */
  139. SOCK_FLOW_READY_IND = 14, /* Flow control: the API is ready to send data again */
  140. SOCK_OPEN_BEARER_CNF, // Result Event of sock_open_bearer()
  141. SOCK_CLOSE_BEARER_CNF, // Result event of sock_close_bearer()
  142. SOCK_BEARER_INFO_CNF, // Result event of sock_bearer_info()
  143. SOCK_BAERER_CLOSED_IND // The bearer connection has been closed
  144. } T_SOCK_EVENTTYPE;
  145. /*
  146. * Result codes of the API functions to indicate success or an error condition.
  147. * This type is used as the result code of the function and as the result value
  148. * in the associated event. It is also used for the error codes of a
  149. * 'SOCK_ERROR_IND' event
  150. */
  151. typedef enum {
  152. SOCK_RESULT_OK = 0, /* No problem detected. a corresponding primitive has been sent to the TCP/IP entity */
  153. SOCK_RESULT_INVALID_PARAMETER = 1, /* A parameter given to the function is invalid */
  154. SOCK_RESULT_INTERNAL_ERROR = 2, /* An internal error has happened */
  155. SOCK_RESULT_ADDR_IN_USE = 3, /* The address or port is already in use */
  156. SOCK_RESULT_OUT_OF_MEMORY = 4, /* There is not enough memory to fulfill the request */
  157. SOCK_RESULT_NOT_SUPPORTED = 5, /* The socket is not of a type that can support this operation */
  158. SOCK_RESULT_UNREACHABLE = 6, /* The specified host cannot be reached */
  159. SOCK_RESULT_CONN_REFUSED = 7, /* The connection to the specified address was refused by the remote host */
  160. SOCK_RESULT_TIMEOUT = 8, /* The connection attempt timed out without establishing a connection */
  161. SOCK_RESULT_IS_CONNECTED = 9, /* The request could not be fulfilled because the socket is already connected */
  162. SOCK_RESULT_HOST_NOT_FOUND = 10, /* The specified host could not be found in the DNS */
  163. SOCK_RESULT_DNS_TEMP_ERROR = 11, /* A temporary DNS error has occurred. Retrying the query may be successful */
  164. SOCK_RESULT_DNS_PERM_ERROR = 12, /* A permanent DNS error has occurred */
  165. SOCK_RESULT_NO_IPADDR = 13, /* The specified name has been found in the DNS, but no IP address is available */
  166. SOCK_RESULT_NOT_CONNECTED = 14, /* The socket has not been connected yet */
  167. SOCK_RESULT_MSG_TOO_BIG = 15, /* The size of the data buffer is too large for a UDP socket */
  168. SOCK_RESULT_CONN_RESET = 16, /* The connection has been reset by the remote peer */
  169. SOCK_RESULT_CONN_ABORTED = 17, /* The connection was aborted due to timeout or some other error condition */
  170. SOCK_RESULT_NO_BUFSPACE = 18, /* Sending failed temporarily because the space to buffer the message was exhausted. */
  171. SOCK_RESULT_NETWORK_LOST, // As a result code: The operation failed because TCP/IP's bearer connection has been disconnected.As an asynchronous event code: The bearer connection has been closed.
  172. SOCK_RESULT_NOT_READY, // The operation failed because the bearer connection has not been opened.
  173. SOCK_RESULT_BEARER_NOT_READY, // The bearer connection could not be opened because the mobile is not yet completely attached to the network. A retry at a later time may be successful.
  174. SOCK_RESULT_IN_PROGRESS, // The operation failed because a similar operation is already in progress.
  175. SOCK_RESULT_BEARER_ACTIVE// The operation failed because a bearer connection is already open.
  176. } T_SOCK_RESULT;
  177. /* Type of the bearer_select parameter of sock_open_bearer(), used to select the
  178. * type of the bearer connection to be opened by the Data Connection Manager
  179. * (DCM), and of the bearer_type field of the T_SOCK_BEARER_INFO struct.
  180. */
  181. typedef enum {
  182. SOCK_BEARER_ANY = DCM_SOCK_BEARER_ANY,
  183. SOCK_BEARER_GPRS = DCM_SOCK_BEARER_GPRS,
  184. SOCK_BEARER_GSM = DCM_SOCK_BEARER_GSM,
  185. SOCK_BEARER_USE_PROFILE = DCM_SOCK_BEARER_USE_PROFILE,
  186. SOCK_BEARER_AS_SPECIFIED = DCM_SOCK_BEARER_AS_SPECIFIED
  187. } T_SOCK_BEARER_TYPE;
  188. // FST: ?????
  189. typedef enum {
  190. SOCK_AUTH_PAP = DCM_SOCK_AUTH_PAP,
  191. SOCK_AUTH_CHAP = DCM_SOCK_AUTH_CHAP,
  192. SOCK_AUTH_NO= DCM_SOCK_AUTH_NO
  193. } T_SOCK_AUTHTYPE;
  194. /*
  195. * Type of the generic event data structure passed
  196. * to the callback function on an event.
  197. * The actual event structure may be bigger(depending on its type),
  198. * but it will contain these fields at the beginning
  199. */
  200. typedef struct {
  201. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  202. T_SOCK_RESULT result; /* Result code of the operation */
  203. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  204. } T_SOCK_EVENTSTRUCT;
  205. /*
  206. * Pointer to the callback function specified by the application
  207. */
  208. typedef void (*T_SOCK_CALLBACK)(T_SOCK_EVENTSTRUCT* event, void *context);
  209. /* System wide handle of a bearer connection.
  210. * Variables of this type are used as handles to identify a bearer connection.
  211. * !! NOT NEEDED FOR CURRENT IMPLEMENTATION ONLY MENTIONED FOR FUTURE SUPPOSE.!!
  212. */
  213. typedef U16 T_SOCK_BEARER_HANDLE;
  214. typedef struct {
  215. T_SOCK_BEARER_HANDLE bearer_handle;
  216. T_HANDLE app_handle;
  217. T_SOCK_BEARER_TYPE bearer_type;
  218. BOOL apn_valid;
  219. char apn[SOCK_MAX_APN_LEN+1];
  220. BOOL phone_nr_valid;
  221. char phone_nr[SOCK_MAX_PHONENUM_LEN+1];
  222. BOOL user_id_valid;
  223. char user_id[SOCK_MAX_USERID_LEN+1];
  224. BOOL password_valid;
  225. char password[SOCK_MAX_PASSWORD_LEN+1];
  226. int cid;
  227. T_SOCK_IPADDR ip_address;
  228. T_SOCK_IPADDR dns1;
  229. T_SOCK_IPADDR dns2;
  230. T_SOCK_IPADDR gateway;
  231. T_SOCK_AUTHTYPE authtype;
  232. BOOL data_compr;
  233. BOOL header_comp;
  234. int precedence;
  235. int delay;
  236. int reliability;
  237. int peak_throughput;
  238. int mean_througput;
  239. BOOL shareable;
  240. } T_SOCK_BEARER_INFO;
  241. /* ========================================================================== */
  242. /* ============================== Result Events from TCPIP ================= */
  243. typedef struct {
  244. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  245. T_SOCK_RESULT result; /* Result code of the operation */
  246. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  247. T_SOCK_BEARER_HANDLE bearer_handle;
  248. } T_SOCK_OPEN_BEARER_CNF;
  249. typedef T_SOCK_EVENTSTRUCT T_SOCK_CLOSE_BEARER_CNF;
  250. typedef struct {
  251. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  252. T_SOCK_RESULT result; /* Result code of the operation */
  253. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  254. T_SOCK_BEARER_INFO bearer_params;
  255. } T_SOCK_BEARER_INFO_CNF;
  256. typedef struct {
  257. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  258. T_SOCK_RESULT result; /* Result code of the operation */
  259. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  260. U32 dcm_error; /* The parameter contains errors received from
  261. * PS (ETSI Spec 07.07) */
  262. } T_SOCK_BAERER_CLOSED_IND;
  263. typedef struct {
  264. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  265. T_SOCK_RESULT result; /* Result code of the operation */
  266. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  267. } T_SOCK_CREATE_CNF;
  268. typedef T_SOCK_EVENTSTRUCT T_SOCK_CLOSE_CNF;
  269. typedef T_SOCK_EVENTSTRUCT T_SOCK_BIND_CNF;
  270. typedef T_SOCK_EVENTSTRUCT T_SOCK_LISTEN_CNF;
  271. typedef T_SOCK_EVENTSTRUCT T_SOCK_CONNECT_CNF;
  272. typedef struct {
  273. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  274. T_SOCK_RESULT result; /* Result code of the operation */
  275. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  276. T_SOCK_IPADDR ipaddr; /* The local IP address of the socket */
  277. T_SOCK_PORT port; /* The local port number of the socket */
  278. } T_SOCK_SOCKNAME_CNF;
  279. typedef T_SOCK_SOCKNAME_CNF T_SOCK_PEERNAME_CNF;
  280. typedef struct {
  281. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  282. T_SOCK_RESULT result; /* Result code of the operation */
  283. T_SOCK_SOCKET socket; /* unused */
  284. char hostname[SOCK_MAXHOSTNAMELEN+1]; /* The name of the host as
  285. a zero-terminated string */
  286. T_SOCK_IPADDR ipaddr; /* The local IP address of the socket */
  287. } T_SOCK_HOSTINFO_CNF;
  288. typedef struct {
  289. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  290. T_SOCK_RESULT result; /* Result code of the operation */
  291. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  292. U16 mtu_size; /* MTU size */
  293. } T_SOCK_MTU_SIZE_CNF;
  294. typedef struct {
  295. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  296. T_SOCK_RESULT result; /* Result code of the operation */
  297. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  298. U32 data_length; /* Length of the data portion received. */
  299. char *data_buffer; /* Pointer to the data received. The application
  300. shall free this data buffer after use. */
  301. } T_SOCK_RECV_IND;
  302. typedef struct {
  303. T_SOCK_EVENTTYPE event_type; /* Type of the event. */
  304. T_SOCK_RESULT result; /* Result code of the operation */
  305. T_SOCK_SOCKET socket; /* Socket for which the event occurred */
  306. T_SOCK_SOCKET new_socket; /* New socket allocated for the connection. */
  307. T_SOCK_IPADDR peer_ipaddr; /* IP address of the remote peer. */
  308. T_SOCK_PORT peer_port; /* Port number on the remote side. */
  309. } T_SOCK_CONNECT_IND;
  310. typedef T_SOCK_EVENTSTRUCT T_SOCK_CONN_CLOSED_IND;
  311. typedef T_SOCK_EVENTSTRUCT T_SOCK_ERROR_IND;
  312. typedef T_SOCK_EVENTSTRUCT T_SOCK_FLOW_READY_IND;
  313. /* ========================================================================== */
  314. /* ================== Prototypes of socket API ============================== */
  315. /* ******************* API administrative functions ************************* */
  316. /*------------------------------------------------------------------------------
  317. Function : sock_api_initialize
  318. Parameter : - T_SOCK_API_INSTANCE * :
  319. 'The function returns an API instance value. The value is needed
  320. for several API functions.'
  321. - T_HANDLE :
  322. 'Application task handle as passed to pei_init()'
  323. - char* :
  324. 'Name of the application entity as used with vsi_c_open().'
  325. Return : The function returns TRUE if the initialization was successful.
  326. Description : Initializes the socket interface API.
  327. ------------------------------------------------------------------------------*/
  328. BOOL sock_api_initialize(T_SOCK_API_INSTANCE *api_instance,
  329. T_HANDLE app_handle,
  330. char* app_name);
  331. /*------------------------------------------------------------------------------
  332. Function : sock_api_deinitialize
  333. Parameter : - T_SOCK_API_INSTANCE :
  334. 'API instance value.'
  335. Return : None
  336. Description : Deinitializes the socket interface API. The function releases
  337. all associated memory.
  338. ------------------------------------------------------------------------------*/
  339. void sock_api_deinitialize(T_SOCK_API_INSTANCE api_instance);
  340. /*------------------------------------------------------------------------------
  341. Function : sock_api_handles_primitive
  342. Parameter : - T_SOCK_API_INSTANCE: API instance value
  343. - T_PRIM: Pointer to primitive received from
  344. the primitive queue'
  345. Return : The function returns TRUE if the primitive has been handled by
  346. this function.In this case the application should not do
  347. anything else with the primitive and should not call PFREE()
  348. to free the memory block used for the primitive.
  349. The function returns FALSE if the primitive has not been
  350. handled by this function. In this case the application should
  351. process the primitive as usual.
  352. Description : Handles primitives for the socket API.
  353. To free the application from the handling of the event
  354. primitives sent by the TCP/IP entity, the Socket API provides
  355. this function that checks if a primitive is to be handled by
  356. the Socket API and if it is, handles it. The application is
  357. supposed to call it immediately after receiving a primitive.
  358. If the primitive is meant for the Socket API, it is handled by
  359. this function. This will in most cases include calling the
  360. callback function supplied by the application to deliver an
  361. event. If the primitive is not meant for the Socket API,
  362. no action is taken.
  363. It is recommended to call this function early in the
  364. application entity's pei_primitive() function.
  365. ------------------------------------------------------------------------------*/
  366. BOOL sock_api_handles_primitive(T_SOCK_API_INSTANCE api_instance,
  367. T_PRIM *prim);
  368. /* ******************* Bearer related functions ***************************** */
  369. /*------------------------------------------------------------------------------
  370. Function : sock_open_bearer()
  371. Parameter : - T_SOCK_API_INSTANCE: API instance value
  372. - T_SOCK_BEARER_TYPE : CSD or GPRS
  373. - int: Number of the selected profile with a bearer
  374. selection of SOCK_BEARER_USE_PROFILE.
  375. Unused in other cases.
  376. - T_SOCK_BEARER_INFO: requested parameters of the bearer connection
  377. - T_SOCK_CALLBACK: callback function to be called for return events.
  378. - void*: An arbitrary pointer to be passed to the
  379. callback function when it is called
  380. Return : T_SOCK_RESULT indicates successor a problem that happend
  381. Return Event : T_SOCK_OPEN_BEARER_CNF
  382. Description : Opens a CSD or GPRS connection for use with TCP/IP.
  383. This function a bearer connection for use with TCP/IP. It must be
  384. called after sock_api_initialize() and before any other
  385. TCP/IP-related functions.
  386. ------------------------------------------------------------------------------*/
  387. T_SOCK_RESULT sock_open_bearer(T_SOCK_API_INSTANCE api_instance,
  388. T_SOCK_BEARER_TYPE bearer_select,
  389. int profile_number,
  390. T_SOCK_BEARER_INFO *params,
  391. T_SOCK_CALLBACK sock_cb,
  392. void *context);
  393. /*------------------------------------------------------------------------------
  394. Function : sock_close_bearer()
  395. Parameter : - T_SOCK_API_INSTANCE : API instance value
  396. - T_SOCK_BEARER_HANDLE: returned by SOCK_OPEN_BEARER_CNF
  397. - T_SOCK_CALLBACK: Callback function to be called for return events.
  398. - void*: An arbitrary pointer to be passed to the
  399. callback function when it is called
  400. Return : T_SOCK_RESULT indicates successor a problem that happend
  401. Return Event : T_SOCK_CLOSE_BEARER_CNF
  402. Description : Close a bearer connection that has been opened with sock_open_bearer().
  403. ------------------------------------------------------------------------------*/
  404. T_SOCK_RESULT sock_close_bearer(T_SOCK_API_INSTANCE api_instance,
  405. T_SOCK_BEARER_HANDLE bearer_handle,
  406. T_SOCK_CALLBACK sock_cb,
  407. void *context);
  408. /*------------------------------------------------------------------------------
  409. Function : sock_bearer_info()
  410. Parameter : - T_SOCK_API_INSTANCE: API instance value
  411. - T_SOCK_BEARER_HANDLE: returned by SOCK_OPEN_BEARER_CNF
  412. - T_SOCK_CALLBACK: Callback function to be called for
  413. return events.
  414. - void*: An arbitrary pointer to be passed to the
  415. callback function when it is called
  416. Return : T_SOCK_RESULT
  417. Return Event : T_SOCK_BEARER_INFO_CNF
  418. Description : Get information about a bearer connection that has been opened
  419. with sock_open_bearer().
  420. ------------------------------------------------------------------------------*/
  421. T_SOCK_RESULT sock_bearer_info(T_SOCK_API_INSTANCE api_instance,
  422. T_SOCK_BEARER_HANDLE bearer_handle,
  423. T_SOCK_CALLBACK sock_cb,
  424. void *context);
  425. /* ******************* Socket related functions ***************************** */
  426. /*------------------------------------------------------------------------------
  427. Function : sock_create
  428. Parameter : - T_SOCK_API_INSTANCE :
  429. 'API instance value.'
  430. - T_SOCK_IPPROTO :
  431. 'The protocol (UDP or TCP) to be used with this socket'
  432. - T_SOCK_CALLBACK :
  433. 'The callback function to be called for events on this socket'
  434. - void * :
  435. 'An arbitrary pointer to be passed to
  436. the callback function when it is called'
  437. Return : (T_SOCK_RESULT)
  438. Return Event : 'SOCK_CREATE_CNF'
  439. - T_SOCK_RESULT : Result code
  440. - T_SOCK_SOCKET : The socket descriptor returned by the TCP/IP entity
  441. Description : - Create a new UDP or TCP socket
  442. - This function creates a socket that can subsequently be used with
  443. the other Socket API functions
  444. ------------------------------------------------------------------------------*/
  445. T_SOCK_RESULT sock_create(T_SOCK_API_INSTANCE api_instance,
  446. T_SOCK_IPPROTO ipproto,
  447. T_SOCK_CALLBACK callback,
  448. void *context);
  449. /*------------------------------------------------------------------------------
  450. Function : sock_close
  451. Parameter : - T_SOCK_SOCKET :
  452. 'The socket descriptor to be closed'
  453. Return : (T_SOCK_RESULT)
  454. Return Event : 'SOCK_CLOSE_CNF'
  455. - T_SOCK_RESULT : Result code
  456. - T_SOCK_SOCKET : The socket descriptor to be closed
  457. Description : - Close socket, shutdown connection if present
  458. - This function closes a socket that has previously
  459. been created with sock_create().
  460. If a connection is open for this socket, it will be closed.
  461. If this socket has listened for connections,
  462. no further connections will be accepted
  463. History : 0001 03.08.11 shkim Created
  464. ------------------------------------------------------------------------------*/
  465. T_SOCK_RESULT sock_close(T_SOCK_SOCKET socket);
  466. /*------------------------------------------------------------------------------
  467. Function : sock_bind
  468. Parameter : - T_SOCK_SOCKET :
  469. 'The socket descriptor to be closed'
  470. - T_SOCK_PORT :
  471. 'The port number to bind the socket to'
  472. Return : (T_SOCK_RESULT)
  473. Return Event : 'SOCK_BIND_CNF'
  474. - T_SOCK_RESULT : Result code
  475. - T_SOCK_SOCKET : The socket descriptor to be bound
  476. Description : - Bind socket to a specific local port number
  477. - This function binds a socket to the specified local port
  478. History : 0001 03.08.11 shkim Created
  479. ------------------------------------------------------------------------------*/
  480. T_SOCK_RESULT sock_bind(T_SOCK_SOCKET socket,
  481. T_SOCK_PORT port);
  482. /*------------------------------------------------------------------------------
  483. Function : sock_listen
  484. Parameter : - T_SOCK_SOCKET :
  485. 'The socket descriptor to listen on'
  486. Return : (T_SOCK_RESULT)
  487. Return Event : 'SOCK_LISTEN_CNF'
  488. - T_SOCK_RESULT : Result code
  489. - T_SOCK_SOCKET : The socket descriptor to listen on
  490. Description : - Accept TCP connections on this socket
  491. - This function makes TCP/IP listen for
  492. TCP connections on this socket.
  493. The socket should have been bound to a specific port
  494. using sock_bind() before.
  495. History : 0001 03.08.11 shkim Created
  496. ------------------------------------------------------------------------------*/
  497. T_SOCK_RESULT sock_listen(T_SOCK_SOCKET socket);
  498. /*------------------------------------------------------------------------------
  499. Function : sock_connect
  500. Parameter : - T_SOCK_SOCKET :
  501. 'The socket descriptor to connect'
  502. - T_SOCK_IPADDR :
  503. 'The IP address to connect to'
  504. - T_SOCK_PORT :
  505. 'The port number to connect to'
  506. Return : (T_SOCK_RESULT)
  507. Return Event : 'SOCK_CONNECT_CNF'
  508. - T_SOCK_RESULT : Result code
  509. - T_SOCK_SOCKET : The socket descriptor to connect
  510. Description : - Connect the socket to a remote endpoint
  511. - With TCP sockets, a TCP connection is established to
  512. the specified IP address and the specified port.
  513. The connection can then be used to send data using sock_send();
  514. received data is indicated by a SOCK_RECV_IND event.
  515. With UDP sockets, the specified IP address and port number
  516. are stored with the socket;
  517. subsequent UDP messages can be sent to this address
  518. using sock_send();
  519. only messages from this address will be received.
  520. History : 0001 03.08.11 shkim Created
  521. ------------------------------------------------------------------------------*/
  522. T_SOCK_RESULT sock_connect(T_SOCK_SOCKET socket,
  523. T_SOCK_IPADDR ipaddr,
  524. T_SOCK_PORT port);
  525. /*------------------------------------------------------------------------------
  526. Function : sock_getsockname
  527. Parameter : - T_SOCK_SOCKET :
  528. 'The socket descriptor to retrieve information about'
  529. Return : (T_SOCK_RESULT)
  530. Return Event : 'SOCK_SOCKNAME_CNF'
  531. - T_SOCK_RESULT : Result code
  532. - T_SOCK_SOCKET : The socket descriptor to connect
  533. - T_SOCK_IPADDR : The local IP address of the socket
  534. - T_SOCK_PORT : The local port number of the socket
  535. Description : - Retrieve local address information
  536. - The function retrieves local address information of the socket.
  537. If the socket has not yet been bound to an address using sock_bind(),
  538. the port number is unspecified (SOCK_PORT_ANY)
  539. History : 0001 03.08.11 shkim Created
  540. ------------------------------------------------------------------------------*/
  541. T_SOCK_RESULT sock_getsockname(T_SOCK_SOCKET socket);
  542. /*------------------------------------------------------------------------------
  543. Function : sock_getpeername
  544. Parameter : - T_SOCK_SOCKET :
  545. 'The socket descriptor to retrieve information about'
  546. Return : (T_SOCK_RESULT)
  547. Return Event : 'SOCK_PEERNAME_CNF'
  548. - T_SOCK_RESULT : Result code
  549. - T_SOCK_SOCKET : The socket descriptor to connect
  550. - T_SOCK_IPADDR : The IP address of the remote peer
  551. - T_SOCK_PORT : The port number at the remote peer
  552. Description : - Retrieve remote address information
  553. - The function retrieves address information of
  554. the connection at the remote peer.
  555. If the socket is not connected,
  556. the IP address and port number are unspecified
  557. ------------------------------------------------------------------------------*/
  558. T_SOCK_RESULT sock_getpeername(T_SOCK_SOCKET socket);
  559. /*------------------------------------------------------------------------------
  560. Function : sock_gethostbyname
  561. Parameter : - T_SOCK_API_INSTANCE :
  562. 'API instance value.'
  563. - char * :
  564. 'The name of the referenced host'
  565. - T_SOCK_CALLBACK :
  566. 'The callback function to be called for the result event'
  567. - void * :
  568. 'An arbitrary pointer to be passed to the callback
  569. function when it is called'
  570. Return : (T_SOCK_RESULT)
  571. Return Event : 'SOCK_HOSTINFO_CNF'
  572. - T_SOCK_RESULT : Result code
  573. - char hostname[SOCK_MAXHOSTNAMELEN+1] : The name of the
  574. host as a zero-terminated string
  575. - T_SOCK_IPADDR : The IP address of the host
  576. Description : - Get the IP address of a host
  577. - The function queries the IP address information of
  578. the specified host from the DNS.
  579. Because the function is not associated to any socket,
  580. a callback function and a context
  581. pointer must be specified separately
  582. ------------------------------------------------------------------------------*/
  583. T_SOCK_RESULT sock_gethostbyname(T_SOCK_API_INSTANCE api_instance,
  584. char *hostname,
  585. T_SOCK_CALLBACK callback,
  586. void *context);
  587. /*------------------------------------------------------------------------------
  588. Function : sock_gethostbyaddr
  589. Parameter : - T_SOCK_API_INSTANCE :
  590. 'API instance value.'
  591. - T_SOCK_IPADDR :
  592. 'The IP address of the referenced host'
  593. - T_SOCK_CALLBACK :
  594. 'The callback function to be called for the result event'
  595. - void * :
  596. 'An arbitrary pointer to be passed to the callback function
  597. when it is called'
  598. Return : (T_SOCK_RESULT)
  599. Return Event : 'SOCK_HOSTINFO_CNF'
  600. - T_SOCK_RESULT : Result code
  601. - char hostname[SOCK_MAXHOSTNAMELEN+1] : The name of the
  602. host as a zero-terminated string
  603. - T_SOCK_IPADDR : The IP address of the host
  604. Description : - Get the name of a host
  605. - The function queries the hostname for the specified
  606. IP address from the DNS.
  607. Because the function is not associated to any socket,
  608. a callback function and a context pointer must be specified separately
  609. ------------------------------------------------------------------------------*/
  610. T_SOCK_RESULT sock_gethostbyaddr(T_SOCK_API_INSTANCE api_instance,
  611. T_SOCK_IPADDR ipaddr,
  612. T_SOCK_CALLBACK callback,
  613. void *context);
  614. /*------------------------------------------------------------------------------
  615. Function : sock_send
  616. Parameter : - T_SOCK_SOCKET :
  617. 'The socket to send the data on'
  618. - char * :
  619. 'The data buffer to be sent'
  620. - U16 :
  621. 'The length of the data buffer in bytes'
  622. Return : (T_SOCK_RESULT)
  623. Return Event : None
  624. Description : - Send data on a socket ( TCP only )
  625. - The function sends the specified data buffer over the socket.
  626. The socket must be connected,
  627. i. e. it must have been connected to a remote peer
  628. using sock_connect() or been created when accepting
  629. a connection as indicated by SOCK_SONNECT_IND.
  630. Implementation note: In order to send the payload data via DTI,
  631. the data must be copied into a DTI descriptor by the Socket API;
  632. there is no way to avoid the copy operation without
  633. putting the burden of knowing DTI-internal data
  634. structures on the application.
  635. It has been decided to pay the cost of the copy operation
  636. in order to free the application from this responsibility
  637. ------------------------------------------------------------------------------*/
  638. T_SOCK_RESULT sock_send(T_SOCK_SOCKET socket,
  639. char *buffer,
  640. U16 buffer_length);
  641. /*------------------------------------------------------------------------------
  642. Function : sock_sendto
  643. Parameter : - T_SOCK_SOCKET :
  644. 'The socket to send the data on'
  645. - char * :
  646. 'The data buffer to be sent'
  647. - U16 :
  648. 'The length of the data buffer'
  649. - T_SOCK_IPADDR :
  650. 'IP address of the host to send data to'
  651. - T_SOCK_PORT :
  652. 'Remote port to send data to'
  653. Return : (T_SOCK_RESULT)
  654. Return Event : None
  655. Description : - Send data on a socket( UDP only )
  656. - The function sends the specified data buffer
  657. over the socket to the specified address. The socket must be
  658. a UDP socket.
  659. Implementation note: In order to send the payload data via DTI,
  660. the data must be copied into a DTI descriptor by the Socket API;
  661. there is no way to avoid the copy operation without putting
  662. the burden of knowing DTI-internal data structures on
  663. the application. It has been decided to pay the cost of
  664. the copy operation in order to free the application from
  665. this responsibility
  666. ------------------------------------------------------------------------------*/
  667. T_SOCK_RESULT sock_sendto(T_SOCK_SOCKET socket,
  668. char *buffer,
  669. U16 buffer_length,
  670. T_SOCK_IPADDR ipaddr,
  671. T_SOCK_PORT port);
  672. /*------------------------------------------------------------------------------------
  673. Function : sock_set_callback
  674. Parameter : - T_SOCK_SOCKET :
  675. 'Socket to set callback and context for'
  676. - T_SOCK_CALLBACK :
  677. 'New callback function for the socket'
  678. - void * :
  679. 'New context pointer for the socket'
  680. Return : (T_SOCK_RESULT)
  681. Return Event : None
  682. Description : - Set a new callback function and context pointer for the socket
  683. - The function defines a new callback function and a new context
  684. pointer for the socket. All socket events after this call will be
  685. delivered using the new callback function and the new context
  686. pointer
  687. ------------------------------------------------------------------------------*/
  688. T_SOCK_RESULT sock_set_callback(T_SOCK_SOCKET socket,
  689. T_SOCK_CALLBACK callback,
  690. void *context);
  691. /*------------------------------------------------------------------------------
  692. Function : sock_get_callback
  693. Parameter : - T_SOCK_SOCKET :
  694. 'Socket to get callback and context from'
  695. - T_SOCK_CALLBACK * :
  696. 'Return callback function pointer for the socket'
  697. - void ** :
  698. 'Return context pointer for the socket'
  699. Return : (T_SOCK_RESULT)
  700. Return Event : None
  701. Description : - Get callback function pointer and context pointer for the socket
  702. - The function returns callback function pointer and context pointer
  703. for the socket.
  704. pointer
  705. ------------------------------------------------------------------------------*/
  706. T_SOCK_RESULT sock_get_callback(T_SOCK_SOCKET socket,
  707. T_SOCK_CALLBACK *callback_p,
  708. void **context_p);
  709. /*------------------------------------------------------------------------------
  710. Function : sock_flow_xoff
  711. Parameter : - T_SOCK_SOCKET :
  712. 'Socket to switch to "xoff" status'
  713. Return : (T_SOCK_RESULT)
  714. Return Event : None
  715. Description : - Flow control: make TCP/IP stop sending data
  716. - This function makes the Socket API stop TCP/IP sending data.
  717. If TCP/IP has already been stopped, the function has no effect.
  718. History : 0001 03.08.11 shkim Created
  719. 0002 03.09.12 STW T_SOCK_RESULT added
  720. ------------------------------------------------------------------------------*/
  721. T_SOCK_RESULT sock_flow_xoff(T_SOCK_SOCKET socket);
  722. /*------------------------------------------------------------------------------
  723. Function : sock_flow_xon
  724. Parameter : - T_SOCK_SOCKET :
  725. 'Socket to switch to "xon" status'
  726. Return : (T_SOCK_RESULT)
  727. Return Event : None
  728. Description : - Flow control: make TCP/IP resume sending data
  729. - This function makes TCP/IP resume sending data.
  730. If TCP/IP has not been stopped, the function has no effect
  731. History : 0001 03.08.11 shkim Created
  732. 0002 03.09.12 STW T_SOCK_RESULT added
  733. ------------------------------------------------------------------------------*/
  734. T_SOCK_RESULT sock_flow_xon(T_SOCK_SOCKET socket);
  735. /*------------------------------------------------------------------------------
  736. Function : sock_get_mtu_size
  737. Parameter : - T_SOCK_SOCKET :
  738. 'Socket to get MTU size from'
  739. Return : (T_SOCK_RESULT)
  740. Return Event : 'SOCK_MTU_SIZE_CNF'
  741. - T_SOCK_RESULT : Result code
  742. - T_SOCK_SOCKET : The socket descriptor (unused).
  743. - U16 : MTU size
  744. Description : - Get MTU size of network connection
  745. - The function retrieves the size of
  746. the Maximum Transfer Unit(MTU) of the network connection.
  747. History : 0001 03.08.11 shkim Created
  748. 0002 03.09.12 STW T_SOCK_SOCKET added
  749. ------------------------------------------------------------------------------*/
  750. T_SOCK_RESULT sock_get_mtu_size(T_SOCK_SOCKET socket);
  751. #endif /* __SOCKET_H__ */