yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /******************************************************************************* |
| 37 | * Filename: |
| 38 | * --------- |
| 39 | * ipc_api.h |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * TATAKA |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * IP Core public structure and interface definition. |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *============================================================================== |
| 54 | * HISTORY |
| 55 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 56 | *------------------------------------------------------------------------------ |
| 57 | * removed! |
| 58 | * |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * removed! |
| 62 | * removed! |
| 63 | * |
| 64 | * removed! |
| 65 | * removed! |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * removed! |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * removed! |
| 81 | * removed! |
| 82 | * |
| 83 | * removed! |
| 84 | * removed! |
| 85 | * removed! |
| 86 | * removed! |
| 87 | * |
| 88 | * removed! |
| 89 | * removed! |
| 90 | * removed! |
| 91 | * |
| 92 | * removed! |
| 93 | * removed! |
| 94 | * removed! |
| 95 | * |
| 96 | * removed! |
| 97 | * removed! |
| 98 | * removed! |
| 99 | * removed! |
| 100 | * |
| 101 | * removed! |
| 102 | * removed! |
| 103 | * removed! |
| 104 | * |
| 105 | * removed! |
| 106 | * removed! |
| 107 | * removed! |
| 108 | * |
| 109 | * removed! |
| 110 | * removed! |
| 111 | * removed! |
| 112 | * |
| 113 | * removed! |
| 114 | * removed! |
| 115 | * |
| 116 | * removed! |
| 117 | * removed! |
| 118 | * |
| 119 | * removed! |
| 120 | * removed! |
| 121 | * removed! |
| 122 | * removed! |
| 123 | * removed! |
| 124 | * removed! |
| 125 | * |
| 126 | * removed! |
| 127 | * removed! |
| 128 | * removed! |
| 129 | * removed! |
| 130 | * removed! |
| 131 | * |
| 132 | * removed! |
| 133 | * removed! |
| 134 | * removed! |
| 135 | * |
| 136 | * removed! |
| 137 | * removed! |
| 138 | * removed! |
| 139 | * |
| 140 | * removed! |
| 141 | * removed! |
| 142 | * removed! |
| 143 | * |
| 144 | * removed! |
| 145 | * removed! |
| 146 | * removed! |
| 147 | * removed! |
| 148 | * |
| 149 | * removed! |
| 150 | * removed! |
| 151 | * removed! |
| 152 | * |
| 153 | * removed! |
| 154 | * removed! |
| 155 | * removed! |
| 156 | * removed! |
| 157 | * |
| 158 | * removed! |
| 159 | * removed! |
| 160 | * removed! |
| 161 | * removed! |
| 162 | * |
| 163 | * removed! |
| 164 | * removed! |
| 165 | * removed! |
| 166 | * removed! |
| 167 | * |
| 168 | * removed! |
| 169 | * removed! |
| 170 | * removed! |
| 171 | * |
| 172 | * removed! |
| 173 | * removed! |
| 174 | * removed! |
| 175 | * |
| 176 | * removed! |
| 177 | * removed! |
| 178 | * removed! |
| 179 | * |
| 180 | * removed! |
| 181 | * removed! |
| 182 | * removed! |
| 183 | * removed! |
| 184 | * removed! |
| 185 | * |
| 186 | * removed! |
| 187 | * removed! |
| 188 | * removed! |
| 189 | * removed! |
| 190 | * removed! |
| 191 | * |
| 192 | * removed! |
| 193 | * removed! |
| 194 | * removed! |
| 195 | * removed! |
| 196 | * |
| 197 | * removed! |
| 198 | * removed! |
| 199 | * removed! |
| 200 | * |
| 201 | * removed! |
| 202 | * removed! |
| 203 | * removed! |
| 204 | * removed! |
| 205 | * |
| 206 | * removed! |
| 207 | * removed! |
| 208 | * removed! |
| 209 | * |
| 210 | * removed! |
| 211 | * removed! |
| 212 | * removed! |
| 213 | * |
| 214 | * removed! |
| 215 | * removed! |
| 216 | * removed! |
| 217 | * |
| 218 | * removed! |
| 219 | * removed! |
| 220 | * |
| 221 | * removed! |
| 222 | * removed! |
| 223 | * removed! |
| 224 | * removed! |
| 225 | * |
| 226 | * removed! |
| 227 | * removed! |
| 228 | * removed! |
| 229 | * |
| 230 | * removed! |
| 231 | * removed! |
| 232 | * |
| 233 | * removed! |
| 234 | * removed! |
| 235 | * removed! |
| 236 | * |
| 237 | * removed! |
| 238 | * removed! |
| 239 | * |
| 240 | * removed! |
| 241 | * removed! |
| 242 | * removed! |
| 243 | * removed! |
| 244 | * removed! |
| 245 | * |
| 246 | * removed! |
| 247 | * removed! |
| 248 | * removed! |
| 249 | * removed! |
| 250 | * removed! |
| 251 | * removed! |
| 252 | * removed! |
| 253 | * removed! |
| 254 | * |
| 255 | * removed! |
| 256 | * removed! |
| 257 | * removed! |
| 258 | * removed! |
| 259 | * removed! |
| 260 | * removed! |
| 261 | * |
| 262 | * removed! |
| 263 | * removed! |
| 264 | * removed! |
| 265 | * removed! |
| 266 | * removed! |
| 267 | * removed! |
| 268 | * |
| 269 | * removed! |
| 270 | * removed! |
| 271 | * removed! |
| 272 | * removed! |
| 273 | * |
| 274 | * |
| 275 | * removed! |
| 276 | * removed! |
| 277 | * removed! |
| 278 | * removed! |
| 279 | * removed! |
| 280 | * |
| 281 | * removed! |
| 282 | * removed! |
| 283 | * removed! |
| 284 | * |
| 285 | * removed! |
| 286 | * removed! |
| 287 | * removed! |
| 288 | * |
| 289 | * removed! |
| 290 | * removed! |
| 291 | * |
| 292 | * removed! |
| 293 | * removed! |
| 294 | * removed! |
| 295 | * |
| 296 | * removed! |
| 297 | * removed! |
| 298 | * removed! |
| 299 | * |
| 300 | * removed! |
| 301 | * removed! |
| 302 | * |
| 303 | * removed! |
| 304 | * removed! |
| 305 | * removed! |
| 306 | * |
| 307 | * removed! |
| 308 | * removed! |
| 309 | * |
| 310 | * removed! |
| 311 | * removed! |
| 312 | *------------------------------------------------------------------------------ |
| 313 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 314 | *============================================================================== |
| 315 | *******************************************************************************/ |
| 316 | #ifndef __INC_IPC_API_H |
| 317 | #define __INC_IPC_API_H |
| 318 | |
| 319 | #include "hif_ior.h" |
| 320 | #include "hif_mw_msgid.h" /*< expected to remove it when other other module include the header file */ |
| 321 | #include "lhif_if.h" |
| 322 | |
| 323 | #include "ipc_defs_public.h" |
| 324 | #include "ipc_enums.h" |
| 325 | #include "ipc_struct.h" |
| 326 | |
| 327 | /*------------------------------------------------------------------------------ |
| 328 | * Data structure definition. |
| 329 | *----------------------------------------------------------------------------*/ |
| 330 | typedef struct _ipc_pkt_des_t { |
| 331 | ipc_pkt_des_type_e des_type; |
| 332 | kal_uint8 *packet; |
| 333 | kal_uint32 packet_len; |
| 334 | union { |
| 335 | struct { |
| 336 | qbm_gpd *gpd; |
| 337 | qbm_gpd *bd; |
| 338 | }; |
| 339 | struct { |
| 340 | upcm_did *did; |
| 341 | kal_uint32 pkt_start_idx; |
| 342 | kal_uint16 psn; |
| 343 | }; |
| 344 | struct { |
| 345 | lhif_meta_tbl_t *meta; |
| 346 | }; |
| 347 | struct { |
| 348 | void *ipf_meta; |
| 349 | }; |
| 350 | }; |
| 351 | ipc_filter_t **matched_filter; |
| 352 | ipc_filter_info_t *filter_info; |
| 353 | kal_bool is_packet_info; /**< KAL_TRUE : Already parsed packet_info, KAL_FALSE : Not parsed packet_info yet */ |
| 354 | ipc_packet_info_t *packet_info; |
| 355 | kal_uint8 ip_type; |
| 356 | } ipc_pkt_des_t; |
| 357 | |
| 358 | typedef struct _ipc_pkt_t { |
| 359 | union { |
| 360 | kal_bool isGPD; /**< KAL_TRUE : Describe GPD list (with head/tail), KAL_FALSE : Describe single data buffer (with pointer/length) */ |
| 361 | ipc_pkt_des_type_e buf_type; /**< Buffer type */ |
| 362 | }; |
| 363 | |
| 364 | union { |
| 365 | /* Used if buf_type == IPC_PKT_DES_TYPE_GPD */ |
| 366 | /* Used if isGPD == KAL_FALSE */ |
| 367 | struct { |
| 368 | qbm_gpd *head; /**< Head of GPD List. Used if isGPD == KAL_TRUE */ |
| 369 | qbm_gpd *tail; /**< Tail of GPD List. Used if isGPD == KAL_TRUE */ |
| 370 | }; |
| 371 | |
| 372 | /* Used if buf_type == IPC_PKT_DES_TYPE_DID */ |
| 373 | struct { |
| 374 | upcm_did *did_head; /**< Head of DID List. Used if buf_type == IPC_PKT_DES_TYPE_DID */ |
| 375 | upcm_did *did_tail; /**< Tail of DID List. Used if buf_type == IPC_PKT_DES_TYPE_DID */ |
| 376 | }; |
| 377 | |
| 378 | /* Used if buf_type == IPC_PKT_DES_TYPE_META */ |
| 379 | struct { |
| 380 | kal_uint32 start_idx; /**< Start of meta List. Used if buf_type == IPC_PKT_DES_TYPE_META */ |
| 381 | kal_uint32 end_idx; /**< End of DID List. Used if buf_type == IPC_PKT_DES_TYPE_META */ |
| 382 | }; |
| 383 | }; |
| 384 | |
| 385 | /* Used if buf_type == IPC_PKT_DES_TYPE_NO_DESC */ |
| 386 | /* Used if isGPD == KAL_FALSE */ |
| 387 | kal_uint8 *data; /**< Data pointer of buffer. Used if isGPD == KAL_FALSE */ |
| 388 | kal_uint32 data_len; /**< Data pointer of buffer. Used if isGPD == KAL_FALSE */ |
| 389 | |
| 390 | } ipc_pkt_t; |
| 391 | /*------------------------------------------------------------------------------ |
| 392 | * Helper Macro. |
| 393 | *----------------------------------------------------------------------------*/ |
| 394 | /* |
| 395 | * IPv4/IPv6 common. |
| 396 | */ |
| 397 | #define IPC_NE_GET_1B(_buf) \ |
| 398 | ((kal_uint8)*((kal_uint8 *)(_buf))) |
| 399 | #define IPC_NE_SET_1B(_buf, _value) \ |
| 400 | do { \ |
| 401 | *((kal_uint8 *)(_buf)) = (kal_uint8)(_value); \ |
| 402 | } while (0) |
| 403 | |
| 404 | #ifndef IPC_ON_BIG_ENDIAN_PLATFORM /* little-endian platform */ |
| 405 | #define IPC_NE_GET_2B(_buf) \ |
| 406 | ( (((kal_uint16)*((kal_uint8 *)(_buf) + 0)) << 8) | \ |
| 407 | (((kal_uint16)*((kal_uint8 *)(_buf) + 1)) << 0) ) |
| 408 | |
| 409 | #define IPC_NE_SET_2B(_buf, _value) \ |
| 410 | do { \ |
| 411 | *((kal_uint8 *)(_buf) + 0) = (kal_uint8)((_value) >> 8); \ |
| 412 | *((kal_uint8 *)(_buf) + 1) = (kal_uint8)((_value) >> 0); \ |
| 413 | } while (0) |
| 414 | |
| 415 | #define IPC_NE_GET_4B(_buf) \ |
| 416 | ( (((kal_uint32)*((kal_uint8 *)(_buf) + 0)) << 24) | \ |
| 417 | (((kal_uint32)*((kal_uint8 *)(_buf) + 1)) << 16) | \ |
| 418 | (((kal_uint32)*((kal_uint8 *)(_buf) + 2)) << 8) | \ |
| 419 | (((kal_uint32)*((kal_uint8 *)(_buf) + 3)) << 0) ) |
| 420 | |
| 421 | #define IPC_NE_SET_4B(_buf, _value) \ |
| 422 | do { \ |
| 423 | *((kal_uint8 *)(_buf) + 0) = (kal_uint8)((_value) >> 24); \ |
| 424 | *((kal_uint8 *)(_buf) + 1) = (kal_uint8)((_value) >> 16); \ |
| 425 | *((kal_uint8 *)(_buf) + 2) = (kal_uint8)((_value) >> 8); \ |
| 426 | *((kal_uint8 *)(_buf) + 3) = (kal_uint8)((_value) >> 0); \ |
| 427 | } while (0) |
| 428 | |
| 429 | #define IPC_H2N_2B(_value) \ |
| 430 | (((kal_uint16)(_value) >> 8) | (((kal_uint16)(_value) & 0xff) << 8)) |
| 431 | |
| 432 | #else /* big-endian platform */ |
| 433 | #define IPC_NE_GET_2B(_buf) \ |
| 434 | ( (((kal_uint16)*((kal_uint8 *)(_buf) + 0)) << 0) | \ |
| 435 | (((kal_uint16)*((kal_uint8 *)(_buf) + 1)) << 8) ) |
| 436 | |
| 437 | #define IPC_NE_SET_2B(_buf, _value) \ |
| 438 | do { \ |
| 439 | *((kal_uint8 *)(_buf) + 0) = (kal_uint8)((_value) >> 0); \ |
| 440 | *((kal_uint8 *)(_buf) + 1) = (kal_uint8)((_value) >> 8); \ |
| 441 | } while (0) |
| 442 | |
| 443 | #define IPC_NE_GET_4B(_buf) \ |
| 444 | ( (((kal_uint32)*((kal_uint8 *)(_buf) + 0)) << 0) | \ |
| 445 | (((kal_uint32)*((kal_uint8 *)(_buf) + 1)) << 8) | \ |
| 446 | (((kal_uint32)*((kal_uint8 *)(_buf) + 2)) << 16) | \ |
| 447 | (((kal_uint32)*((kal_uint8 *)(_buf) + 3)) << 24) ) |
| 448 | |
| 449 | #define IPC_NE_SET_4B(_buf, _value) \ |
| 450 | do { \ |
| 451 | *((kal_uint8 *)(_buf) + 0) = (kal_uint8)((_value) >> 0); \ |
| 452 | *((kal_uint8 *)(_buf) + 1) = (kal_uint8)((_value) >> 8); \ |
| 453 | *((kal_uint8 *)(_buf) + 2) = (kal_uint8)((_value) >> 16); \ |
| 454 | *((kal_uint8 *)(_buf) + 3) = (kal_uint8)((_value) >> 24); \ |
| 455 | } while (0) |
| 456 | |
| 457 | #define IPC_H2N_2B(_value) \ |
| 458 | ((kal_uint16)(_value)) |
| 459 | #endif |
| 460 | |
| 461 | #define IPC_HDR_IS_V4(_ip_hdr) \ |
| 462 | (0x40 == (*((kal_uint8 *)(_ip_hdr)) & 0xf0)) |
| 463 | |
| 464 | #define IPC_HDR_IS_V6(_ip_hdr) \ |
| 465 | (0x60 == (*((kal_uint8 *)(_ip_hdr)) & 0xf0)) |
| 466 | |
| 467 | |
| 468 | #define IPC_CP_ADDR(_dst, _src, _len) \ |
| 469 | kal_mem_cpy((_dst), (_src), (_len)) |
| 470 | |
| 471 | #define IPC_EQ_ADDR(_addr1, _addr2, _len) \ |
| 472 | (0 == kal_mem_cmp((_addr1), (_addr2), (_len))) |
| 473 | |
| 474 | #define IPC_EQ_2BYTE(_ptr1, _ptr2) \ |
| 475 | ( ((*(kal_uint8 *)(_ptr1)) == (*((kal_uint8 *)(_ptr2)))) && \ |
| 476 | ((*((kal_uint8 *)(_ptr1) + 1)) == (*(((kal_uint8 *)(_ptr2) + 1)))) ) |
| 477 | |
| 478 | #define IPC_EQ_1BYTE(_ptr1, _ptr2) \ |
| 479 | ((*(kal_uint8 *)(_ptr1)) == (*((kal_uint8 *)(_ptr2)))) |
| 480 | |
| 481 | |
| 482 | /* |
| 483 | * IANA IP Protocol Numbers. |
| 484 | * Ref: http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml |
| 485 | */ |
| 486 | #define IPC_HDR_PROT_IPV6_HOP 0 /* IPv6 Hop-by-Hop Option */ |
| 487 | #define IPC_HDR_PROT_ICMP 1 /* Internet Control Message */ |
| 488 | #define IPC_HDR_PROT_IGMP 2 /* Internet Group Message */ |
| 489 | #define IPC_HDR_PROT_IPV4_ENC 4 /* IPv4 encapsulation */ |
| 490 | #define IPC_HDR_PROT_TCP 6 /* Transmission Control */ |
| 491 | #define IPC_HDR_PROT_UDP 17 /* User Datagram */ |
| 492 | #define IPC_HDR_PROT_IPV6_ENC 41 /* IPv6 encapsulation */ |
| 493 | #define IPC_HDR_PROT_IPV6_ROUTE 43 /* Routing Header for IPv6 */ |
| 494 | #define IPC_HDR_PROT_IPV6_FRAG 44 /* Fragment Header for IPv6 */ |
| 495 | #define IPC_HDR_PROT_ESP 50 /* Encap Security Payload */ |
| 496 | #define IPC_HDR_PROT_AH 51 /* Authentication Header */ |
| 497 | #define IPC_HDR_PROT_ICMPV6 58 /* ICMP for IPv6 */ |
| 498 | #define IPC_HDR_PROT_IPV6_NONEXT 59 /* No Next Header for IPv6 */ |
| 499 | #define IPC_HDR_PROT_IPV6_DEST 60 /* Destination Options for IPv6 */ |
| 500 | |
| 501 | /* |
| 502 | * IPv4. |
| 503 | */ |
| 504 | #define IPC_HDR_V4_ADDR_SIZE (4) |
| 505 | #define IPC_HDR_V4_HEADER_SIZE (20) |
| 506 | |
| 507 | #define IPC_HDR_V4_GET_IHL(_ip_header) \ |
| 508 | ((IPC_NE_GET_1B(_ip_header) & 0x0f) << 2) |
| 509 | |
| 510 | #define IPC_HDR_V4_SET_IHL(_ip_header, _ihl) \ |
| 511 | do { \ |
| 512 | IPC_NE_SET_1B(_ip_header, (IPC_NE_GET_1B(_ip_header) & 0xF0) | (((kal_uint8)(_ihl)>>2) & 0x0F)); \ |
| 513 | } while (0) |
| 514 | |
| 515 | /* |
| 516 | * 2016/02/24 Peter.Hsu |
| 517 | * To support ECN, we extend existing DSCP API to cover ECN due to backward compatibility. |
| 518 | */ |
| 519 | |
| 520 | /* Get/Set both DSCP & ECN (total 8 bits) */ |
| 521 | #define IPC_HDR_V4_GET_DSCP(_ip_header) \ |
| 522 | (IPC_NE_GET_1B(((kal_uint8*)(_ip_header)) + 1)) |
| 523 | |
| 524 | #define IPC_HDR_V4_SET_DSCP(_ip_header, _dscp_ecn) \ |
| 525 | do { \ |
| 526 | IPC_NE_SET_1B(((kal_uint8*)(_ip_header)) + 1, IPC_NE_GET_1B(((kal_uint8*)(_ip_header)) + 1) | (kal_uint8)(_dscp_ecn)); \ |
| 527 | } while (0) |
| 528 | |
| 529 | #define IPC_HDR_V4_RESET_VER_IHL_DSCP_ECN(_ip_header) \ |
| 530 | do { \ |
| 531 | IPC_NE_SET_1B(_ip_header, 0x45); \ |
| 532 | IPC_NE_SET_1B(((kal_uint8 *)(_ip_header)) + 1, 0x00); \ |
| 533 | } while (0) |
| 534 | |
| 535 | #define IPC_HDR_V4_GET_TOTAL_LENGTH(_ip_header) \ |
| 536 | IPC_NE_GET_2B(((kal_uint8 *)(_ip_header)) + 2) |
| 537 | |
| 538 | #define IPC_HDR_V4_SET_TOTAL_LENGTH(_ip_header, _length) \ |
| 539 | do { \ |
| 540 | IPC_NE_SET_2B(((kal_uint8 *)(_ip_header)) + 2, _length); \ |
| 541 | } while (0) |
| 542 | |
| 543 | #define IPC_HDR_V4_GET_IDENTITY(_ip_header) \ |
| 544 | IPC_NE_GET_2B(((kal_uint8 *)(_ip_header)) + 4) |
| 545 | |
| 546 | #define IPC_HDR_V4_SET_IDENTITY(_ip_header, _id) \ |
| 547 | do { \ |
| 548 | IPC_NE_SET_2B(((kal_uint8 *)(_ip_header)) + 4, _id); \ |
| 549 | } while (0) |
| 550 | |
| 551 | #define IPC_HDR_V4_GET_FLAGS(_ip_header) \ |
| 552 | ((*(((kal_uint8 *)(_ip_header) + 6))) >> 5) |
| 553 | |
| 554 | #define IPC_HDR_V4_SET_FLAGS(_ip_header, _flags) \ |
| 555 | do { \ |
| 556 | IPC_NE_SET_1B(((kal_uint8*)(_ip_header)) + 6, (IPC_NE_GET_1B(((kal_uint8*)(_ip_header)) + 6) & 0x1F) | ((kal_uint8)(_flags) << 5));\ |
| 557 | } while (0) |
| 558 | |
| 559 | #define IPC_HDR_V4_IS_MF(_ip_header) \ |
| 560 | (IPC_HDR_V4_GET_FLAGS(_ip_header) & 0x04) |
| 561 | |
| 562 | #define IPC_HDR_V4_GET_FRAG_OFFSET(_ip_header) \ |
| 563 | (IPC_NE_GET_2B(((kal_uint8 *)(_ip_header)) + 6) & 0x1fff) |
| 564 | |
| 565 | #define IPC_HDR_V4_SET_FRAG_OFFSET(_ip_header, _offset) \ |
| 566 | do { \ |
| 567 | IPC_NE_SET_2B((((kal_uint8 *)(_ip_header)) + 6), \ |
| 568 | ((IPC_NE_GET_2B(((kal_uint8 *)(_ip_header)) + 6) & 0xe000) | \ |
| 569 | ((kal_uint16)(_offset) & 0x1fff)) ); \ |
| 570 | } while (0) |
| 571 | |
| 572 | #define IPC_HDR_V4_IS_FRAG(_ip_header) \ |
| 573 | (IPC_HDR_V4_IS_MF(_ip_header) || (0 != IPC_HDR_V4_GET_FRAG_OFFSET(_ip_header))) |
| 574 | |
| 575 | #define IPC_HDR_V4_GET_TTL(_ip_header) \ |
| 576 | IPC_NE_GET_1B(((kal_uint8 *)(_ip_header)) + 8) |
| 577 | |
| 578 | #define IPC_HDR_V4_SET_TTL(_ip_header, _ttl) \ |
| 579 | do { \ |
| 580 | IPC_NE_SET_1B(((kal_uint8 *)(_ip_header)) + 8, (kal_uint8)(_ttl)); \ |
| 581 | } while (0) |
| 582 | |
| 583 | #define IPC_HDR_V4_GET_PROTOCOL(_ip_header) \ |
| 584 | IPC_NE_GET_1B(((kal_uint8 *)(_ip_header)) + 9) |
| 585 | |
| 586 | #define IPC_HDR_V4_SET_PROTOCOL(_ip_header, _protocol) \ |
| 587 | do { \ |
| 588 | IPC_NE_SET_1B(((kal_uint8 *)(_ip_header)) + 9, (kal_uint8)(_protocol)); \ |
| 589 | } while (0) |
| 590 | |
| 591 | #define IPC_HDR_V4_EQ_PROTOCOL(_ip_header, _protocol) \ |
| 592 | (IPC_HDR_V4_GET_PROTOCOL(_ip_header) == (_protocol)) |
| 593 | |
| 594 | #define IPC_HDR_V4_GET_HEADER_CHECKSUM(_ip_header) \ |
| 595 | IPC_NE_GET_2B((kal_uint8 *)(_ip_header) + 10) |
| 596 | |
| 597 | #define IPC_HDR_V4_SET_HEADER_CHECKSUM(_ip_header, _checksum) \ |
| 598 | do { \ |
| 599 | IPC_NE_SET_2B((kal_uint8 *)(_ip_header) + 10, _checksum); \ |
| 600 | } while (0) |
| 601 | |
| 602 | #define IPC_HDR_V4_GET_SRC_ADDR(_ip_header) \ |
| 603 | ((kal_uint8 *)(_ip_header) + 12) |
| 604 | |
| 605 | #define IPC_HDR_V4_SET_SRC_ADDR(_ip_header, _src_ip_addr) \ |
| 606 | do { \ |
| 607 | IPC_CP_V4_ADDR(IPC_HDR_V4_GET_SRC_ADDR(_ip_header), _src_ip_addr); \ |
| 608 | } while (0) |
| 609 | |
| 610 | #define IPC_HDR_V4_GET_DST_ADDR(_ip_header) \ |
| 611 | ((kal_uint8 *)(_ip_header) + 16) |
| 612 | |
| 613 | #define IPC_HDR_V4_SET_DST_ADDR(_ip_header, _dst_ip_addr) \ |
| 614 | do { \ |
| 615 | IPC_CP_V4_ADDR(IPC_HDR_V4_GET_DST_ADDR(_ip_header), _dst_ip_addr); \ |
| 616 | } while (0) |
| 617 | |
| 618 | #define IPC_HDR_V4_GET_NHPTR(_ip_header) \ |
| 619 | ((kal_uint8 *)(_ip_header) + IPC_HDR_V4_GET_IHL(_ip_header)) |
| 620 | |
| 621 | #define IPC_CP_V4_ADDR(_dst, _src) \ |
| 622 | do { \ |
| 623 | IPC_CP_ADDR(_dst, _src, IPC_HDR_V4_ADDR_SIZE); \ |
| 624 | } while (0) |
| 625 | |
| 626 | #define IPC_EQ_V4_ADDR(_addr1, _addr2) \ |
| 627 | IPC_EQ_ADDR(_addr1, _addr2, IPC_HDR_V4_ADDR_SIZE) |
| 628 | |
| 629 | #define IPC_IS_V4_CLASSA_ADDR(_addr) \ |
| 630 | ( 0x00 == (*((kal_uint8 *)(_addr)) & 0xf0) ) |
| 631 | |
| 632 | #define IPC_IS_V4_CLASSB_ADDR(_addr) \ |
| 633 | ( 0x80 == (*((kal_uint8 *)(_addr)) & 0xf0) ) |
| 634 | |
| 635 | #define IPC_IS_V4_CLASSC_ADDR(_addr) \ |
| 636 | ( 0xc0 == (*((kal_uint8 *)(_addr)) & 0xf0) ) |
| 637 | |
| 638 | #define IPC_IS_V4_CLASSD_ADDR(_addr) \ |
| 639 | ( 0xe0 == (*((kal_uint8 *)(_addr)) & 0xf0) ) |
| 640 | |
| 641 | #define IPC_IS_V4_UNSPECIFIED_ADDR(_addr) \ |
| 642 | ( 0 == *((kal_uint8*)(_addr)) && \ |
| 643 | 0 == *((kal_uint8*)(_addr)+1) && \ |
| 644 | 0 == *((kal_uint8*)(_addr)+2) && \ |
| 645 | 0 == *((kal_uint8*)(_addr)+3) ) |
| 646 | |
| 647 | /* |
| 648 | * IPv6. |
| 649 | */ |
| 650 | #define IPC_HDR_V6_ADDR_SIZE (16) |
| 651 | #define IPC_HDR_V6_HEADER_SIZE (40) |
| 652 | #define IPC_HDR_V6_MAX_HOP (255) |
| 653 | |
| 654 | #define IPC_HDR_V6_LENGTH_OFFSET (4) |
| 655 | #define IPC_HDR_V6_NH_TYPE_OFFSET (6) |
| 656 | #define IPC_HDR_V6_HOP_LIMIT_OFFSET (7) |
| 657 | #define IPC_HDR_V6_SRC_ADDR_OFFSET (8) |
| 658 | #define IPC_HDR_V6_DST_ADDR_OFFSET (24) |
| 659 | |
| 660 | #define IPC_HDR_V6_GET_TC(_ip_header) \ |
| 661 | ((IPC_NE_GET_2B(_ip_header) >> 4) & 0xff) |
| 662 | |
| 663 | #define IPC_HDR_V6_SET_TC(_ip_header, _tc) \ |
| 664 | do { \ |
| 665 | IPC_NE_SET_2B(_ip_header, \ |
| 666 | ((IPC_NE_GET_2B(_ip_header) & 0xf00f) | (((kal_uint16)(_tc) & 0xff) << 4))); \ |
| 667 | } while (0) |
| 668 | |
| 669 | #define IPC_HDR_V6_GET_FLOW_LABEL(_ip_header) \ |
| 670 | (IPC_NE_GET_4B(_ip_header) & 0xfffff) |
| 671 | |
| 672 | #define IPC_HDR_V6_SET_FLOW_LABEL(_ip_header, _flow_label) \ |
| 673 | do { \ |
| 674 | IPC_NE_SET_4B(_ip_header, \ |
| 675 | ((IPC_NE_GET_4B(_ip_header) & 0xfff00000) | ((kal_uint32)(_flow_label) & 0xfffff))); \ |
| 676 | } while (0) |
| 677 | |
| 678 | #define IPC_HDR_V6_RESET_VER_TC_FL(_ip_header) \ |
| 679 | do { \ |
| 680 | kal_mem_set((kal_uint8 *)(_ip_header), 0, 4); \ |
| 681 | *((kal_uint8 *)(_ip_header)) |= 0x60; \ |
| 682 | } while (0) |
| 683 | |
| 684 | #define IPC_HDR_V6_GET_LENGTH(_ip_header) \ |
| 685 | IPC_NE_GET_2B((kal_uint8 *)(_ip_header) + IPC_HDR_V6_LENGTH_OFFSET) |
| 686 | |
| 687 | #define IPC_HDR_V6_SET_LENGTH(_ip_header, _length) \ |
| 688 | do { \ |
| 689 | IPC_NE_SET_2B((kal_uint8 *)(_ip_header) + IPC_HDR_V6_LENGTH_OFFSET, _length); \ |
| 690 | } while (0) |
| 691 | |
| 692 | #define IPC_HDR_V6_GET_NH_TYPE(_ip_header) \ |
| 693 | IPC_NE_GET_1B(((kal_uint8 *)(_ip_header)) + IPC_HDR_V6_NH_TYPE_OFFSET) |
| 694 | |
| 695 | #define IPC_HDR_V6_SET_NH_TYPE(_ip_header, _type) \ |
| 696 | do { \ |
| 697 | IPC_NE_SET_1B(((kal_uint8 *)(_ip_header)) + IPC_HDR_V6_NH_TYPE_OFFSET, (kal_uint8)(_type)); \ |
| 698 | } while (0) |
| 699 | |
| 700 | #define IPC_HDR_V6_GET_HOP_LIMIT(_ip_header) \ |
| 701 | IPC_NE_GET_1B((kal_uint8 *)(_ip_header) + IPC_HDR_V6_HOP_LIMIT_OFFSET) |
| 702 | |
| 703 | #define IPC_HDR_V6_SET_HOP_LIMIT(_ip_header, _hop_limit) \ |
| 704 | do { \ |
| 705 | IPC_NE_SET_1B(((kal_uint8 *)(_ip_header)) + IPC_HDR_V6_HOP_LIMIT_OFFSET, (kal_uint8)(_hop_limit)); \ |
| 706 | } while (0) |
| 707 | |
| 708 | #define IPC_HDR_V6_GET_SRC_ADDR(_ip_header) \ |
| 709 | ((kal_uint8 *)(_ip_header) + IPC_HDR_V6_SRC_ADDR_OFFSET) |
| 710 | |
| 711 | #define IPC_HDR_V6_SET_SRC_ADDR(_ip_header, _src_ip_addr) \ |
| 712 | do { \ |
| 713 | IPC_CP_V6_ADDR(IPC_HDR_V6_GET_SRC_ADDR(_ip_header), _src_ip_addr); \ |
| 714 | } while (0) |
| 715 | |
| 716 | #define IPC_HDR_V6_GET_DST_ADDR(_ip_header) \ |
| 717 | ((kal_uint8 *)(_ip_header) + IPC_HDR_V6_DST_ADDR_OFFSET) |
| 718 | |
| 719 | #define IPC_HDR_V6_SET_DST_ADDR(_ip_header, _dst_ip_addr) \ |
| 720 | do { \ |
| 721 | IPC_CP_V6_ADDR(IPC_HDR_V6_GET_DST_ADDR(_ip_header), _dst_ip_addr); \ |
| 722 | } while (0) |
| 723 | |
| 724 | #define IPC_HDR_V6_GET_NHPTR(_ip_header) \ |
| 725 | ((kal_uint8 *)(_ip_header) + IPC_HDR_V6_HEADER_SIZE) |
| 726 | |
| 727 | #define IPC_HDR_V6_SET_DST_SOL_MCST_ADDR(_ip_header, _dst_ip_addr) \ |
| 728 | do { \ |
| 729 | *(IPC_HDR_V6_GET_DST_ADDR(_ip_header)) = 0xff; \ |
| 730 | *(IPC_HDR_V6_GET_DST_ADDR(_ip_header) + 1) = 0x02; \ |
| 731 | kal_mem_set(IPC_HDR_V6_GET_DST_ADDR(_ip_header) + 2, 0, 9); \ |
| 732 | *(IPC_HDR_V6_GET_DST_ADDR(_ip_header) + 11) = 0x01; \ |
| 733 | *(IPC_HDR_V6_GET_DST_ADDR(_ip_header) + 12) = 0xff; \ |
| 734 | kal_mem_cpy(IPC_HDR_V6_GET_DST_ADDR(_ip_header) + 13, (kal_uint8 *)(_dst_ip_addr) + 13, 3); \ |
| 735 | } while (0) |
| 736 | |
| 737 | #define IPC_HDR_V6EXT_GET_NH_TYPE(_ext_header) \ |
| 738 | IPC_NE_GET_1B(_ext_header) |
| 739 | |
| 740 | #define IPC_HDR_V6EXT_GET_HDR_EXT_LEN(_ext_header) \ |
| 741 | ((IPC_NE_GET_1B(((kal_uint8*)(_ext_header))+1) + 1) << 3) |
| 742 | |
| 743 | #define IPC_IS_V6_LINK_LOCAL_ADDR(_addr) \ |
| 744 | ( (0xfe == IPC_NE_GET_1B(_addr)) && \ |
| 745 | (0x80 == IPC_NE_GET_1B(((kal_uint8*)(_addr)) + 1))) |
| 746 | |
| 747 | #define IPC_IS_V6_GLOBAL_ADDR(_addr) \ |
| 748 | ( 0x20 == (IPC_NE_GET_1B(_addr) & 0xe0) ) |
| 749 | |
| 750 | #define IPC_IS_V6_UNSPECIFIED_ADDR(_addr) \ |
| 751 | ( 0x00 == *((kal_uint8 *)(_addr)) && \ |
| 752 | 0x00 == *((kal_uint8 *)(_addr) + 1) && \ |
| 753 | 0x00 == *((kal_uint8 *)(_addr) + 2) && \ |
| 754 | 0x00 == *((kal_uint8 *)(_addr) + 3) && \ |
| 755 | 0x00 == *((kal_uint8 *)(_addr) + 4) && \ |
| 756 | 0x00 == *((kal_uint8 *)(_addr) + 5) && \ |
| 757 | 0x00 == *((kal_uint8 *)(_addr) + 6) && \ |
| 758 | 0x00 == *((kal_uint8 *)(_addr) + 7) && \ |
| 759 | 0x00 == *((kal_uint8 *)(_addr) + 8) && \ |
| 760 | 0x00 == *((kal_uint8 *)(_addr) + 9) && \ |
| 761 | 0x00 == *((kal_uint8 *)(_addr) + 10) && \ |
| 762 | 0x00 == *((kal_uint8 *)(_addr) + 11) && \ |
| 763 | 0x00 == *((kal_uint8 *)(_addr) + 12) && \ |
| 764 | 0x00 == *((kal_uint8 *)(_addr) + 13) && \ |
| 765 | 0x00 == *((kal_uint8 *)(_addr) + 14) && \ |
| 766 | 0x00 == *((kal_uint8 *)(_addr) + 15)) |
| 767 | |
| 768 | #define IPC_IS_V6_MCST_ADDR(_addr) \ |
| 769 | ( 0xff == IPC_NE_GET_1B(_addr) ) |
| 770 | |
| 771 | #define IPC_CP_V6_ADDR(_dst, _src) \ |
| 772 | IPC_CP_ADDR(_dst, _src, IPC_HDR_V6_ADDR_SIZE) |
| 773 | |
| 774 | #define IPC_EQ_V6_ADDR(_addr1, _addr2) \ |
| 775 | IPC_EQ_ADDR(_addr1, _addr2, IPC_HDR_V6_ADDR_SIZE) |
| 776 | |
| 777 | /* |
| 778 | * IPv6 fragment header |
| 779 | */ |
| 780 | #define IPC_HDR_V6_FRAGMENT_HEADER_SIZE (8) |
| 781 | |
| 782 | /* |
| 783 | * UDP. |
| 784 | */ |
| 785 | #define IPC_HDR_UDP_HEADER_SIZE (8) |
| 786 | |
| 787 | #define IPC_HDR_UDP_GET_SRC_PORT(_udp) \ |
| 788 | IPC_NE_GET_2B(_udp) |
| 789 | |
| 790 | #define IPC_HDR_UDP_SET_SRC_PORT(_udp, _src_port) \ |
| 791 | IPC_NE_SET_2B((kal_uint8 *)(_udp), _src_port) |
| 792 | |
| 793 | #define IPC_HDR_UDP_EQ_SRC_PORT(_udp, _src_port) \ |
| 794 | (IPC_HDR_UDP_GET_SRC_PORT(_udp) == (_src_port)) |
| 795 | |
| 796 | #define IPC_HDR_UDP_GET_DST_PORT(_udp) \ |
| 797 | IPC_NE_GET_2B((kal_uint8 *)(_udp) + 2) |
| 798 | |
| 799 | #define IPC_HDR_UDP_SET_DST_PORT(_udp, _dst_port) \ |
| 800 | IPC_NE_SET_2B((kal_uint8 *)(_udp) + 2, _dst_port) |
| 801 | |
| 802 | #define IPC_HDR_UDP_EQ_DST_PORT(_udp, _dst_port) \ |
| 803 | (IPC_HDR_UDP_GET_DST_PORT(_udp) == (_dst_port)) |
| 804 | |
| 805 | #define IPC_HDR_UDP_GET_LENGTH(_udp) \ |
| 806 | IPC_NE_GET_2B((kal_uint8 *)(_udp) + 4) |
| 807 | |
| 808 | #define IPC_HDR_UDP_SET_LENGTH(_udp, _length) \ |
| 809 | IPC_NE_SET_2B((kal_uint8 *)(_udp) + 4, _length) |
| 810 | |
| 811 | #define IPC_HDR_UDP_GET_CHECKSUM(_udp) \ |
| 812 | IPC_NE_GET_2B((kal_uint8 *)(_udp) + 6) |
| 813 | |
| 814 | #define IPC_HDR_UDP_SET_CHECKSUM(_udp, _checksum) \ |
| 815 | IPC_NE_SET_2B((kal_uint8 *)(_udp) + 6, _checksum) |
| 816 | |
| 817 | /* |
| 818 | * TCP. |
| 819 | */ |
| 820 | #define IPC_HDR_TCP_FLAG_FIN 0x01 |
| 821 | #define IPC_HDR_TCP_FLAG_SYN 0x02 |
| 822 | #define IPC_HDR_TCP_FLAG_RST 0x04 // Reset |
| 823 | #define IPC_HDR_TCP_FLAG_PUSH 0x08 |
| 824 | #define IPC_HDR_TCP_FLAG_ACK 0x10 |
| 825 | #define IPC_HDR_TCP_FLAG_URG 0x20 // Urgent |
| 826 | #define IPC_HDR_TCP_FLAG_ECE 0x40 // ECN Echo |
| 827 | #define IPC_HDR_TCP_FLAG_CWR 0x80 // Congestion Window Reduced |
| 828 | #define IPC_HDR_TCP_FLAG_NS 0x100 // ECN-nonce concealment protection (added to header by RFC 3540) |
| 829 | |
| 830 | |
| 831 | #define IPC_HDR_TCP_HEADER_SIZE (20) |
| 832 | |
| 833 | #define IPC_HDR_TCP_GET_SRC_PORT(_tcp) \ |
| 834 | IPC_NE_GET_2B(_tcp) |
| 835 | |
| 836 | #define IPC_HDR_TCP_SET_SRC_PORT(_tcp, _src_port) \ |
| 837 | IPC_NE_SET_2B(_tcp, _src_port) |
| 838 | |
| 839 | #define IPC_HDR_TCP_EQ_SRC_PORT(_tcp, _src_port) \ |
| 840 | (IPC_HDR_TCP_GET_SRC_PORT(_tcp) == (_src_port)) |
| 841 | |
| 842 | #define IPC_HDR_TCP_GET_DST_PORT(_tcp) \ |
| 843 | IPC_NE_GET_2B((kal_uint8 *)(_tcp) + 2) |
| 844 | |
| 845 | #define IPC_HDR_TCP_SET_DST_PORT(_tcp, _dst_port) \ |
| 846 | IPC_NE_SET_2B((kal_uint8 *)(_tcp) + 2, _dst_port) |
| 847 | |
| 848 | #define IPC_HDR_TCP_EQ_DST_PORT(_tcp, _dst_port) \ |
| 849 | (IPC_HDR_TCP_GET_DST_PORT(_tcp) == (_dst_port)) |
| 850 | |
| 851 | #define IPC_HDR_TCP_GET_SEQ_NUM(_tcp) \ |
| 852 | IPC_NE_GET_4B((kal_uint8 *)(_tcp) + 4) |
| 853 | |
| 854 | #define IPC_HDR_TCP_SET_SEQ_NUM(_tcp, _seq_num) \ |
| 855 | IPC_NE_SET_4B((kal_uint8 *)(_tcp) + 4, _seq_num) |
| 856 | |
| 857 | #define IPC_HDR_TCP_EQ_SEQ_NUM(_tcp, _seq_num) \ |
| 858 | (IPC_HDR_TCP_GET_SEQ_NUM(_tcp) == (_seq_num)) |
| 859 | |
| 860 | #define IPC_HDR_TCP_GET_ACK_NUM(_tcp) \ |
| 861 | IPC_NE_GET_4B((kal_uint8 *)(_tcp) + 8) |
| 862 | |
| 863 | #define IPC_HDR_TCP_SET_ACK_NUM(_tcp, _ack_num) \ |
| 864 | IPC_NE_SET_4B((kal_uint8 *)(_tcp) + 8, _ack_num) |
| 865 | |
| 866 | #define IPC_HDR_TCP_EQ_ACK_NUM(_tcp, _ack_num) \ |
| 867 | (IPC_HDR_TCP_GET_ACK_NUM(_tcp) == (_ack_num)) |
| 868 | |
| 869 | #define IPC_HDR_TCP_GET_OFFSET(_tcp) \ |
| 870 | ((IPC_NE_GET_1B((kal_uint8 *)(_tcp) + 12) & 0xF0) >> 2) |
| 871 | |
| 872 | #define IPC_HDR_TCP_SET_OFFSET(_tcp, _offset) \ |
| 873 | do { \ |
| 874 | IPC_NE_SET_1B((kal_uint8 *)(_tcp) + 12, (IPC_NE_GET_1B((kal_uint8 *)(_tcp) + 12) & 0x0F) | ((((kal_uint8)(_offset)>>2)<<4) & 0xF0)); \ |
| 875 | } while (0) |
| 876 | |
| 877 | #define IPC_HDR_TCP_GET_RESERVED(_tcp) \ |
| 878 | ((IPC_NE_GET_1B((kal_uint8 *)(_tcp) + 12) >> 1) & 0x07) |
| 879 | |
| 880 | #define IPC_HDR_TCP_SET_RESERVED(_tcp, _reserved) \ |
| 881 | do { \ |
| 882 | IPC_NE_SET_1B((kal_uint8 *)(_tcp) + 12, (IPC_NE_GET_1B((kal_uint8 *)(_tcp) + 12) & 0xF1) | (((kal_uint8)(_reserved) << 1) & 0x0E)); \ |
| 883 | } while (0) |
| 884 | |
| 885 | #define IPC_HDR_TCP_GET_FLAGS(_tcp) \ |
| 886 | (IPC_NE_GET_2B((kal_uint8 *)(_tcp) + 12) & 0x01FF) |
| 887 | |
| 888 | #define IPC_HDR_TCP_SET_FLAGS(_tcp, _flags) \ |
| 889 | do { \ |
| 890 | IPC_NE_SET_2B((kal_uint8 *)(_tcp) + 12, (IPC_NE_GET_2B((kal_uint8 *)(_tcp) + 12) & 0xFE00) | ((_flags) & 0x01FF)); \ |
| 891 | } while (0) |
| 892 | |
| 893 | #define IPC_HDR_TCP_GET_WINDOW(_tcp) \ |
| 894 | IPC_NE_GET_2B((kal_uint8 *)(_tcp) + 14) |
| 895 | |
| 896 | #define IPC_HDR_TCP_SET_WINDOW(_tcp, _window) \ |
| 897 | IPC_NE_SET_2B((kal_uint8 *)(_tcp) + 14, _window) |
| 898 | |
| 899 | #define IPC_HDR_TCP_GET_CHECKSUM(_tcp) \ |
| 900 | IPC_NE_GET_2B((kal_uint8 *)(_tcp) + 16) |
| 901 | |
| 902 | #define IPC_HDR_TCP_SET_CHECKSUM(_tcp, _checksum) \ |
| 903 | IPC_NE_SET_2B((kal_uint8 *)(_tcp) + 16, _checksum) |
| 904 | |
| 905 | #define IPC_HDR_TCP_GET_URGENT_PTR(_tcp) \ |
| 906 | IPC_NE_GET_2B((kal_uint8 *)(_tcp) + 18) |
| 907 | |
| 908 | #define IPC_HDR_TCP_SET_URGENT_PTR(_tcp, _urp) \ |
| 909 | IPC_NE_SET_2B((kal_uint8 *)(_tcp) + 18, _urp) |
| 910 | /* |
| 911 | * ICMP. |
| 912 | */ |
| 913 | #define IPC_HDR_ICMP_HEADER_SIZE (8) |
| 914 | |
| 915 | #define IPC_HDR_ICMP_TYPE_ECHO_REQUEST (8) |
| 916 | #define IPC_HDR_ICMP_TYPE_ECHO_REPLY (0) |
| 917 | #define IPC_HDR_ICMP_TYPE_RS (10) |
| 918 | #define IPC_HDR_ICMP_TYPE_RA (9) |
| 919 | |
| 920 | #define IPC_HDR_ICMPV6_TYPE_ECHO_REQUEST (128) |
| 921 | #define IPC_HDR_ICMPV6_TYPE_ECHO_REPLY (129) |
| 922 | #define IPC_HDR_ICMPV6_TYPE_RS (133) |
| 923 | #define IPC_HDR_ICMPV6_TYPE_RA (134) |
| 924 | |
| 925 | #define IPC_HDR_ICMP_GET_TYPE(_icmp) \ |
| 926 | IPC_NE_GET_1B(_icmp) |
| 927 | |
| 928 | #define IPC_HDR_ICMP_SET_TYPE(_icmp, _type) \ |
| 929 | IPC_NE_SET_1B(_icmp, _type) |
| 930 | |
| 931 | #define IPC_HDR_ICMP_EQ_TYPE(_icmp, _type) \ |
| 932 | (IPC_HDR_ICMP_GET_TYPE(_icmp) == (_type)) |
| 933 | |
| 934 | #define IPC_HDR_ICMP_GET_CODE(_icmp) \ |
| 935 | IPC_NE_GET_1B((kal_uint8 *)(_icmp) + 1) |
| 936 | |
| 937 | #define IPC_HDR_ICMP_SET_CODE(_icmp, _code) \ |
| 938 | IPC_NE_SET_1B((kal_uint8 *)(_icmp) + 1, (_code)) |
| 939 | |
| 940 | #define IPC_HDR_ICMP_EQ_CODE(_icmp, _code) \ |
| 941 | (IPC_HDR_ICMP_GET_CODE(_icmp) == (_code)) |
| 942 | |
| 943 | #define IPC_HDR_ICMP_GET_CHECKSUM(_icmp) \ |
| 944 | IPC_NE_GET_2B((kal_uint8 *)(_icmp) + 2) |
| 945 | |
| 946 | #define IPC_HDR_ICMP_SET_CHECKSUM(_icmp, _checksum) \ |
| 947 | IPC_NE_SET_2B((kal_uint8 *)(_icmp) + 2, _checksum) |
| 948 | |
| 949 | #define IPC_HDR_ICMP_SET_UNUSED(_icmp, _value) \ |
| 950 | IPC_NE_SET_4B((kal_uint8 *)(_icmp) + 4, _value) |
| 951 | /* |
| 952 | * Ports. |
| 953 | */ |
| 954 | #define IPC_PORT_BOOTPS (67) |
| 955 | #define IPC_PORT_BOOTPC (68) |
| 956 | |
| 957 | /* |
| 958 | * Helper functions |
| 959 | */ |
| 960 | #define ipc_get_netif_id_from_l2p_chid(_ipc_l2p_enum, _chid) ((kal_uint32)(_ipc_l2p_enum | _chid)) |
| 961 | |
| 962 | /*------------------------------------------------------------------------------ |
| 963 | * Public functions. |
| 964 | *----------------------------------------------------------------------------*/ |
| 965 | /** |
| 966 | * Allow HIF side module, such as ethercore or ppp, to register callback functions, |
| 967 | * callback context, and module id for a network interface. |
| 968 | * |
| 969 | * @param config [IN] The information required to regerster a network interface. |
| 970 | * @param handle [OUT] Caller allocated space to store a handle to the network interface attached. |
| 971 | * It returns a IPC_INVALID_HANDLE if failed. |
| 972 | * |
| 973 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 974 | */ |
| 975 | kal_bool ipc_attach(ipc_conf_t *config, ipc_handle_t *handle); |
| 976 | |
| 977 | /** |
| 978 | * Detach the network interface. |
| 979 | * |
| 980 | * @param handle [IN] Handle to the network interface to detach. |
| 981 | * |
| 982 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 983 | */ |
| 984 | kal_bool ipc_detach(ipc_handle_t handle); |
| 985 | |
| 986 | /** |
| 987 | * Send a list of IP datagrams to wireless network. |
| 988 | * |
| 989 | * @param handle [IN] Handle to the network interface attached. |
| 990 | * @param ior [IN] It wraps up a set of uplink GPD to send. |
| 991 | * |
| 992 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 993 | */ |
| 994 | kal_bool ipc_uplink(ipc_handle_t handle, ipc_io_request_t *ior); |
| 995 | |
| 996 | /** |
| 997 | * Retrieve index of a set of IPv4/IPv6 addresses. |
| 998 | * |
| 999 | * @param handle [IN] Handle to the network interface attached. |
| 1000 | * |
| 1001 | * @return Non-negtive value as a valid index, netgative value for an invalid one (e.g. before session established.). |
| 1002 | */ |
| 1003 | kal_int32 ipc_get_ip_id(ipc_handle_t handle); |
| 1004 | |
| 1005 | /** |
| 1006 | * Force reloading buffers for the network interface to receive uplink traffic. |
| 1007 | * |
| 1008 | * @param handle [IN] Handle to the network interface attached. |
| 1009 | */ |
| 1010 | void ipc_need_ul_reload(ipc_handle_t handle); |
| 1011 | |
| 1012 | /** |
| 1013 | * Check if any network interfaces need uplink reload retry, |
| 1014 | * if so, send an ILM to IPCORE to do uplink reload. |
| 1015 | */ |
| 1016 | void ipc_check_ul_reload_retry(void); |
| 1017 | |
| 1018 | /** |
| 1019 | * Manually notify the HIF network interface link/IP status changed. (This API does NOT change IP Core internal FSM !) |
| 1020 | * |
| 1021 | * @param netif_id [IN] The network interface ID. |
| 1022 | * @param ip_type [IN] Type of the PDN, IPC_IP_TYPE_IPV4, IPC_IP_TYPE_IPV6, or IPC_IP_TYPE_MIXED. |
| 1023 | * @param link_update[IN] KAL_TRUE if an IP session is established/deactived and link status is changed. KAL_FALSE if an IP information is updated for an activated IP session. |
| 1024 | * @param link_up [IN] (If link_update is KAL_TRUE) KAL_TRUE if an IP session is established, KAL_FALSE if an IP session is deactived ; |
| 1025 | (If link_update is KAL_FALSE) KAL_TRUE if new IP information is available, KAL_FALSE if original IP information is obsoleted |
| 1026 | */ |
| 1027 | void ipc_notify_link_change(kal_uint32 netif_id, kal_uint8 ip_type, kal_bool link_update, kal_bool is_up); |
| 1028 | |
| 1029 | /** |
| 1030 | * Install callback function and filtering rules for uplink traffic. |
| 1031 | * |
| 1032 | * @param rules [IN] Rules to filter of uplink IP datagrams. |
| 1033 | * @param callback_func [IN] Callback function for a uplink IP datagram matched the rules. |
| 1034 | * @param callback_context [IN] Context to pass in the callback function. |
| 1035 | * |
| 1036 | * @return Zero or postive value as filter ID if registration succeeded, negative value if it failed. |
| 1037 | */ |
| 1038 | kal_int32 ipc_register_ul_filter_cbk(ipc_filter_rules_t *rules, |
| 1039 | ipc_filter_callback_t callback_func, |
| 1040 | void *callback_context); |
| 1041 | |
| 1042 | /** |
| 1043 | * Install callback function and filtering rules for downlink traffic. |
| 1044 | * |
| 1045 | * @param rules [IN] Rules to filter of downlink IP datagrams. |
| 1046 | * @param callback_func [IN] Callback function for a downlink IP datagram matched the rules. |
| 1047 | * @param callback_context [IN] Context to pass in the callback function. |
| 1048 | * |
| 1049 | * @return Zero or postive value as filter ID if registration succeeded, negative value if it failed. |
| 1050 | */ |
| 1051 | kal_int32 ipc_register_dl_filter_cbk(ipc_filter_rules_t *rules, |
| 1052 | ipc_filter_callback_t callback_func, |
| 1053 | void *callback_context); |
| 1054 | |
| 1055 | /** |
| 1056 | * Install module ID and filtering rules for uplink traffic. |
| 1057 | * |
| 1058 | * @param rules [IN] Rules to filter of uplink IP datagrams. |
| 1059 | * @param callback_module [IN] Destination module of the MSG MSG_ID_IPCORE_UL_PACKET_FILTERED_REQ for a uplink IP datagram matched the rules. |
| 1060 | * @param callback_context [IN] Context to pass in the callback function. |
| 1061 | * |
| 1062 | * @return Zero or postive value as filter ID if registration succeeded, negative value if it failed. |
| 1063 | */ |
| 1064 | kal_int32 ipc_register_ul_filter_msg(ipc_filter_rules_t *rules, |
| 1065 | module_type callback_module, |
| 1066 | void *callback_context); |
| 1067 | |
| 1068 | /** |
| 1069 | * Install module ID and filtering rules for downlink traffic. |
| 1070 | * |
| 1071 | * @param rules [IN] Rules to filter of downlink IP datagrams. |
| 1072 | * @param callback_module [IN] Destination module of the MSG MSG_ID_IPCORE_DL_PACKET_FILTERED_REQ for a downlink IP datagram matched the rules. |
| 1073 | * @param callback_context [IN] Context to pass in the callback function. |
| 1074 | * |
| 1075 | * @return Zero or postive value as filter ID if registration succeeded, negative value if it failed. |
| 1076 | */ |
| 1077 | kal_int32 ipc_register_dl_filter_msg(ipc_filter_rules_t *rules, |
| 1078 | module_type callback_module, |
| 1079 | void *callback_context); |
| 1080 | |
| 1081 | /** |
| 1082 | * Install callback function and filtering rules for uplink traffic. (callback function with information as parameter) |
| 1083 | * |
| 1084 | * @param rules [IN] Rules to filter of uplink IP datagrams. |
| 1085 | * @param callback_func [IN] Callback function for a uplink IP datagram matched the rules (with information as parameter). |
| 1086 | * @param callback_context [IN] Context to pass in the callback function. |
| 1087 | * |
| 1088 | * @return Zero or positive value as filter ID if registration succeeded, negative value if it failed. |
| 1089 | */ |
| 1090 | kal_int32 ipc_register_ul_filter_with_info_cbk(ipc_filter_rules_t *rules, |
| 1091 | ipc_filter_with_info_callback_t callback_func, |
| 1092 | void *callback_context); |
| 1093 | |
| 1094 | /** |
| 1095 | * Install callback function and filtering rules for downlink traffic. (callback function with information as parameter) |
| 1096 | * |
| 1097 | * @param rules [IN] Rules to filter of downlink IP datagrams. |
| 1098 | * @param callback_func [IN] Callback function for a downlink IP datagram matched the rules (with information as parameter). |
| 1099 | * @param callback_context [IN] Context to pass in the callback function. |
| 1100 | * |
| 1101 | * @return Zero or postive value as filter ID if registration succeeded, negative value if it failed. |
| 1102 | */ |
| 1103 | kal_int32 ipc_register_dl_filter_with_info_cbk(ipc_filter_rules_t *rules, |
| 1104 | ipc_filter_with_info_callback_t callback_func, |
| 1105 | void *callback_context); |
| 1106 | |
| 1107 | /** |
| 1108 | * Install module ID and filtering rules for uplink traffic. (callback function with information as parameter) |
| 1109 | * |
| 1110 | * @param rules [IN] Rules to filter of uplink IP datagrams. |
| 1111 | * @param callback_module [IN] Destination module of the MSG MSG_ID_IPCORE_UL_PACKET_FILTERED_WITH_INFO_REQ for a uplink IP datagram matched the rules. |
| 1112 | * @param callback_context [IN] Context to pass in the callback function. |
| 1113 | * |
| 1114 | * @return Zero or postive value as filter ID if registration succeeded, negative value if it failed. |
| 1115 | */ |
| 1116 | kal_int32 ipc_register_ul_filter_with_info_msg(ipc_filter_rules_t *rules, |
| 1117 | module_type callback_module, |
| 1118 | void *callback_context); |
| 1119 | |
| 1120 | /** |
| 1121 | * Install module ID and filtering rules for downlink traffic. (callback function with information as parameter) |
| 1122 | * |
| 1123 | * @param rules [IN] Rules to filter of downlink IP datagrams. |
| 1124 | * @param callback_module [IN] Destination module of the MSG MSG_ID_IPCORE_DL_PACKET_FILTERED_WITH_INFO_REQ for a downlink IP datagram matched the rules. |
| 1125 | * @param callback_context [IN] Context to pass in the callback function. |
| 1126 | * |
| 1127 | * @return Zero or postive value as filter ID if registration succeeded, negative value if it failed. |
| 1128 | */ |
| 1129 | kal_int32 ipc_register_dl_filter_with_info_msg(ipc_filter_rules_t *rules, |
| 1130 | module_type callback_module, |
| 1131 | void *callback_context); |
| 1132 | |
| 1133 | /** |
| 1134 | * Uninstall the filter for uplink traffic. |
| 1135 | * |
| 1136 | * @param filter_id [IN] filter ID to unregister. |
| 1137 | */ |
| 1138 | void ipc_deregister_ul_filter(kal_int32 filter_id); |
| 1139 | |
| 1140 | /** |
| 1141 | * Uninstall the filter for donwlink traffic. |
| 1142 | * |
| 1143 | * @param filter_id [IN] filter ID to unregister. |
| 1144 | */ |
| 1145 | void ipc_deregister_dl_filter(kal_int32 filter_id); |
| 1146 | |
| 1147 | /** |
| 1148 | * Copy buffers in the GPD list to the buffer prepared by caller. |
| 1149 | * |
| 1150 | * @param dst_buffer [OUT] Destination buffer to copy to, which is prepared by caller. |
| 1151 | * @param dst_max_len [IN] Size of the destination buffer prepared by caller in bytes. |
| 1152 | * @param dst_len_copied [OUT] Number of bytes copied to the destination buffer. |
| 1153 | * @param src_head_gpd [IN] Head of the GPD list with source buffers to copy from. |
| 1154 | * @param src_tail_gpd [IN] Tail of the GPD list with source buffers to copy from. |
| 1155 | * |
| 1156 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1157 | */ |
| 1158 | kal_bool ipc_gpd_copy(kal_uint8 *dst_buffer, kal_uint32 dst_max_len, kal_uint32 *dst_len_copied, qbm_gpd *src_head_gpd, qbm_gpd *src_tail_gpd); |
| 1159 | |
| 1160 | /** |
| 1161 | * Pack datagram in GPD format and selectively fill L4(UDP) and IP header. |
| 1162 | * |
| 1163 | * @param uplink [IN] Uplink or downlink packet. |
| 1164 | * @param pkt [IN] Datagram or GPD list to sent. |
| 1165 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1166 | * @param head_gpd [OUT] Head of GPD list return |
| 1167 | * @param tail_gpd [OUT] Tail of GPD list return |
| 1168 | * |
| 1169 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1170 | */ |
| 1171 | kal_bool ipc_pack_pkt_public(kal_bool uplink, |
| 1172 | ipc_pkt_t *pkt, |
| 1173 | ipc_hdr_t *hdr, |
| 1174 | qbm_gpd **head_gpd, |
| 1175 | qbm_gpd **tail_gpd); |
| 1176 | |
| 1177 | /** |
| 1178 | * Send datagram in buffer or GPD list to the wireless netowrk and selectively fill L4(UDP) and IP header on each of them. |
| 1179 | * |
| 1180 | * @param pkt [IN] Datagram or GPD list to sent. |
| 1181 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1182 | * @param ebi [IN] EBI/NSAPI. |
| 1183 | * |
| 1184 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1185 | */ |
| 1186 | kal_bool ipc_send_ul_pkt(ipc_pkt_t *pkt, ipc_hdr_t *hdr, kal_uint32 ebi); |
| 1187 | |
| 1188 | /** |
| 1189 | * Send datagram in buffer or GPD list to the wireless netowrk and selectively fill L4(UDP) and IP header on each of them. |
| 1190 | * |
| 1191 | * @param pkt [IN] Datagram or GPD list to sent. |
| 1192 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1193 | * @param pdn [IN] PDN ID |
| 1194 | * @param ip_type [IN] Type of IP datagrams, see IPC_IP_TYPE_XXX defined for valid values. Note that only one of IPv4/IPv6 can be selected and MIX type is NOT allowed. |
| 1195 | * |
| 1196 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1197 | */ |
| 1198 | kal_bool ipc_send_ul_pkt_by_pdn(ipc_pkt_t *pkt, |
| 1199 | ipc_hdr_t *hdr, |
| 1200 | kal_uint32 pdn, |
| 1201 | kal_uint8 ip_type); |
| 1202 | |
| 1203 | /** |
| 1204 | * Send datagram in buffer or GPD list to the wireless netowrk and selectively fill L4(UDP) and IP header on each of them. |
| 1205 | * |
| 1206 | * @param pkt [IN] Datagram or GPD list to sent. |
| 1207 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1208 | * @param netif_id [IN] Network interface ID |
| 1209 | * @param ip_type [IN] Type of IP datagrams, see IPC_IP_TYPE_XXX defined for valid values. Note that only one of IPv4/IPv6 can be selected and MIX type is NOT allowed. |
| 1210 | |
| 1211 | * |
| 1212 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1213 | */ |
| 1214 | kal_bool ipc_send_ul_pkt_by_netif_id(ipc_pkt_t *pkt, |
| 1215 | ipc_hdr_t *hdr, |
| 1216 | kal_uint32 netif_id, |
| 1217 | kal_uint8 ip_type); |
| 1218 | |
| 1219 | /** |
| 1220 | * Send datagram in buffer or GPD list to the wireless netowrk and selectively fill L4(UDP) and IP header on each of them. |
| 1221 | * |
| 1222 | * @param pkt [IN] Datagram or GPD list to sent. |
| 1223 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1224 | * @param ebi [IN] EBI/NSAPI. |
| 1225 | * @param proto_idx [IN] The index to distinquish from different SIM Card. |
| 1226 | * |
| 1227 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1228 | */ |
| 1229 | kal_bool ipc_send_ul_pkt_multiple_ps(ipc_pkt_t *pkt, |
| 1230 | ipc_hdr_t *hdr, |
| 1231 | kal_uint32 ebi, |
| 1232 | kal_uint8 proto_idx); |
| 1233 | |
| 1234 | /** |
| 1235 | * Send datagram in buffer or GPD list to the wireless netowrk and selectively fill L4(UDP) and IP header on each of them. |
| 1236 | * |
| 1237 | * @param pkt [IN] Datagram or GPD list to sent. |
| 1238 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1239 | * @param pdn [IN] PDN ID |
| 1240 | * @param ip_type [IN] Type of IP datagrams, see IPC_IP_TYPE_XXX defined for valid values. Note that only one of IPv4/IPv6 can be selected and MIX type is NOT allowed. |
| 1241 | * @param proto_idx [IN] The index to distinquish from different SIM Card. |
| 1242 | * |
| 1243 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1244 | */ |
| 1245 | kal_bool ipc_send_ul_pkt_by_pdn_multiple_ps(ipc_pkt_t *pkt, |
| 1246 | ipc_hdr_t *hdr, |
| 1247 | kal_uint32 pdn, |
| 1248 | kal_uint8 ip_type, |
| 1249 | kal_uint8 proto_idx); |
| 1250 | |
| 1251 | /** |
| 1252 | * Send datagram in buffer or GPD list to the wireless netowrk after filtering and selectively fill L4(UDP) and IP header on each of them. |
| 1253 | * |
| 1254 | * @param pkt [IN] Datagram or GPD list to sent. |
| 1255 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1256 | * @param pdn [IN] PDN ID |
| 1257 | * @param ip_type [IN] Type of IP datagrams, see IPC_IP_TYPE_XXX defined for valid values. Note that only one of IPv4/IPv6 can be selected and MIX type is NOT allowed. |
| 1258 | * @param proto_idx [IN] The index to distinquish from different SIM Card. |
| 1259 | * |
| 1260 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1261 | */ |
| 1262 | kal_bool ipc_send_ul_pkt_on_normal_path_by_pdn_multiple_ps(ipc_pkt_t *pkt, |
| 1263 | ipc_hdr_t *hdr, |
| 1264 | kal_uint32 pdn, |
| 1265 | kal_uint8 ip_type, |
| 1266 | kal_uint8 proto_idx); |
| 1267 | |
| 1268 | /** |
| 1269 | * Send datagram in buffer or GPD list to the netowrk interface and selectively fill L4(UDP) and IP header on each of them. |
| 1270 | * |
| 1271 | * @param pkt [IN] Datagram or GPD list to sent. |
| 1272 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1273 | * @param netif_id [IN] Network interface ID. |
| 1274 | * |
| 1275 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1276 | */ |
| 1277 | kal_bool ipc_send_dl_pkt(ipc_pkt_t *pkt, ipc_hdr_t *hdr, kal_uint32 netif_id); |
| 1278 | |
| 1279 | /** |
| 1280 | * Register a notification. |
| 1281 | * |
| 1282 | * @param callback_func [IN] Callback function pointer. |
| 1283 | * @param callback_context [IN] Context to pass in the callback function. |
| 1284 | * |
| 1285 | * @return Zero or positive value as notification ID if registration succeeded, negative value otherwise. |
| 1286 | */ |
| 1287 | kal_int32 ipc_register_ntfy(ipc_ntfy_callback_t callback_func, |
| 1288 | void *callback_context); |
| 1289 | |
| 1290 | /** |
| 1291 | * Uninstall the registered notification. |
| 1292 | * |
| 1293 | * @param ntfy_id [IN] notification ID gotten from ipc_register_ntfy() to uninstall. |
| 1294 | */ |
| 1295 | void ipc_deregister_ntfy(kal_int32 ntfy_id); |
| 1296 | |
| 1297 | /** |
| 1298 | * Register link up indication handler |
| 1299 | * |
| 1300 | * @param module_id [IN] Module ID to handle ILM MSG_ID_IPCORE_LINK_UP_IND. |
| 1301 | * |
| 1302 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1303 | */ |
| 1304 | kal_bool ipc_register_link_up_ind_handler(module_type module_id); |
| 1305 | |
| 1306 | /** |
| 1307 | * Uninstall the registered link up indication handler |
| 1308 | */ |
| 1309 | void ipc_deregister_link_up_ind_handler(void); |
| 1310 | |
| 1311 | /** |
| 1312 | * Register IP up indication handler |
| 1313 | * |
| 1314 | * @param module_id [IN] Module ID to handle ILM MSG_ID_IPCORE_IP_UP_IND. |
| 1315 | * |
| 1316 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1317 | */ |
| 1318 | kal_bool ipc_register_ip_up_ind_handler(module_type module_id); |
| 1319 | |
| 1320 | /** |
| 1321 | * Uninstall the registered link up indication handler |
| 1322 | */ |
| 1323 | void ipc_deregister_ip_up_ind_handler(void); |
| 1324 | |
| 1325 | /** |
| 1326 | * Bind two lan netif to one another (for MD Direct Tethering) |
| 1327 | * |
| 1328 | * @param netif_id_1 [IN] lan netif ID. |
| 1329 | * @param netif_id_2 [IN] lan netif ID. |
| 1330 | */ |
| 1331 | void ipc_bind_lan_netif(kal_uint32 netif_id_1, kal_uint32 netif_id_2); |
| 1332 | |
| 1333 | /** |
| 1334 | * Unbind two lan netif from one another (for MD Direct Tethering) |
| 1335 | * |
| 1336 | * @param netif_id_1 [IN] lan netif ID. |
| 1337 | * @param netif_id_2 [IN] lan netif ID. |
| 1338 | */ |
| 1339 | void ipc_unbind_lan_netif(kal_uint32 netif_id_1, kal_uint32 netif_id_2); |
| 1340 | |
| 1341 | /** |
| 1342 | * Send a list of IP datagrams to wireless network. (Gen93) |
| 1343 | * |
| 1344 | * @param start_idx [IN] Start idx of the Meta list. |
| 1345 | * @param end_idx [IN] Start idx of the Meta list. |
| 1346 | * @param queue_type [IN] Type of the Meta queue. |
| 1347 | * |
| 1348 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 1349 | */ |
| 1350 | kal_bool ipc_meta_uplink(kal_uint16 start_idx, kal_uint16 end_idx, LHIF_QUEUE_TYPE queue_type); |
| 1351 | |
| 1352 | /** |
| 1353 | * Get pdn_id & protocol index by given netif ID |
| 1354 | * |
| 1355 | * @param netif_id [IN] The network interface ID. |
| 1356 | * @param ip_type [IN] The IP type of the queried PDN. |
| 1357 | * @param p_pdn_id [OUT] The result of the PDN ID. |
| 1358 | * @param p_proto_idx [OUT] The result of the protocol index. |
| 1359 | * |
| 1360 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 1361 | */ |
| 1362 | kal_bool ipc_find_pdn_id_by_netif_id(kal_uint32 netif_id, kal_uint8 ip_type, kal_uint32 *p_pdn_id, kal_uint8 *p_proto_idx); |
| 1363 | |
| 1364 | /** |
| 1365 | * Send datagram in buffer or DID list to the netowrk interface and selectively fill L4(UDP) and IP header on each of them. (Gen93) |
| 1366 | * |
| 1367 | * @param pkt [IN] Datagram or DID list to sent. |
| 1368 | * @param hdr [IN] UDP/IP header information which will be filled to sent packet(s). NULL pointer means "No packet modification is needed" |
| 1369 | * @param netif_id [IN] Network interface ID. |
| 1370 | * |
| 1371 | * @return KAL_TRUE if succeeded, KAL_FALSE otherwise. |
| 1372 | */ |
| 1373 | kal_bool ipc_send_dl_pkt_in_did(ipc_pkt_t *pkt, ipc_hdr_t *hdr, kal_uint32 netif_id); |
| 1374 | |
| 1375 | /** |
| 1376 | * Re-filtering API for ipc_fragment submoule to check the filtering result of the fragment packets. (Gen93) |
| 1377 | * |
| 1378 | * @param ip_type [IN] Type of the packet, either IPC_IP_TYPE_IPV4 or IPC_IP_TYPE_IPV6. |
| 1379 | * @param info [IN] Information for re-filtering. |
| 1380 | * @param p_head [OUT] Head of GPD list return |
| 1381 | * @param p_tail [OUT] Tail of GPD list return |
| 1382 | */ |
| 1383 | void ipc_frag_refilter(kal_uint8 ip_type, ipc_frag_refilter_info_t *info, qbm_gpd *p_head, qbm_gpd *p_tail); |
| 1384 | |
| 1385 | /** |
| 1386 | * Re-filtering API for ipc_fragment submoule to send fragment packets to AP when fragment collection timeout or exception. (Gen93) |
| 1387 | * |
| 1388 | * @param ip_type [IN] Type of the packet, either IPC_IP_TYPE_IPV4 or IPC_IP_TYPE_IPV6. |
| 1389 | * @param info [IN] Information for re-filtering. |
| 1390 | * @param p_head [OUT] Head of GPD list return |
| 1391 | * @param p_tail [OUT] Tail of GPD list return |
| 1392 | */ |
| 1393 | void ipc_frag_send_pkt(kal_uint8 ip_type, ipc_frag_refilter_info_t *info, qbm_gpd *p_head, qbm_gpd *p_tail); |
| 1394 | |
| 1395 | /* |
| 1396 | * Look into packet to gather necessary IP header & the upper layer protocol header information. |
| 1397 | * Note that, for IPv6's packet, current implementation don't handle the following cases and take them as not found: |
| 1398 | * #1. IPv6 packet with ESP header: |
| 1399 | * According to RFC 4303 section 3.1, everything after ESP header is encrypted. |
| 1400 | * Since we cannot decrypt it, we cannot acturally look into the upper layer protocol. |
| 1401 | * |
| 1402 | * #2. IPv6 extension header not defined in RFC 2460: |
| 1403 | * If necessary, we will handle them here according to corresponding RFC. |
| 1404 | * |
| 1405 | * #3. fragmentation: |
| 1406 | * No application needs IPv6 fragmentation on a modem platform so far. |
| 1407 | * |
| 1408 | * @param ipv6_packet [IN] The packet. |
| 1409 | * @param packet_len [IN] Length of the packet. |
| 1410 | * @param p_info [OUT] The necessary information gathered for later packete filtering. |
| 1411 | * |
| 1412 | * @return KAL_TRUE if the packet's information was gathered sucessfully, KAL_FALSE otherwise. |
| 1413 | */ |
| 1414 | kal_bool ipc_get_packet_info(kal_uint8 *p_packet, kal_uint16 packet_len, ipc_packet_info_t *p_info); |
| 1415 | |
| 1416 | /** |
| 1417 | * Send a list of IP datagrams filter-out by IPF. (Gen95) |
| 1418 | * |
| 1419 | * @param start_idx [IN] Start idx of the Meta list. |
| 1420 | * @param end_idx [IN] Start idx of the Meta list. |
| 1421 | * @param queue_type [IN] Type of the Meta queue. |
| 1422 | * |
| 1423 | */ |
| 1424 | void ipc_meta_downlink(kal_uint16 start_idx, kal_uint16 end_idx, kal_uint32 queue_type); |
| 1425 | |
| 1426 | /** |
| 1427 | * Query bound PDN id according to netif_id and ip_type |
| 1428 | * |
| 1429 | * @param netif_id [IN] network interface ID. |
| 1430 | * @param ip_type [IN] IPC_IP_TYPE_IPV4 / IPC_IP_TYPE_IPV6. (ipc_enums.h) |
| 1431 | * @param pdn_id [OUT] return the bound PDN ID. |
| 1432 | * |
| 1433 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 1434 | */ |
| 1435 | kal_bool ipc_query_pdn_by_netif(kal_uint32 netif_id, kal_uint8 ip_type, kal_int32 *pdn_id); |
| 1436 | |
| 1437 | /** |
| 1438 | * calculate TCP checksum |
| 1439 | * |
| 1440 | * @param is_ipv4 ipv4 or ipv6 |
| 1441 | * @param src_addr source address |
| 1442 | * @param dst_addr destination address |
| 1443 | * @param tcp_header tcp header pointer |
| 1444 | * @param tcp_len tcp length |
| 1445 | */ |
| 1446 | kal_uint16 ipc_calc_tcp_checksum(kal_bool is_ipv4, |
| 1447 | kal_uint8 *src_addr, |
| 1448 | kal_uint8 *dst_addr, |
| 1449 | kal_uint8 *tcp_header, |
| 1450 | kal_uint32 tcp_len); |
| 1451 | |
| 1452 | /** |
| 1453 | * calculate UDP checksum |
| 1454 | * |
| 1455 | * @param is_ipv4 ipv4 or ipv6 |
| 1456 | * @param src_addr source address |
| 1457 | * @param dst_addr destination address |
| 1458 | * @param udp_header udp header pointer |
| 1459 | * @param udp_len udp length |
| 1460 | */ |
| 1461 | kal_uint16 ipc_calc_udp_checksum(kal_bool is_ipv4, |
| 1462 | kal_uint8 *src_addr, |
| 1463 | kal_uint8 *dst_addr, |
| 1464 | kal_uint8 *udp_header, |
| 1465 | kal_uint32 udp_len); |
| 1466 | |
| 1467 | /** |
| 1468 | * calculate IPv4 checksum |
| 1469 | * |
| 1470 | * @param ip_header IP header pointer |
| 1471 | */ |
| 1472 | kal_uint16 ipc_calc_ipv4_checksum(kal_uint8 *ip_header); |
| 1473 | |
| 1474 | /** |
| 1475 | * send DL did by channel_id |
| 1476 | * |
| 1477 | * @param net_type network type |
| 1478 | * @param ch_id channel id |
| 1479 | * @param p_did_head did head |
| 1480 | * @param p_did_tail did tail |
| 1481 | */ |
| 1482 | kal_bool ipc_send_dl_did_by_ch_id(kal_uint8 net_type, |
| 1483 | kal_uint8 ch_id, |
| 1484 | upcm_did *p_did_head, |
| 1485 | upcm_did *p_did_tail); |
| 1486 | |
| 1487 | |
| 1488 | /** |
| 1489 | * Send datagram in QBM GPD to the netowrk interface after unwinding call stack |
| 1490 | * |
| 1491 | * @param pkt Packet GPD |
| 1492 | * @param netif_id Network interface ID. |
| 1493 | * @param session_type IPV4/V6 session type |
| 1494 | */ |
| 1495 | kal_bool ipc_send_dl_pkt_enqueue(qbm_gpd *pkt, kal_uint32 netif_id, kal_uint32 session_type); |
| 1496 | |
| 1497 | /** |
| 1498 | * register ipc filter |
| 1499 | * |
| 1500 | * @param data_path_direction DL_DATA_PATH or UL_DATA_PATH |
| 1501 | * @param p_rules filter rules |
| 1502 | * @param p_ntfy_ctxt filter match notification context |
| 1503 | * |
| 1504 | * @return non negative filter id for successful, otherwise IPC_INVALID_FILTER_ID |
| 1505 | */ |
| 1506 | kal_int32 ipc_reg_filter(ipc_data_path_direction_e data_path_direct, |
| 1507 | ipc_filter_rules_t *p_rules, |
| 1508 | ipc_filter_ntfy_ctxt_t *p_ntfy_ctxt); |
| 1509 | |
| 1510 | /** |
| 1511 | * deregister ipc filter |
| 1512 | * |
| 1513 | * @param filter_id the filter_id which want to be deregistered |
| 1514 | * |
| 1515 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 1516 | */ |
| 1517 | kal_bool ipc_dereg_filter(kal_int32 filter_id); |
| 1518 | |
| 1519 | /** |
| 1520 | * Get data usage by Netif_id |
| 1521 | * |
| 1522 | * @param netif_id [IN] the netif_id for which want to know data usgae |
| 1523 | * @param data_usage [OUT] data usage of uplink and downlink path |
| 1524 | * |
| 1525 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 1526 | */ |
| 1527 | kal_bool ipc_get_data_usage_by_netif_id(kal_uint32 netif_id, ipc_data_usage_info_t *data_usage); |
| 1528 | |
| 1529 | /** |
| 1530 | * Get data usage by pdn_id |
| 1531 | * |
| 1532 | * @param pdn_id [IN] the pdn_id for which want to know data usgae |
| 1533 | * @param proto_idx [IN] the sim_idx for which want to know data usgae |
| 1534 | * @param data_usage [OUT] data usage of uplink and downlink path |
| 1535 | * |
| 1536 | * @return KAL_TRUE if successful, KAL_FALSE otherwise. |
| 1537 | */ |
| 1538 | kal_bool ipc_get_data_usage_by_pdn_id(kal_uint32 pdn_id, kal_uint8 proto_idx, ipc_data_usage_info_t *data_usage); |
| 1539 | |
| 1540 | #endif /* __INC_IPC_API_H */ |