comparison src/g23m-fad/ip/ip.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 : IP
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 IP_H
23 #define IP_H
24
25 /*-------------------------------------------------------------------------*/
26
27 #if defined WIN32 && ! defined _SIMULATION_
28 #define _SIMULATION_
29 #endif
30
31 #ifdef _SIMULATION_
32 #undef _TARGET_
33 #else
34 #ifndef _TARGET_
35 #define _TARGET_
36 #endif
37 #endif
38
39 /* Information for DTI library */
40
41 #define IP_DTI_DEF_INSTANCE 0
42 #define IP_DTI_HL_INTERFACE 0
43 #define IP_DTI_LL_INTERFACE 1
44 #define IP_DTI_DEF_CHANNEL 0
45
46 #define IP_DTI_UPLINK_QUEUE_SIZE 0
47 #define IP_DTI_DOWNLINK_QUEUE_SIZE 0
48
49 /*==== Types =======================================================*/
50
51 /* Instance management */
52
53 #ifdef OPTION_MULTI_INSTANCE
54 #define GET_INSTANCE(p) (ip_data_base + p->custom.route.inst_no)
55 #define IP_INSTANCES MAX_INSTANCES
56 #else
57 #define GET_INSTANCE(p) ip_data_base
58 #define IP_INSTANCES 1
59 #endif
60
61 /*==== Constants ============================================================*/
62
63 #define MAX_LAYER 1 /* Connected to layers */
64
65 /* States for send and receive packets */
66
67 /* Constants for the IP packet */
68
69 #define MIN_HEADER_LEN 5 /* Min IP header length in 32 bit words */
70 #define MAX_PACKET_LEN 1500 /* Max packet len from higher layer */
71
72 /* Segmenting states and parameter */
73
74 #define NO_SEGMENTS 0 /* Normal packet */
75 #define SEND_SEGMENT 1 /* Sending segments */
76 #define READ_SEGMENT 2 /* Read segment */
77 #define GO_ON_SEGMENTING 10 /* Fragmenting ok - go on */
78 #define NO_SPACE_SEGMENTING 10 /* Not possible to sort cs. of less space */
79 #define MAX_SEGMENTS 50 /* Max received segments */
80 #define MAX_SEGM_SERVER 1 /* Max active server by rec. segments */
81
82 /* Errors */
83
84 #define NO_ERROR 0 /* No errors found */
85 #define ERR_PACKET_LEN 1 /* Packet length error */
86 #define CHANGE_PACKET_LEN 2 /* Length desc_list > total len indicated in header */
87
88 /* IP addresses */
89
90 #define MAX_ADDR_TYPES 15 /* Max field address-types */
91 #define MCAST_ADDR 0 /* Multicast address or class D address */
92 #define LINK_LAYER_BCAST 1 /* Link layer broadcast address */
93 #define LOOP_BACK_ADDR 2 /* Loopback address */
94 #define CLASS_E_ADDR 3 /* Class E address */
95 #define NO_DEST_ADDR 4 /* No destination address */
96 #define BCAST_ADDR_255 5 /* Broadcast address 255.255.255.255 */
97 #define NETW_ADDR 6 /* Network address */
98 #define CLASS_A_ADDR 7 /* Class A address */
99 #define CLASS_B_ADDR 8 /* Class B address */
100 #define CLASS_C_ADDR 9 /* Class C address */
101 #define DEFAULT_R_ADDR 10 /* Default route address */
102 #define BAD_UL_SRC_ADDR 11 /* Indicate bad uplink source address */
103 #define BAD_DL_SRC_ADDR 12 /* Indicate bad downlink source address */
104 #define BAD_UL_DEST_ADDR 13 /* Indicate bad uplink destination address */
105 #define BAD_DL_DEST_ADDR 14 /* Indicate bad uplink destination address */
106
107 /* Only for testing */
108
109 #define TEST_SRC_ADDR 0x0a0b0c0d /* Source test address */
110 #define TEST_DEST_ADDR 0x0a0b0c0e /* Destination test address */
111
112 /* Type of primitives */
113
114 #define P_DTI_READY 0
115 #define P_DTI_DATA_REQ 1
116 #define P_DTI_GETDATA_REQ 2
117 #define P_DTI_DATA_IND 3
118
119 /* Bit offset for encoding/decoding */
120
121 #define ENCODE_OFFSET 0
122
123 /* Timer */
124
125 #define TREASSEMBLY 0 /* Reassembly timer */
126
127 /* Timeout for reassembly segments */
128
129 #define TIME_REASSEMBLY 30000 /* 30 - 60 seconds is the correct value */
130
131 /* Dynamic configuration numbers */
132
133 #define RESET 0
134 #define FRAME_TRACE 6
135
136 /* State index for the entity process/services */
137
138 #define KER ker.
139 #define HILA hila.
140 #define LOLA lola.
141
142 /* States of the entity process kernel */
143
144 #define DEACTIVATED 0
145 #define ACTIVE_NC 1 /* Not configured */
146 #define CONNECTED 2
147
148 /* States for send and receive packet services */
149
150 #define DOWN 0 /* State not active */
151 #define CONNECTING 1 /* State is connecting */
152 #define IDLE 2 /* State no incoming signals */
153 #define SEND 3 /* State sending packet */
154 #define WAIT 4 /* State waiting for packet */
155
156 /* For trace purposes */
157
158 #ifndef NTRACE
159 #define SERVICE_NAME_KER "KER"
160 #define SERVICE_NAME_HILA "HILA"
161 #define SERVICE_NAME_LOLA "LOLA"
162 #endif
163
164 /*============ TYPES ======================================================*/
165
166 /* Global variable-structure for uplink */
167
168 typedef struct
169 {
170 UBYTE state; /* State uplink */
171 #ifndef NTRACE
172 char * name;
173 char * state_name;
174 #endif
175 T_DTI2_DATA_REQ * dti_data_req; /* Data primitive uplink */
176 BOOL drop_packet; /* TRUE: not sending packet to lower layer */
177 UBYTE ttl; /* Time to live */
178 USHORT segment_id; /* Number of the segment packet */
179 USHORT header_len; /* Header length */
180 UBYTE state_segment; /* State segmenting uplink */
181 ULONG next_segment_desc; /* Pointer to next segment desc */
182 USHORT last_segment_pos; /* Last position for copy in next_segment_desc */
183 USHORT segment_offset; /* Offset for segmenting */
184 USHORT sended_segment_len; /* Sended segment length include header */
185 USHORT list_len_segment; /* Listlength of the income datagram */
186 UBYTE segment_prot; /* Protokoll higher layer by fragmenting */
187 T_desc2 * first_desc_segment; /* First desc for sending */
188 USHORT identity; /* Sets the identity */
189 } T_HILA;
190
191 /* Global variable-structure for downlink */
192
193 typedef struct
194 {
195 UBYTE state; /* State downlink */
196 #ifndef NTRACE
197 char * name;
198 char * state_name;
199 #endif
200 T_DTI2_DATA_IND * dti_data_ind; /* Inputbuffer from higher layer */
201 T_DTI2_DATA_IND * data_ind_reassembly [MAX_SEGM_SERVER]; /* For receiving segments */
202 BOOL drop_packet; /* TRUE: not sending packet to lower layer */
203 USHORT header_len; /* Header length */
204 UBYTE state_reassembly [MAX_SEGM_SERVER]; /* State segmenting uplink */
205 BOOL got_first_segment [MAX_SEGM_SERVER]; /* Got first segment by reassembling */
206 BOOL got_last_segment [MAX_SEGM_SERVER]; /* Got last segment */
207 ULONG ip_source_addr_segment [MAX_SEGM_SERVER]; /* IP source address for segment */
208 USHORT pos_server; /* Position of fragmenting server */
209 USHORT id_reassemble [MAX_SEGM_SERVER]; /* Identity of the reassemble fragments */
210 UBYTE prot_reassemble [MAX_SEGM_SERVER]; /* Protocol reassembly */
211 UBYTE timer_reass_running [MAX_SEGM_SERVER]; /* Timer is running */
212 ULONG sort_reass_array [2] [MAX_SEGMENTS]; /* Used to sort the incoming fragments */
213 } T_LOLA;
214
215 /* Entity data for each IP instance */
216
217 typedef struct
218 {
219 UBYTE state; /* State variables for each process */
220 #ifndef NTRACE
221 char * name;
222 char * state_name;
223 #endif
224 ULONG source_addr;/* Source IP address */
225 ULONG dst_addr; /* Destination address */
226 ULONG peer_addr; /* Destination address for routing */
227 ULONG netmask; /* Netmask for the routing table */
228 char entity_name_hl [IPA_ENTITY_NAME_LEN]; /* Entity name higher layer */
229 char entity_name_ll [IPA_ENTITY_NAME_LEN]; /* Entity name lower layer */
230 ULONG link_id_hl;
231 ULONG link_id_ll;
232 USHORT mtu; /* Maximum transfer unit */
233 BOOL send_icmp; /* ICMP message shall be sent */
234 T_DTI2_DATA_REQ * icmp_dti_data_req; /* For sending ICMP message to uplink */
235 } T_KER;
236
237 typedef struct
238 {
239 T_HILA hila; /* Data for each higher layer */
240 T_LOLA lola; /* Data for each lower layer */
241 T_KER ker;
242 } T_IP_DATA;
243
244 #ifdef GPRS
245 typedef enum
246 {
247 UNIT_INVALID = -1,
248 UNIT_SNDCP,
249 UNIT_ACI,
250 UNIT_UART,
251 UNIT_PPPS,
252 UNIT_PPPC,
253 UNIT_L2R,
254 UNIT_T30,
255 UNIT_IP,
256 UNIT_TRA,
257 UNIT_UDP,
258 UNIT_WAP,
259 UNIT_MTST,
260 UNIT_BLUETOOTH,
261 UNIT_NULL,
262 UNIT_MAX
263 } IP_UNIT_ID;
264 #endif
265
266 /*==== EXPORT =====================================================*/
267
268 /* Data base */
269
270 extern DTI_HANDLE ip_hDTI;
271
272 /* Instance data base */
273
274 extern T_IP_DATA ip_data_base [], * ip_data;
275
276 /* DTI data base. The data base is allocated in function dti_init(). */
277
278 extern DTI_HANDLE udp_hDTI;
279
280 #define ENTITY_DATA ip_data
281
282 /* Prototypes timer */
283
284 #ifdef OPTION_MULTITHREAD
285 #define tim_init_timer _ENTITY_PREFIXED (tim_init_timer)
286 #define tim_set_timeout_flag _ENTITY_PREFIXED (tim_set_timeout_flag)
287 #define tim_handle_timeout _ENTITY_PREFIXED (tim_handle_timeout)
288 #define tim_flush_fifo _ENTITY_PREFIXED (tim_flush_fifo)
289 #define tim_reassembly _ENTITY_PREFIXED (tim_reassembly)
290 #endif
291
292 BOOL tim_init_timer (void);
293
294 /* Timer specific timeout handling routines */
295
296 void tim_reassembly (/* USHORT layer, USHORT segm_server */);
297
298 /* Prototypes customer specific functions */
299
300 #ifdef OPTION_MULTITHREAD
301 #define csf_init_timer _ENTITY_PREFIXED (csf_init_timer)
302 #define csf_close_timer _ENTITY_PREFIXED (csf_close_timer)
303 #endif
304
305 BOOL csf_init_timer (void);
306 void csf_close_timer (void);
307 void csf_stop_timer (USHORT index);
308 BOOL csf_timer_expired (
309 USHORT index,
310 USHORT * layer,
311 USHORT * segm_server,
312 USHORT * timer
313 );
314
315 /*==== Prototypes ==================================================*/
316
317 /* Prototypes
318 *
319 * IP KERNEL
320 *
321 * KERNEL primitive processing
322 */
323
324 #ifdef OPTION_MULTITHREAD
325 #define ker_ipa_activate_req _ENTITY_PREFIXED (ker_ipa_activate_req)
326 #define ker_ipa_deactivate_req _ENTITY_PREFIXED (ker_ipa_deactivate_req)
327 #define ker_ipa_config_req _ENTITY_PREFIXED (ker_ipa_config_req)
328 #define ker_ip_addr_req _ENTITY_PREFIXED (ker_ip_addr_req)
329
330 #define sig_dti_ker_connection_opened_hl_ind \
331 _ENTITY_PREFIXED (sig_dti_ker_connection_opened_hl_ind)
332 #define sig_dti_ker_connection_opened_ll_ind \
333 _ENTITY_PREFIXED (sig_dti_ker_connection_opened_ll_ind)
334 #define sig_dti_ker_connection_closed_hl_ind \
335 _ENTITY_PREFIXED (sig_dti_ker_connection_closed_hl_ind)
336 #define sig_dti_ker_connection_closed_ll_ind \
337 _ENTITY_PREFIXED (sig_dti_ker_connection_closed_ll_ind)
338 #define sig_dti_ker_data_received_hl_ind \
339 _ENTITY_PREFIXED (sig_dti_ker_data_received_hl_ind)
340 #define sig_dti_ker_tx_buffer_ready_ll_ind \
341 _ENTITY_PREFIXED (sig_dti_ker_tx_buffer_ready_ll_ind)
342 #define sig_dti_ker_tx_buffer_full_hl_ind \
343 _ENTITY_PREFIXED (sig_dti_ker_tx_buffer_full_hl_ind)
344 #define sig_dti_ker_data_received_ll_ind \
345 _ENTITY_PREFIXED (sig_dti_ker_data_received_ll_ind)
346 #define sig_dti_ker_tx_buffer_ready_hl_ind \
347 _ENTITY_PREFIXED (sig_dti_ker_tx_buffer_ready_hl_ind)
348 #define sig_dti_ker_tx_buffer_full_ll_ind \
349 _ENTITY_PREFIXED (sig_dti_ker_tx_buffer_full_ll_ind)
350
351 #define pei_dti_dti_connect_req _ENTITY_PREFIXED (pei_dti_dti_connect_req)
352 #define pei_dti_dti_connect_cnf _ENTITY_PREFIXED (pei_dti_dti_connect_cnf)
353 #define pei_dti_dti_connect_ind _ENTITY_PREFIXED (pei_dti_dti_connect_ind)
354 #define pei_dti_dti_connect_res _ENTITY_PREFIXED (pei_dti_dti_connect_res)
355 #define pei_dti_dti_disconnect_req _ENTITY_PREFIXED (pei_dti_dti_disconnect_req)
356 #define pei_dti_dti_disconnect_ind _ENTITY_PREFIXED (pei_dti_dti_disconnect_ind)
357 #define pei_dti_dti_ready_ind _ENTITY_PREFIXED (pei_dti_dti_ready_ind)
358 #define pei_dti_dti_data_req _ENTITY_PREFIXED (pei_dti_dti_data_req)
359 #define pei_dti_dti_data_ind _ENTITY_PREFIXED (pei_dti_dti_data_ind)
360 #define pei_dti_dti_getdata_req _ENTITY_PREFIXED (pei_dti_dti_getdata_req)
361
362 #ifdef _SIMULATION_
363 #define pei_dti_dti_data_test_req _ENTITY_PREFIXED (pei_dti_dti_data_test_req)
364 #define pei_dti_dti_data_test_ind _ENTITY_PREFIXED (pei_dti_dti_data_test_ind)
365 #endif
366
367 #define pei_sig_callback _ENTITY_PREFIXED (pei_sig_callback)
368
369 #define ip_packet_validator _ENTITY_PREFIXED (ip_packet_validator)
370 #define check_ip_address _ENTITY_PREFIXED (check_ip_address)
371 #define chk_packet_len _ENTITY_PREFIXED (chk_packet_len)
372 #define ip_addr_int_to_byte _ENTITY_PREFIXED (ip_addr_int_to_byte)
373 #define build_ip_packet _ENTITY_PREFIXED (build_ip_packet)
374 #define init_ip _ENTITY_PREFIXED (init_ip)
375 #define sort_descs_id_up _ENTITY_PREFIXED (sort_descs_id_up)
376 #define reassemble_fragments _ENTITY_PREFIXED (reassemble_fragments)
377 #define config_down_ll _ENTITY_PREFIXED (config_down_ll)
378 #define terminate_ip _ENTITY_PREFIXED (terminate_ip)
379 #endif
380
381 /* IPA SAP */
382
383 void ker_ipa_dti_req (T_IPA_DTI_REQ * ipa_dti_req);
384 void ker_ipa_config_req (T_IPA_CONFIG_REQ * ipa_config_req);
385
386 /* IP SAP */
387
388 void ker_ip_addr_req (T_IP_ADDR_REQ * ip_addr_req);
389
390 /* Wrapping functions for DTI library primitives */
391
392 void pei_dti_dti_connect_req (T_DTI2_CONNECT_REQ * dti_connect_req);
393 void pei_dti_dti_connect_cnf (T_DTI2_CONNECT_CNF * dti_connect_cnf);
394 void pei_dti_dti_connect_ind (T_DTI2_CONNECT_IND * dti_connect_ind);
395 void pei_dti_dti_connect_res (T_DTI2_CONNECT_RES * dti_connect_res);
396 void pei_dti_dti_disconnect_req (T_DTI2_DISCONNECT_REQ * dti_disconnect_req);
397 void pei_dti_dti_disconnect_ind (T_DTI2_DISCONNECT_IND * dti_disconnect_ind);
398 void pei_dti_dti_data_req (T_DTI2_DATA_REQ * dti_data_req);
399 void pei_dti_dti_getdata_req (T_DTI2_GETDATA_REQ * dti_getdata_req);
400 void pei_dti_dti_data_ind (T_DTI2_DATA_IND * dti_data_ind);
401 void pei_dti_dti_ready_ind (T_DTI2_READY_IND * dti_ready_ind);
402 #ifdef _SIMULATION_
403 void pei_dti_dti_data_test_req (T_DTI2_DATA_TEST_REQ * dti_data_test_req);
404 void pei_dti_dti_data_test_ind (T_DTI2_DATA_TEST_IND * dti_data_test_ind);
405 #endif
406
407 /* UP DTI */
408
409 void sig_dti_ker_data_received_hl_ind (T_DTI2_DATA_REQ * dti_data_req);
410 void sig_dti_ker_connection_opened_hl_ind ();
411 void sig_dti_ker_connection_closed_hl_ind ();
412 void sig_dti_ker_tx_buffer_ready_ll_ind ();
413 void sig_dti_ker_tx_buffer_full_hl_ind ();
414
415 /* DN DTI */
416
417 void sig_dti_ker_data_received_ll_ind (T_DTI2_DATA_IND * dti_data_ind);
418 void sig_dti_ker_connection_opened_ll_ind ();
419 void sig_dti_ker_connection_closed_ll_ind ();
420 void sig_dti_ker_tx_buffer_ready_hl_ind ();
421 void sig_dti_ker_tx_buffer_full_ll_ind ();
422
423 /* DTILIB callback function */
424
425 void pei_sig_callback (
426 U8 instance,
427 U8 interfac,
428 U8 channel,
429 U8 reason,
430 T_DTI2_DATA_IND * dti_data_ind
431 );
432
433 /* Functions in ip_kerf.c */
434
435 BOOL ip_packet_validator (T_desc_list2 * desc_list);
436 void build_ip_packet (BOOL uplink, UBYTE select);
437 void init_ip (void);
438 void terminate_ip (void);
439 void config_down_ll (void);
440 void check_ip_address (
441 BOOL * addr_type_dest,
442 BOOL * addr_type_src,
443 ULONG dest_addr,
444 ULONG src_addr
445 );
446 void ip_addr_int_to_byte (UBYTE * b_values, ULONG ul_value);
447 UBYTE chk_packet_len (UBYTE * ip_header, T_desc_list2 * desc_list);
448 USHORT sort_descs_id_up (
449 T_desc_list2 * desc_list,
450 ULONG sort_array[2][MAX_SEGMENTS]
451 );
452 void reassemble_fragments (
453 T_DTI2_DATA_IND ** dti_data_ind,
454 T_LOLA * p_dl,
455 UBYTE * ip_header,
456 BOOL first_segment,
457 /* BOOL middle_segment, */
458 BOOL last_segment /*,*/
459 /* USHORT fragm_offset */
460 );
461
462 /* Communication handles */
463
464 #ifdef OPTION_MULTITHREAD
465 #define hCommMMI _ENTITY_PREFIXED (hCommMMI)
466 #define hCommDL _ENTITY_PREFIXED (hCommDL)
467 #define hCommIP _ENTITY_PREFIXED (hCommIP)
468 #define hCommHL _ENTITY_PREFIXED (hCommHL)
469 #endif
470
471 extern T_HANDLE hCommMMI; /* ACI communication */
472 extern T_HANDLE hCommDL; /* HL communication */
473 extern T_HANDLE hCommIP; /* IP communication */
474 extern T_HANDLE hCommHL; /* HL communication */
475 extern T_HANDLE ip_handle;
476
477 /* Entity common buffer for the decoded air interface message */
478
479 #ifdef OPTION_MULTITHREAD
480 #define _decodedMsg _ENTITY_PREFIXED (_decodedMsg)
481 #endif
482
483 extern UBYTE _decodedMsg [];
484
485 #ifndef NCONFIG
486 #ifdef OPTION_MULTITHREAD
487 #define partab _ENTITY_PREFIXED (partab)
488 #endif
489 extern KW_DATA partab [];
490 #endif
491
492 #ifdef _SIMULATION_
493 #define Sprintf sprintf
494 #endif
495
496 /* Number of signals (maximal signalNum which occurs in pei_signal) */
497
498 #define MAX_SIGNALS 10
499
500 /*-------------------------------------------------------------------------*/
501
502 #endif /* IP_H */
503
504 /*-------------------------------------------------------------------------*/
505