comparison src/g23m-fad/udp/udp.h @ 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 +----------------------------------------------------------------------------
3 | Project: GSM-WAP (8444)
4 | Modul: UDP
5 +----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +----------------------------------------------------------------------------
17 | Purpose: Definitions for the Protocol Stack Entity
18 | Internet Protocol
19 +----------------------------------------------------------------------------
20 */
21
22 #ifndef UDP_H
23 #define UDP_H
24
25 /*-------------------------------------------------------------------------*/
26
27 #define UDP_SINGLE_LAYER 0
28
29 /* Information for DTI library */
30
31 #define UDP_DTI_DEF_INSTANCE UDP_SINGLE_LAYER
32
33 #define UDP_DTI_LL_INTERFACE 0 /* Lower layer interface */
34 #define UDP_DTI_HL_INTERFACE 1 /* Higher layer interface */
35
36 #define UDP_DTI_DEF_CHANNEL 0
37 #define UDP_DTI_INIT_QUEUE_SIZE 0
38
39 #include "ip_udp.h"
40
41 /*---- Types --------------------------------------------------------------*/
42
43 /* Instance management */
44
45 #ifdef OPTION_MULTI_INSTANCE
46 #define GET_INSTANCE(p) (udp_data_base + p->custom.route.inst_no)
47 #define UDP_INSTANCES MAX_INSTANCES
48 #else
49 #define GET_INSTANCE(p) (udp_data_base + UDP_SINGLE_LAYER)
50 #define UDP_INSTANCES 1
51 #endif
52
53 /*---- Constants ----------------------------------------------------------*/
54
55 /* Constants for the UDP packet */
56
57 #define MIN_HEADER_LEN 5 /* Min IP header length in 32 bit words */
58
59 /* Errors */
60 #define NO_ERROR 0 /* No errors found */
61
62 #define LEN_PSEUDO_HEADER_B 12 /* Length of pseudo header in bytes */
63
64 /* States of higher layer port */
65
66 #define PORT_DOWN 0
67 #define PORT_BOUND 1
68 #define PORT_ACTIVE 2
69
70 /* States for error downlink */
71
72 #define STATE_DL_NO_ERROR 0 /* No errors */
73 #define STATE_DL_ERROR 1 /* We have one or more errors */
74
75 /* State index for the entity process/services */
76
77 #define KER ker.
78 #define HILA hila.
79 #define LOLA lola.
80
81 /* States of the entity process kernel */
82
83 #define DEACTIVATED 0 /* */
84 #define ACTIVE_NC 1 /* Not configured */
85 #define CONNECTED 2 /* */
86
87 /* States for send and receive packet services */
88
89 #define DOWN 0 /* State not active */
90 #define CONNECTING 1 /* State is connecting */
91 #define IDLE 2 /* State no incoming signals */
92 #define SEND 3 /* State sending packet */
93 #define WAIT 4 /* State waiting for packet */
94
95 #ifndef NTRACE
96 /* For trace purposes */
97 #define SERVICE_NAME_KER "KER"
98 #define SERVICE_NAME_HILA "HILA"
99 #define SERVICE_NAME_LOLA "LOLA"
100 #endif
101
102 /*---- TYPES --------------------------------------------------------------*/
103
104 /* Later on included between WAP and UDP - To do */
105
106 typedef struct
107 {
108 UBYTE src_ip[4];
109 UBYTE des_ip[4];
110 UBYTE src_port[2];
111 UBYTE des_port[2];
112 } T_SRC_DES;
113
114 typedef struct
115 {
116 UBYTE state;
117 #ifndef NTRACE
118 char * name;
119 char * state_name;
120 #endif
121 UBYTE dti_state;
122 ULONG link_id;
123 BOOL drop_packet; /* TRUE: not sending packet to lower layer */
124 char entity_name [UDPA_ENTITY_NAME_LEN];
125
126 T_DTI2_DATA_REQ * dti_data_req; /* Data primitive to lower layer */
127 } T_HILA;
128
129 typedef struct
130 {
131 UBYTE state;
132 #ifndef NTRACE
133 char * name;
134 char * state_name;
135 #endif
136 UBYTE dti_state;
137 ULONG link_id;
138 BOOL drop_packet; /* TRUE: not sending packet to higher layer */
139 char entity_name [UDPA_ENTITY_NAME_LEN];
140
141 UBYTE state_err; /* State variable for errors */
142 ULONG src_addr; /* Source address for DL datagram */
143 ULONG dst_addr; /* Destination address for DL datagram */
144 USHORT dst_port; /* Destination port for DL datagram */
145 USHORT src_port; /* Source port for DL datagram */
146
147 T_DTI2_DATA_IND * dti_data_ind; /* We are sending data to higher layer */
148 } T_LOLA;
149
150 typedef struct
151 {
152 UBYTE state;
153 #ifndef NTRACE
154 char * name;
155 char * state_name;
156 #endif
157 BOOL send_icmp; /* We send an ICMP message */
158 UBYTE port_state; /* State of the source port */
159 USHORT src_port; /* Source port */
160 USHORT dst_port; /* Destination port */
161 ULONG src_addr; /* Source address in the IP packet */
162 ULONG dst_addr; /* Destination IP address */
163
164 T_DTI2_DATA_REQ * dti_data_req_icmp; /* For ICMP messages */
165 } T_KER;
166
167 /* Entity data for each UDP instance */
168
169 typedef struct
170 {
171 T_HILA hila; /* Data for each higher layer */
172 T_LOLA lola; /* Data for each lower layer */
173 T_KER ker;
174 } T_UDP_DATA;
175
176 /*---- EXPORT -------------------------------------------------------------*/
177
178 /* Instance data base */
179
180 extern T_UDP_DATA udp_data_base [], * udp_data;
181
182 /* The DTI data base is allocated in function dti_init() */
183
184 extern DTI_HANDLE udp_hDTI;
185
186 #define ENTITY_DATA udp_data
187
188 /*---- Prototypes ---------------------------------------------------------*/
189
190 /* Prototypes
191 *
192 * UDP KERNEL
193 *
194 * KERNEL primitive processing */
195
196 #ifdef OPTION_MULTITHREAD
197
198 #define ker_udp_shutdown_res _ENTITY_PREFIXED (ker_udp_shutdown_res)
199 #define ker_udp_bind_req _ENTITY_PREFIXED (ker_udp_bind_req)
200 #define ker_udp_closeport_req _ENTITY_PREFIXED (ker_udp_closeport_req)
201 #define ker_udp_error_res _ENTITY_PREFIXED (ker_udp_error_res)
202 #define ker_udpa_dti_req _ENTITY_PREFIXED (ker_udpa_dti_req)
203 #define ker_udpa_config_req _ENTITY_PREFIXED (ker_udpa_config_req)
204
205 #define sig_dti_ker_connection_opened_ll_ind \
206 _ENTITY_PREFIXED (sig_dti_ker_connection_opened_ll_ind)
207 #define sig_dti_ker_connection_opened_hl_ind \
208 _ENTITY_PREFIXED (sig_dti_ker_connection_opened_hl_ind)
209 #define sig_dti_ker_connection_closed_ll_ind \
210 _ENTITY_PREFIXED (sig_dti_ker_connection_closed_ll_ind)
211 #define sig_dti_ker_connection_closed_hl_ind \
212 _ENTITY_PREFIXED (sig_dti_ker_connection_closed_hl_ind)
213 #define sig_dti_ker_data_received_ll_ind \
214 _ENTITY_PREFIXED (sig_dti_ker_data_received_ll_ind)
215 #define sig_dti_ker_tx_buffer_ready_hl_ind \
216 _ENTITY_PREFIXED (sig_dti_ker_tx_buffer_ready_hl_ind)
217 #define sig_dti_ker_tx_buffer_full_hl_ind \
218 _ENTITY_PREFIXED (sig_dti_ker_tx_buffer_full_hl_ind)
219 #define sig_dti_ker_data_received_hl_ind \
220 _ENTITY_PREFIXED (sig_dti_ker_data_received_hl_ind)
221 #define sig_dti_ker_tx_buffer_ready_ll_ind \
222 _ENTITY_PREFIXED (sig_dti_ker_tx_buffer_ready_ll_ind)
223 #define sig_dti_ker_tx_buffer_full_ll_ind \
224 _ENTITY_PREFIXED (sig_dti_ker_tx_buffer_full_ll_ind)
225
226 #define ker_ip_addr_cnf _ENTITY_PREFIXED (ker_ip_addr_cnf)
227 #define udp_build_packet _ENTITY_PREFIXED (udp_build_packet)
228 #define init_udp _ENTITY_PREFIXED (init_udp)
229 #define deinit_udp _ENTITY_PREFIXED (deinit_udp)
230
231 #define pei_dti_dti_connect_req \
232 _ENTITY_PREFIXED (pei_dti_dti_connect_req)
233 #define pei_dti_dti_connect_cnf \
234 _ENTITY_PREFIXED (pei_dti_dti_connect_cnf)
235 #define pei_dti_dti_connect_ind \
236 _ENTITY_PREFIXED (pei_dti_dti_connect_ind)
237 #define pei_dti_dti_connect_res \
238 _ENTITY_PREFIXED (pei_dti_dti_connect_res)
239 #define pei_dti_dti_disconnect_req \
240 _ENTITY_PREFIXED (pei_dti_dti_disconnect_req)
241 #define pei_dti_dti_disconnect_ind \
242 _ENTITY_PREFIXED (pei_dti_dti_disconnect_ind)
243 #define pei_dti_dti_ready_ind \
244 _ENTITY_PREFIXED (pei_dti_dti_ready_ind)
245 #define pei_dti_dti_data_req \
246 _ENTITY_PREFIXED (pei_dti_dti_data_req)
247 #define pei_dti_dti_data_ind \
248 _ENTITY_PREFIXED (pei_dti_dti_data_ind)
249 #define pei_dti_dti_getdata_req \
250 _ENTITY_PREFIXED (pei_dti_dti_getdata_req)
251 #define pei_sig_callback \
252 _ENTITY_PREFIXED (pei_sig_callback)
253
254 #ifdef _SIMULATION_
255 #define pei_dti_dti_data_test_req \
256 _ENTITY_PREFIXED (pei_dti_dti_data_test_req)
257 #define pei_dti_dti_data_test_ind \
258 _ENTITY_PREFIXED (pei_dti_dti_data_test_ind)
259 #endif
260
261 #endif
262
263 USHORT inet_checksum (UBYTE * block, USHORT len);
264 USHORT desc_checksum (
265 T_desc_list2 * dlist,
266 USHORT start_offset,
267 ULONG start_value
268 );
269 ULONG partial_checksum (UBYTE * block, USHORT len);
270
271 /* UDP SAP */
272
273 void ker_udp_shutdown_res (T_UDP_SHUTDOWN_RES * udp_shutdown_res);
274 void ker_udp_bind_req (T_UDP_BIND_REQ * udp_bind_req);
275 void ker_udp_closeport_req (T_UDP_CLOSEPORT_REQ * udp_closeport_req);
276 void ker_udp_error_res (T_UDP_ERROR_RES * udp_error_res);
277
278 /* UDPA SAP */
279
280 void ker_udpa_dti_req (T_UDPA_DTI_REQ * udpa_dti_req);
281 void ker_udpa_config_req (T_UDPA_CONFIG_REQ * udpa_config_req);
282
283 /* Wrapping functions for dtilib primitives */
284
285 void pei_dti_dti_connect_req (T_DTI2_CONNECT_REQ * dti_connect_req);
286 void pei_dti_dti_connect_cnf (T_DTI2_CONNECT_CNF * dti_connect_cnf);
287 void pei_dti_dti_connect_ind (T_DTI2_CONNECT_IND * dti_connect_ind);
288 void pei_dti_dti_connect_res (T_DTI2_CONNECT_RES * dti_connect_res);
289
290 void pei_dti_dti_disconnect_req (T_DTI2_DISCONNECT_REQ * dti_disconnect_req);
291 void pei_dti_dti_disconnect_ind (T_DTI2_DISCONNECT_IND * dti_disconnect_ind);
292
293 void pei_dti_dti_data_req (T_DTI2_DATA_REQ * dti_data_req);
294 void pei_dti_dti_getdata_req (T_DTI2_GETDATA_REQ * dti_getdata_req);
295 void pei_dti_dti_data_ind (T_DTI2_DATA_IND * dti_data_ind);
296 void pei_dti_dti_ready_ind (T_DTI2_READY_IND * dti_ready_ind);
297
298 #ifdef _SIMULATION_
299 void pei_dti_dti_data_test_req (T_DTI2_DATA_TEST_REQ * dti_data_test_req);
300 void pei_dti_dti_data_test_ind (T_DTI2_DATA_TEST_IND * dti_data_test_ind);
301 #endif
302
303 /* UP DTI */
304
305 void sig_dti_ker_connection_opened_hl_ind ();
306 void sig_dti_ker_connection_closed_hl_ind ();
307 void sig_dti_ker_tx_buffer_ready_hl_ind ();
308 void sig_dti_ker_tx_buffer_full_hl_ind ();
309 void sig_dti_ker_data_received_hl_ind (T_DTI2_DATA_REQ * dti_data_req);
310
311 /* DN DTI */
312
313 void sig_dti_ker_connection_opened_ll_ind ();
314 void sig_dti_ker_connection_closed_ll_ind ();
315 void sig_dti_ker_tx_buffer_ready_ll_ind ();
316 void sig_dti_ker_tx_buffer_full_ll_ind ();
317 void sig_dti_ker_data_received_ll_ind (T_DTI2_DATA_IND * dti_data_ind);
318
319 /* UL IP SAP */
320
321 void ker_ip_addr_cnf (T_IP_ADDR_CNF * ip_addr_cnf);
322
323 /* DTILIB callback function */
324
325 void pei_sig_callback (
326 U8 instance,
327 U8 interfac,
328 U8 channel,
329 U8 reason,
330 T_DTI2_DATA_IND * dti_data_ind
331 );
332
333 /* Functions in udp_kerf.c */
334
335 void udp_build_packet (BOOL hila, UBYTE to_do);
336
337 void init_udp (void);
338 void deinit_udp (void);
339
340 /* Communication handles */
341
342 #ifdef OPTION_MULTITHREAD
343 #define hCommACI _ENTITY_PREFIXED (hCommACI)
344 #define hCommLL _ENTITY_PREFIXED (hCommLL)
345 #define hCommHL _ENTITY_PREFIXED (hCommHL)
346 #endif
347
348 extern T_HANDLE hCommACI; /* ACI communication */
349 extern T_HANDLE hCommLL; /* LL communication */
350 extern T_HANDLE hCommHL; /* HL communication */
351 extern T_HANDLE udp_handle;
352
353 #ifndef NCONFIG
354 #ifdef OPTION_MULTITHREAD
355 #define partab _ENTITY_PREFIXED (partab)
356 #endif
357 extern KW_DATA partab [];
358 #endif
359
360 /*-------------------------------------------------------------------------*/
361
362 #endif /* UDP_H */
363
364 /*-------------------------------------------------------------------------*/
365