[Feature]Upload Modem source code
Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/interface/service/nal/nal_general_types.h b/mcu/interface/service/nal/nal_general_types.h
new file mode 100644
index 0000000..5f81ee4
--- /dev/null
+++ b/mcu/interface/service/nal/nal_general_types.h
@@ -0,0 +1,95 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * nal_general_types.h
+ *
+ * Project:
+ * --------
+ * MT6293
+ *
+ * Description:
+ * ------------
+ * It includes the definations that are common to target and
+ * debug version of NAL on Nucleus
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ ********************************************************************************/
+
+ /*********************************************************************
+ (C) _____ (year of first publication) Sasken communication
+ Technologies Limited, All rights reserved.
+* This file provides a template for .c files. This space
+* should be used to describe the file contents
+* Component-specific prefix : xxxx
+*********************************************************************/
+
+#ifndef _NAL_GENERAL_TYPES_H
+#define _NAL_GENERAL_TYPES_H
+
+#include "kal_general_types.h"
+
+typedef kal_char nal_char ;
+typedef kal_int32 nal_status ;
+typedef kal_int32 nal_int ;
+typedef kal_int8 nal_int8 ;
+typedef kal_int16 nal_int16 ;
+typedef kal_int32 nal_int32 ;
+typedef kal_uint32 nal_unsigned;
+typedef kal_uint8 nal_uint8 ;
+typedef kal_uint16 nal_uint16 ;
+typedef kal_uint32 nal_uint32 ;
+typedef kal_uint32 nal_socklen_t;
+typedef kal_uint32 nal_size_t;
+
+
+#endif /*_NAL_GENERAL_TYPES_H*/
diff --git a/mcu/interface/service/nal/nal_public_apis.h b/mcu/interface/service/nal/nal_public_apis.h
new file mode 100644
index 0000000..2f122b0
--- /dev/null
+++ b/mcu/interface/service/nal/nal_public_apis.h
@@ -0,0 +1,101 @@
+/*************************************************************************
+*
+* Copyright 1993 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+*************************************************************************/
+
+/************************************************************************
+*
+* FILE NAME
+*
+* nal_public_apis.h
+*
+* COMPONENT
+*
+* nal APIs.
+*
+* DESCRIPTION
+*
+* Release nal interface to users.
+*
+* DATA STRUCTURES
+*
+*
+* DEPENDENCIES
+*
+* nal_public_defs.h
+* nal_general_types.h
+*
+*************************************************************************/
+
+#ifndef NAL_PUBLIC_APIS_H
+#define NAL_PUBLIC_APIS_H
+
+#include "kal_public_api.h"
+#include "nal_general_types.h"
+#include "nal_public_defs.h"
+
+nal_int nal_socket(nal_int16 family, nal_int16 type, nal_int16 protocol);
+nal_status nal_bind(nal_int socketd, const nal_addr_struct* myaddr, nal_int16 addrlen);
+nal_status nal_get_sock_name(nal_int socketd, nal_sockaddr_struct* localaddr, nal_int16* addrlen);
+nal_status nal_connect(nal_int socketd, const nal_addr_struct* servaddr, nal_int16 addrlen);
+nal_status nal_is_connected(nal_int socketd);
+nal_int32 nal_send(nal_int socketd, const void* buff, nal_uint16 nbytes, nal_int16 flags);
+nal_int32 nal_recv(nal_int socketd, void* buff, nal_uint16 nbytes, nal_int16 flags);
+nal_int32 nal_send_to(nal_int socketd, const void* buff, nal_uint16 nbytes, nal_int16 flags, const nal_addr_struct* to, nal_int16 addr_len);
+nal_int32 nal_recv_from(nal_int socketd, void* buff, nal_uint16 nbytes, nal_int16 flags, nal_addr_struct* from, nal_int16* addr_len);
+nal_int32 nal_recv_with_info(nal_int socketd, void* buff, nal_uint16 nbytes, nal_int16 flags, nal_info_struct* info, nal_int16* info_len);
+nal_int32 nal_sendmsg(nal_int socketd, const nal_msghdr* msg, nal_int16 flags);
+nal_int32 nal_recvmsg(nal_int socketd, nal_msghdr* msg, nal_int16 flags);
+nal_status nal_getsockopt(nal_int socketd, nal_int level, nal_int optname, void* optval, nal_int* optlen);
+nal_status nal_setsockopt(nal_int socketd, nal_int level, nal_int optname, const void* optval, nal_int optlen);
+
+nal_status nal_listen(nal_int socketd, nal_uint16 backlog);
+nal_status nal_accept(nal_int socketd, nal_addr_struct* peer, nal_int16* addrlen);
+nal_status nal_shutdown(nal_int socketd, nal_int how);
+nal_status nal_close_socket(nal_int socketd);
+nal_status nal_close_socket_simple(nal_int socketd);
+nal_status nal_fcntl(nal_int socketd, nal_int16 command, nal_int16 argument);
+nal_int nal_fd_check(nal_int socketd, nal_fdset* fd);
+void nal_fd_init(nal_fdset* fd);
+void nal_fd_reset(nal_int socketd, nal_fdset* fd);
+void nal_fd_set(nal_int socketd, nal_fdset* fd);
+nal_status nal_select(nal_int max_sockets, nal_fdset* readfs, nal_fdset* writefs, nal_fdset* exceptfs, nal_unsigned timeout);
+
+/* NAL Socket Utilities */
+nal_status nal_inet_pton(nal_int family, const nal_char* src, void* dst);
+nal_status nal_inet_ntop(nal_int family, const void* src, nal_char* dst, nal_int size);
+nal_status nal_inet_ntop_zc(nal_int family, const void *src, nal_char *dst, nal_int size);
+nal_uint16 nal_htons(nal_uint16 number);
+nal_uint16 nal_ntohs(nal_uint16 number);
+nal_uint32 nal_htonl(nal_uint32 number);
+nal_uint32 nal_ntohl(nal_uint32 number);
+
+/* NAL 5-tuple Filter */
+nal_status nal_add_filter(nal_int socketd, nal_addr_struct* dest);
+nal_status nal_add_gen_filter(nal_int protocol, nal_filter_info_t* info);
+nal_status nal_delete_filter(nal_int socketd, nal_int filter_id);
+nal_status nal_update_filter(nal_int socketd, nal_int filter_id, nal_addr_struct* dest);
+
+/* NAL Statistic for Filter */
+void nal_fil_dump_all();
+void nal_stat_dump_filter_list(nal_int socketd, void *filter_list);
+
+/* NAL tool */
+nal_status nal_tl_ping(nal_int socketd, nal_uint32 timeout, nal_addr_struct* from, nal_addr_struct* to, nal_uint32 stk_id, nal_uint32 stk_id_valid);
+
+nal_status nal_addr_ipv4to6_well_known_prefix(nal_uint8* output_ipv6, const nal_uint8* input_ipv4);
+
+/* NAL monitor */
+nal_status nal_monitor(nal_int socketd, nal_uint32 events, nal_uint32 timeout, module_type receiver_mod);
+
+/* NAL RSRA */
+nal_status nal_configure_ipv6_interface(const nal_uint32 dev_index, nal_int optname, const void* optval);
+nal_status nal_setrsraopt(void* user_data, nal_int level, const void* param, nal_uint32 optlen);
+
+#endif /* NAL_PUBLIC_APIS_H */
diff --git a/mcu/interface/service/nal/nal_public_defs.h b/mcu/interface/service/nal/nal_public_defs.h
new file mode 100644
index 0000000..451a9c3
--- /dev/null
+++ b/mcu/interface/service/nal/nal_public_defs.h
@@ -0,0 +1,725 @@
+/*************************************************************************
+*
+* Copyright 1993 Mentor Graphics Corporation
+* All Rights Reserved.
+*
+* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
+* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
+* SUBJECT TO LICENSE TERMS.
+*
+*************************************************************************/
+
+/***************************************************************************
+*
+* FILENAME
+*
+* nal_public_defs.h
+*
+* COMPONENTS
+*
+* Sockets
+*
+* DESCRIPTION
+*
+* This include file will define socket type error return codes, socket
+* options, and socket protocol types.
+*
+* DATA STRUCTURES
+*
+* None
+*
+* DEPENDENCIES
+*
+* None
+*
+***************************************************************************/
+
+#ifndef NAL_PUBLIC_SOCKDEFS_H
+#define NAL_PUBLIC_SOCKDEFS_H
+
+#ifdef __cplusplus
+extern "C" { /* C declarations in C++ */
+#endif /* _cplusplus */
+
+#include "nal_general_types.h"
+
+#define MOD_NAL MOD_NIL
+
+/* Defines for TRUE/ FALSE conditions */
+#define NAL_FALSE 0
+#define NAL_TRUE 1
+
+/* Do not redefine these macros if using the Nucleus builder to compile the
+* code. If not using the Nucleus builder, all macros must be explicitly
+* configured here; otherwise, configure the respective .metadata file.
+*/
+#ifndef CFG_NAL_OS_NET_STACK_CFG_H
+
+/* Set this to NU_FALSE to exclude UDP. */
+#define NAL_INCLUDE_UDP NAL_TRUE
+
+/* Set this to NU_FALSE to exclude TCP. */
+#define NAL_INCLUDE_TCP NAL_TRUE
+
+/* By default raw IP is not included in the Nucleus NET build. Set this
+ to NU_TRUE to include raw IP.
+*/
+#define NAL_INCLUDE_IP_RAW NAL_TRUE
+
+/* By default IPv4 is included in the Nucleus NET library. Change this
+ definition to NU_FALSE to exclude IPv4. */
+#define NAL_INCLUDE_IPV4 NAL_TRUE
+
+/* By default IPv6 is not included in the Nucleus NET library. Change this
+ definition to NU_TRUE to include IPv6. Note that IPv6 is a separate product
+ and must have been purchased and installed for this option to work. */
+#define NAL_INCLUDE_IPV6 NAL_TRUE
+
+
+#endif
+
+/*Constant used in service parameters*/
+#define NAL_SUSPEND KAL_SUSPEND
+#define NAL_NO_SUSPEND 0
+
+/* A generic catch-all for unused parameters. */
+#define NAL_NONE 0
+
+/* Address family equates */
+#define NAL_FAM_UNSPEC 0 /* unspecified */
+#define NAL_FAM_LOCAL 1
+#define NAL_FAM_UNIX NAL_FAM_LOCAL
+#define NAL_FAM_IP 2 /* Internet: UDP, TCP, etc. */
+#define NAL_FAM_ROUTE 17 /* Internal routing protocol */
+#define NAL_FAM_LINK 18 /* Link layer interface. */
+#define NAL_FAM_IP6 28 /* IPv6 */
+
+/* These equates are for backwards compatibility */
+#define NAL_FAMILY_UNIX NAL_FAM_UNIX /* Unix */
+#define NAL_FAMILY_IP NAL_FAM_IP /* Internet - valid entry */
+#define NAL_FAMILY_IP6 NAL_FAM_IP6 /* IPv6 */
+#define NAL_FAMILY_UNSPEC NAL_FAM_UNSPEC
+
+/* TYPE equates */
+#define NAL_TYPE_STREAM 0 /* stream Socket - valid entry */
+#define NAL_TYPE_DGRAM 1 /* datagram Socket - valid entry */
+#define NAL_TYPE_RAW 2 /* raw Socket - valid entry */
+#define NAL_TYPE_SEQPACKET 3 /* sequenced packet Socket */
+#define NAL_TYPE_RDM 4 /* reliably delivered msg Socket */
+
+/* PROTOCOL equates */
+#define NAL_PROTO_INVALID 0
+#define NAL_PROTO_TCP 1
+#define NAL_PROTO_UDP 2
+#define NAL_PROTO_ICMP 3
+
+/* Shutdown options - bit settings */
+#define NAL_SHUT_RD 0x00000001 /* Close read-half */
+#define NAL_SHUT_WR 0x00000002 /* Close write-half */
+#define NAL_SHUT_RDWR (NAL_SHUT_RD|NAL_SHUT_WR)
+
+/* Application Protocol Information */
+typedef enum {
+ NAL_ICD_APP_PROT_OTHER,
+ NAL_ICD_APP_PROT_DNS,
+ NAL_ICD_APP_PROT_NATT_KEEP_ALV_ISAKMP,
+ NAL_ICD_APP_PROT_SIP,
+ NAL_ICD_APP_PROT_RTP,
+ NAL_ICD_APP_PROT_SIP_DECRYPT,
+ NAL_ICD_APP_PROT_MAX
+} nal_icd_app_prot_type_t;
+
+/* Bitmap for Nucleus Net initialized modules */
+#define NAL_DHCP_CLIENT_MODULE 0x00000001
+
+/* Select index defines */
+#define NAL_SEL_READABLE_IDX 0
+#define NAL_SEL_WRITABLE_IDX 1
+#define NAL_SEL_MAX_FDSET 2
+
+/* Socket multitask flags */
+#define NAL_SCK_RES_BUFF 2
+
+#define NAL_IGNORE_VALUE -1 /* Null parameter value */
+#define NAL_NULL_IP 0 /* Used to initialize ip addresses to NULL */
+
+#if (NAL_INCLUDE_IPV6 == NAL_TRUE)
+#define NAL_MAX_ADDR_SIZE 16
+#else
+#define NAL_MAX_ADDR_SIZE 4
+#endif
+
+#define NAL_UDP_MAX_PORTS 50 /* Maximum number of UDP ports. */
+
+#define NAL_TCP_MAX_PORTS 50 /* Maximum number of TCP ports. */
+
+#if NAL_INCLUDE_IP_RAW == NAL_TRUE
+#define NAL_IPR_MAX_PORTS 30
+#else
+#define NAL_IPR_MAX_PORTS 1
+#endif
+
+/* Total number of socket descriptors. This should be
+ TCP_MAX_PORTS + UDP_MAX_PORTS + IPR_MAX_PORTS */
+#define NAL_NSOCKETS (NAL_TCP_MAX_PORTS + NAL_UDP_MAX_PORTS + NAL_IPR_MAX_PORTS)
+
+
+/*Window size*/
+#define NAL_WINDOW_SIZE 16000
+
+/*
+ * Socket state bits.
+ */
+#define NAL_SS_NOFDREF 0x0001 /* no file table ref any more */
+#define NAL_SS_ISCONNECTED 0x0002 /* socket connected to a peer */
+#define NAL_SS_ISCONNECTING 0x0004 /* in process of connecting to peer */
+#define NAL_SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
+#define NAL_SS_DEVICEDOWN 0x0010 /* Used only by UDP sockets. Indicates
+ that the device that was being used by
+ a UDP socket/port has gone down. */
+#define NAL_SS_TIMEDOUT 0x0020 /* The connection timed out */
+#define NAL_SS_WAITWINDOW 0x0040 /* Used for the waiting window */
+#define NAL_SS_CANTRCVMORE 0x0080 /* Indicate that a socket's read-half is
+ closed. */
+#define NAL_SS_CANTWRTMORE 0x0100 /* The socket's write-half is closed. */
+/*
+ * Socket Flag bits.
+ */
+#define NAL_SF_BLOCK 0x0001 /* Indicates blocking or non-blocking */
+#define NAL_SF_LISTENER 0x0002 /* Is a TCP server listening */
+#define NAL_SF_ZC_MODE 0x0004 /* Set zerocopy mode for this socket */
+#define NAL_SF_V4_MAPPED 0x0008
+#define NAL_SF_BIND 0x0010
+
+/* Defines added for the NAL_Select service call. */
+#define NAL_FD_BITS 32
+#define NAL_FD_ELEMENTS ((NAL_NSOCKETS/NAL_FD_BITS)+1)
+
+#define NAL_SCK_EVENT_Q_ELEMENT_SIZE 3 /* event queue element size
+ do not change the size */
+
+/* Socket event bits */
+#define NAL_SOCKET_EVENT_NONE 0x00 /* Remove socket from monitoring list */
+#define NAL_SOCKET_EVENT_READ 0x01 /* Wait for socket to become available for reading */
+#define NAL_SOCKET_EVENT_WRITE 0x02 /* Wait for socket to become available for writing */
+#define NAL_SOCKET_EVENT_EXCEPT 0x04 /* Wait for socket exceptions */
+
+
+/*************************** SOCKET OPTIONS *****************************/
+/* SOCKET OPTION control flags */
+#define NAL_SETFLAG 1
+#define NAL_BLOCK 1
+#define NAL_NO_BLOCK 0
+
+/* {DCP 1-30-02} Added ZeroCopy mode flags */
+
+#define NAL_SET_ZC_MODE 2
+#define NAL_ZC_ENABLE 1
+#define NAL_ZC_DISABLE 0
+
+#define NAL_DSCP_LOW_MIN 0
+#define NAL_DSCP_LOW_MAX 7
+
+#define NAL_DSCP_LOWHI_MIN 8
+#define NAL_DSCP_LOWHI_MAX 15
+
+#define NAL_DSCP_NORMAL_MIN 16
+#define NAL_DSCP_NORMAL_MAX 23
+
+#define NAL_DSCP_NORMALHI_MIN 24
+#define NAL_DSCP_NORMALHI_MAX 31
+
+#define NAL_DSCP_MEDIUM_MIN 32
+#define NAL_DSCP_MEDIUM_MAX 39
+
+#define NAL_DSCP_MEDIUMHI_MIN 40
+#define NAL_DSCP_MEDIUMHI_MAX 47
+
+#define NAL_DSCP_HIGH_MIN 48
+#define NAL_DSCP_HIGH_MAX 55
+
+#define NAL_DSCP_HIGHHI_MIN 56
+#define NAL_DSCP_HIGHHI_MAX 63
+
+/* Note when VLAN is enabled the three bit priority field is extracted from */
+/* the IP_TOS field set for the socket by use of the NAL_Setsockopt function. */
+/* The name IP_TOS should not cause confusion when using DiffServ. The DSCP */
+/* will be inserted into the IP_TOS field. The VLAN priority is computed by */
+/* shifting the DSCP value 3 positions to the right (dividing by 8). This */
+/* correctly maps the 64 DSCP values to the 8 available VLAN priorities. */
+
+#define NAL_MAP_DSCP_VLAN_PRIORITY(x) (NAL_UINT8)((x) >> 3)
+
+
+
+/* IP TOS FIELD Bit Layout | 7 | 6 5 4 3 | 2 1 0 | */
+/* 0 | T O S | V L P | */
+
+/* TOS PRECEDENCE HAS BEEN REPLACED BY DIFFSERV VALUES PER RFC2474 */
+
+#define NAL_IP_TOS_NORMAL_SERVICE 0x0
+#define NAL_IP_TOS_MIN_DELAY 0x8 /* MIN-DELAY service = 1 << 3 */
+#define NAL_IP_TOS_MAX_THRUPUT 0x10 /* MAX-THRUPUT service = 2 << 3 */
+#define NAL_IP_TOS_MAX_REL 0x20 /* MAX-RELIABILITY service = 4 << 3 */
+#define NAL_IP_TOS_MIN_DOLLARS 0x40 /* MIN-DOLLAR COST service = 8 << 3 */
+
+
+/*
+ * Options for use with [gs]etsockopt at the TCP level.
+*/
+
+#define NAL_TCP_NODELAY 1
+#define NAL_SO_KEEPALIVE 2
+#define NAL_TCP_FIRST_PROBE_TIMEOUT 3
+#define NAL_TCP_PROBE_TIMEOUT 4
+#define NAL_TCP_MAX_PROBES 5
+#define NAL_TCP_MSL 6
+#define NAL_TCP_FIRST_RTO 7
+#define NAL_TCP_MAX_RTO 8
+#define NAL_TCP_MAX_R2 9
+#define NAL_TCP_MAX_SYN_R2 10
+#define NAL_TCP_DELAY_ACK 11
+#define NAL_TCP_KEEPALIVE_WAIT 12
+#define NAL_TCP_KEEPALIVE_R2 13
+#define NAL_TCP_CONGESTION_CTRL 14
+#define NAL_TCP_CFG_SACK 15
+#define NAL_TCP_CFG_DSACK 16
+#define NAL_TCP_WINDOWSCALE 17
+#define NAL_TCP_SND_WINDOWSIZE 18
+#define NAL_TCP_RCV_WINDOWSIZE 19
+#define NAL_TCP_TIMESTAMP 20
+#define NAL_TCP_KEEPINTVL 21
+#define NAL_TCP_MAXSEG 22
+#define NAL_TCP_MIN_RTO 23
+
+#define FOREIGN_MAX_SEGMENT_LEN 536
+
+/*
+ * Options for use with [gs]etsockopt at the UDP level.
+*/
+#define NAL_UDP_NOCHECKSUM 38
+#define NAL_UDP_MAX_DATAGRAMS 39
+#define NAL_UDP_IGNORE_CHECKSUM 40
+
+
+/* PROTOCOL LEVELS */
+#define NAL_SOCKET_LEVEL 0
+
+
+/* Levels used in the call to NAL_Setsockopt */
+#define NAL_IPPROTO_IP 0
+#define NAL_IPPROTO_ICMP 1
+#define NAL_IPPROTO_IGMP 2
+#define NAL_IPPROTO_GGP 3
+#define NAL_IPPROTO_TCP 6
+#define NAL_IPPROTO_EGP 8
+#define NAL_IPPROTO_PUP 12
+#define NAL_IPPROTO_UDP 17
+#define NAL_IPPROTO_IPV6 41
+#define NAL_SOL_SOCKET 100
+
+/* Protocol used int call to NAL_Socket with a Raw IP socket */
+#define NAL_IPPROTO_HELLO 63
+#define NAL_IPPROTO_RAW 255
+#define NAL_IPPROTO_OSPF 89
+
+#define NAL_IS_RAW_PROTOCOL(next) \
+ (next == NAL_IPPROTO_RAW) || \
+ (next == NAL_IPPROTO_HELLO) || (next == NAL_IPPROTO_OSPF)
+
+/* IPv6 Defines */
+#define NAL_IPPROTO_HOPBYHOP 0 /* Hop-by-Hop Options */
+#define NAL_IPPROTO_ROUTING 43 /* Routing Header */
+#define NAL_IPPROTO_FRAGMENT 44 /* Fragment Header */
+#define NAL_IPPROTO_ESP 50
+#define NAL_IPPROTO_AUTH 51
+#define NAL_IPPROTO_ICMPV6 58
+#define NAL_IPPROTO_NONEXTHDR 59
+#define NAL_IPPROTO_DEST 60 /* Destination Options Header */
+
+/*
+ * Options for use with [gs]etsockopt at the socket level.
+ * First word of comment is data type; bool is stored in int.
+ */
+#define NAL_SO_BROADCAST 1 /* permission to transmit broadcast messages? */
+#define NAL_SO_LINGER 2 /* linger on socket close */
+#define NAL_SO_REUSEADDR 3 /* socket option to bind multiple addresses to
+ the same port number. */
+#define NAL_SO_RCVBUF 4 /* socket option to set the local TCP Window Size
+ for a socket. */
+#define NAL_SO_AUTO_CLEAR 5 /* socket option to clear all errors on a UDP socket. */
+
+#define NAL_SO_BINDTODEVICE 6 /*socket option to set the socket to be bound to a specified device*/
+
+#define NAL_SO_INFO_FIELDS 8 /* fields enabled for nal_recv_with_info() */
+#define NAL_SO_MASTER_FILTER_LIST 9 /* master downlink filter list, used with for example WiFi device.
+ * Size: master filter count * sizeof(nal_int)
+ */
+#define NAL_SO_FILTER_CONFIG 10 /* filter config */
+#define NAL_SO_ICD_INFO 11 /* Information required to dump the UL/DL packets to AP for MDMI */
+#define NAL_SO_AUTORST 12 /* Auto reset accepted TCP Ports on IPSec key del */
+
+#define NAL_FILTER_CONFIG_NONE 0x00
+#define NAL_FILTER_CONFIG_NON_ESP_MARKER 0x01
+#define NAL_FILTER_CONFIG_NAT_KEEPALIVE 0x02
+
+/*
+ * Options for use with [gs]etsockopt at the IP level.
+ * First word of comment is data type; bool is stored in int.
+ */
+#define NAL_IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
+#define NAL_IP_HDRINCL 2 /* int; header is included with data */
+#define NAL_IP_TOS 3 /* int; IP type of service and precedence. */
+#define NAL_IP_TTL 4 /* int; IP time to live */
+#define NAL_IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */
+#define NAL_IP_RECVRETOPTS 6 /* bool; receive IP opts for response */
+#define NAL_IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */
+#define NAL_IP_RETOPTS 8 /* ip_opts; set/get IP options */
+#define NAL_IP_MULTICAST_IF 9 /* u_char; set/get IP multicast i/f */
+#define NAL_IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */
+#define NAL_IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */
+#define NAL_IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
+#define NAL_IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */
+#define NAL_IP_BROADCAST_IF 14 /* u_char; set/get IP broadcast IF */
+#define NAL_IP_RECVIFADDR 15 /* bool; recv IP of IF of last RX datagram */
+
+/* IPv6 socket options */
+#define NAL_IPV6_UNICAST_HOPS 16
+#define NAL_IPV6_MULTICAST_IF 17
+#define NAL_IPV6_MULTICAST_HOPS 18
+#define NAL_IPV6_MULTICAST_LOOP 19
+#define NAL_IPV6_JOIN_GROUP 20
+#define NAL_IPV6_LEAVE_GROUP 21
+#define NAL_IPV6_RECVHOPLIMIT 22
+#define NAL_IPV6_RECVRTHDR 23
+#define NAL_IPV6_RECVHOPOPTS 24
+#define NAL_IPV6_RECVDSTOPTS 25
+#define NAL_IPV6_RECVTCLASS 26
+#define NAL_IPV6_RECVPKTINFO 27
+#define NAL_IPV6_PKTINFO 28
+#define NAL_IPV6_HOPLIMIT 29
+#define NAL_IPV6_NEXTHOP 30
+#define NAL_IPV6_RTHDR 31
+#define NAL_IPV6_HOPOPTS 32
+#define NAL_IPV6_DSTOPTS 33
+#define NAL_IPV6_RTHDRDSTOPTS 34
+#define NAL_IPV6_TCLASS 35
+#define NAL_IPV6_V6ONLY 36
+#define NAL_IPV6_CHECKSUM 37
+
+/* NOTE ...Please note that Options (optname)for use with [gs]etsockopt
+ * at the UDP level use 38- 40 and are defined in udp.h.
+ */
+
+/* Additional socket options. */
+#define NAL_IP_PKTINFO 41
+
+
+#define NAL_IP_RECVIFADDR_OP 0x001
+#define NAL_SO_REUSEADDR_OP 0x002 /* SO_REUSEADDR has been set on the socket */
+#define NAL_SO_IPV6_PKTINFO_OP 0x004
+#define NAL_SO_IPV6_HOPLIMIT_OP 0x008
+#define NAL_SO_IPV6_TCLASS_OP 0x010
+#define NAL_SO_IPV6_RTHDR_OP 0x020
+#define NAL_SO_IPV6_HOPOPTS 0x040
+#define NAL_SO_IPV6_DESTOPTS 0x080
+#define NAL_SO_IPV6_V6ONLY 0x100 /* NAL_FAMILY_IP6 socket for IPv6 comm. only */
+#define NAL_SO_IPV6_CHECKSUM 0x200
+
+#define NAL_SO_UDP_NOCHECKSUM 0x400
+#define NAL_SO_IP_HDRINCL 0x800
+#define NAL_SO_BROADCAST_OP 0x1000
+#define NAL_SO_IP_PKTINFO_OP 0x2000
+
+#if (INCLUDE_MSG_PEEK == NAL_TRUE)
+/* Read operation flags. */
+#define NAL_MSG_PEEK 0x001 /* Leave the received data in queue. */
+#endif
+
+/* Define NAL service completion status constants*/
+#define NAL_RUNLEVEL_COMP_INITIALIZING 2
+#define NAL_SUCCESS 0
+#define NAL_RETURN_ERROR -1
+#define NAL_INVALID_ENTRY -6
+#define NAL_INVALID_OPERATION -13
+#define NAL_INVALID_POINTER -15
+#define NAL_NO_MEMORY -32
+#define NAL_NOT_PRESENT -35
+#define NAL_QUEUE_FULL -45
+#define NAL_TIMEOUT -49
+#define NAL_UNAVAILABLE -50
+#define NAL_RUNLEVEL_COMP_FAILED -84
+
+/* Define NAL Filter error codes*/
+#define FIL_IS_REPEATED -100
+#define FIL_INVALID_PARM -101
+#define FIL_INVALID_SOCK -102
+#define FIL_INVALID_DEST -103
+#define FIL_HAS_DELETED -104
+#define FIL_NEED_BIND -105
+#define FIL_RUN_OUT -106
+#define FIL_ADD_FAIL -107
+#define FIL_DEL_FAIL -108
+#define FIL_INVALID_PROT -109
+
+#define NAL_DEL_ALL -888
+
+/******************* TRANSFER ERROR CODES ***************************
+ The range for NAL transfer error codes is -201 to -250
+*/
+
+#define NAL_STRUCT_TRANS_ERROR -201 /* Fail to transfer the struct type*/
+
+/******************* SOCKET ERROR CODES ****************************
+
+ The range for Nucleus NET error codes is -251 to -500.
+
+*/
+
+#define NAL_INVALID_PROTOCOL -251 /* Invalid network protocol */
+#define NAL_NO_DATA_TRANSFER -252 /* Data was not written/read
+ during send/receive function */
+#define NAL_NO_PORT_NUMBER -253 /* No local port number was stored
+ in the socket descriptor */
+#define NAL_NO_TASK_MATCH -254 /* No task/port number combination
+ existed in the task table */
+#define NAL_NO_SOCKET_SPACE -255 /* The socket structure list was full
+ when a new socket descriptor was
+ requested */
+#define NAL_NO_ACTION -256 /* No action was processed by
+ the function */
+#define NAL_NOT_CONNECTED -257 /* A connection has been closed
+ by the network. */
+#define NAL_INVALID_SOCKET -258 /* The socket ID passed in was
+ not in a valid range. */
+#define NAL_NO_SOCK_MEMORY -259 /* Memory allocation failed for
+ internal sockets structure. */
+#define NAL_INVALID_ADDRESS -260 /* An incomplete address was sent */
+#define NAL_NO_HOST_NAME -261 /* No host name specified in a */
+#define NAL_RARP_INIT_FAILED -262 /* During initialization RARP failed. */
+#define NAL_BOOTP_INIT_FAILED -263 /* During initialization BOOTP failed. */
+#define NAL_INVALID_PORT -264 /* The port number passed in was
+ not in a valid range. */
+#define NAL_NO_BUFFERS -265 /* There were no buffers to place */
+ /* the outgoing packet in. */
+#define NAL_NOT_ESTAB -266 /* A connection is open but not in
+ an established state. */
+#define NAL_WINDOW_FULL -267 /* The foreign host's in window is
+ full. */
+#define NAL_NO_SOCKETS -268 /* No sockets were specified. */
+#define NAL_NO_DATA -269 /* None of the specified sockets were
+ data ready. NAL_Select. */
+
+
+
+/* The following errors are reported by the NAL_Setsockopt and NAL_Getsockopt
+ service calls. */
+#define NAL_INVALID_LEVEL -270 /* The specified level is invalid. */
+#define NAL_INVALID_OPTION -271 /* The specified option is invalid. */
+#define NAL_INVAL -272 /* General purpose error condition. */
+#define NAL_ACCESS -273 /* The attempted operation is not */
+ /* allowed on the socket */
+#define NAL_ADDRINUSE -274
+
+#define NAL_HOST_UNREACHABLE -275 /* Host unreachable */
+#define NAL_MSGSIZE -276 /* Packet is to large for interface. */
+#define NAL_NOBUFS -277 /* Could not allocate a memory buffer. */
+#define NAL_UNRESOLVED_ADDR -278 /* The MAC address was not resolved.*/
+#define NAL_CLOSING -279 /* The other side in a TCP connection*/
+ /* has sent a FIN */
+#define NAL_MEM_ALLOC -280 /* Failed to allocate memory. */
+#define NAL_RESET -281
+#define NAL_DEVICE_DOWN -282 /* A device being used by the socket has
+ gone down. Most likely because a PPP
+ link has been disconnected or a DHCP
+ IP address lease has expired. */
+/* These error codes are returned by DNS. */
+#define NAL_INVALID_LABEL -283 /* Indicates a domain name with an
+ invalid label. */
+#define NAL_FAILED_QUERY -284 /* No response received for a DNS
+ Query. */
+#define NAL_DNS_ERROR -285 /* A general DNS error status. */
+#define NAL_NOT_A_HOST -286 /* The host name was not found. */
+#define NAL_INVALID_PARM -287 /* A parameter has an invalid value. */
+
+#define NAL_NO_DNS_SERVER -288 /* No DNS server has been registered with
+ the stack. */
+
+/* Error codes for DHCP */
+#define NAL_DHCP_INIT_FAILED -289 /* During initialization DHCP failed. */
+#define NAL_DHCP_REQUEST_FAILED -290
+
+/* Error codes for BOOTP */
+#define NAL_BOOTP_SEND_FAILED -291
+#define NAL_BOOTP_RECV_FAILED -292
+#define NAL_BOOTP_ATTACH_IP_FAILED -293
+#define NAL_BOOTP_SELECT_FAILED -294
+#define NAL_BOOTP_FAILED -295
+
+#define NAL_NO_ROUTE_TO_HOST -296 /* ICMP Destination Unreachable specific error */
+#define NAL_CONNECTION_REFUSED -297 /* ICMP Destination Unreachable specific error */
+#define NAL_MSG_TOO_LONG -298 /* ICMP Destination Unreachable specific error */
+
+#define NAL_BAD_SOCKETD -299
+#define NAL_BAD_LEVEL -300
+#define NAL_BAD_OPTION -301
+
+/* IPv6 Errors */
+#define NAL_DUP_ADDR_FAILED -302
+#define NAL_DISCARD_PACKET -303
+
+/* ICMP Error Codes */
+#define NAL_DEST_UNREACH_ADMIN -304
+#define NAL_DEST_UNREACH_ADDRESS -305
+#define NAL_DEST_UNREACH_PORT -306
+#define NAL_TIME_EXCEED_HOPLIMIT -307
+#define NAL_TIME_EXCEED_REASM -308
+#define NAL_PARM_PROB_HEADER -309
+#define NAL_PARM_PROB_NEXT_HDR -310
+#define NAL_PARM_PROB_OPTION -311
+#define NAL_DEST_UNREACH_NET -312
+#define NAL_DEST_UNREACH_HOST -313
+#define NAL_DEST_UNREACH_PROT -314
+#define NAL_DEST_UNREACH_FRAG -315
+#define NAL_DEST_UNREACH_SRCFAIL -316
+#define NAL_PARM_PROB -317
+#define NAL_SOURCE_QUENCH -318
+
+/* This macro will determine whether an error code is an ICMP error message -
+ * if any ICMP error messages are added above, be sure to change this macro
+ * to reflect the additions/changes.
+ */
+#define NAL_ICMP_ERROR_CODE(a) ( (a <= NAL_DEST_UNREACH_ADMIN) && (a >= NAL_SOURCE_QUENCH) ) ? NAL_TRUE : NAL_FALSE
+
+/* Error Code for NON Blocking */
+#define NAL_WOULD_BLOCK -319
+
+/* Error Code for TCP Keep-Alive */
+#define NAL_CONNECTION_TIMED_OUT -320
+
+/* Return status for NON Blocking connect */
+#define NAL_IS_CONNECTING -321
+
+#define NAL_SOCKET_CLOSED -322 /* The specified socket has been closed */
+
+/* Error codes for event registration functions. */
+#define NAL_TABLE_FULL -323
+#define NAL_NOT_FOUND -324
+
+/* IPv6 error codes for processing incoming extension headers */
+#define NAL_INVAL_NEXT_HEADER -325
+#define NAL_SEND_ICMP_ERROR -326
+
+/* Error Codes for multicasting */
+#define NAL_MULTI_TOO_MANY_SRC_ADDRS -327
+#define NAL_NOT_A_GROUP_MEMBER -328
+#define NAL_TOO_MANY_GROUP_MEMBERS -329
+
+#define NAL_ETH_CABLE_UNPLUGGED -330
+#define NAL_ETH_CABLE_PLUGGED_IN -331
+#define NAL_DEVICE_NOT_DOWN -332
+#define NAL_INVALID_DEVICE -333
+#define NAL_FILTER_ERROR -334
+
+#define NAL_INFO_FIELD_RECV_TIME 0x01
+#define NAL_INFO_FIELD_DSCP 0x02
+#define NAL_INFO_FIELD_TS_CONFIDENCE 0x04
+#define NAL_INFO_FIELD_TTL 0x08
+#define NAL_INFO_FIELD_UDP_CHECKSUM 0x10
+
+struct nal_sck_sockaddr_ip_struct
+{
+ nal_uint8 sck_len;
+ nal_uint8 sck_family;
+ nal_uint16 sck_port;
+ nal_uint32 sck_addr;
+ nal_int8 sck_unused[8];
+};
+
+typedef struct _nal_fdset
+{
+ nal_uint32 words[NAL_FD_ELEMENTS];
+} nal_fdset;
+
+/* Structure for scatter/gather I/O. */
+typedef struct _nal_iovec
+{
+ void *iov_base; /* Pointer to data. */
+ nal_size_t iov_len; /* Length of data. */
+}nal_iovec;
+
+/* Structure describing messages sent by
+ `sendmsg' and received by `recvmsg'. */
+typedef struct _nal_msghdr
+{
+ void* msg_name; /* Address to send to/receive from. */
+ nal_socklen_t msg_namelen; /* Length of address data. */
+
+ nal_iovec *msg_iov; /* Vector of data to send/receive into. */
+ nal_size_t msg_iovlen; /* Number of elements in the vector. (size_t = unsigned long = kal_uint32)*/
+
+ void* msg_control; /* Ancillary data (eg BSD filedesc passing). */
+ nal_size_t msg_controllen; /* Ancillary data buffer length.
+ !! The type should be socklen_t but the
+ definition of the kernel is incompatible
+ with this. */
+
+ nal_int msg_flags; /* Flags on received message. */
+}nal_msghdr;
+
+/* 32-bit structure containing 4-digit ip number */
+typedef struct _nal_id_struct
+{
+ nal_uint8 is_ip_addrs[NAL_MAX_ADDR_SIZE]; /* IP address number */
+}nal_id_struct;
+
+typedef struct _nal_addr_struct
+{
+ nal_int16 family; /* family = INTERNET */
+ nal_uint16 port; /* machine's port number */
+ nal_id_struct id; /* contains the 4-digit ip number for the host machine */
+ nal_char *name; /* points to machine's name */
+}nal_addr_struct;
+
+typedef struct _nal_sockaddr_struct
+{
+ nal_id_struct ip_num; /* the address = the ip num */
+ nal_uint16 port_num; /* the process = the port num */
+ nal_int16 family;
+}nal_sockaddr_struct;
+
+typedef struct _nal_linger_struct
+{
+ kal_int32 linger_on;
+ kal_uint32 linger_ticks;
+}nal_linger_struct;
+
+typedef enum _nal_filter_type_t {
+ NAL_FIL_UDP = 0x0,
+ NAL_FIL_TCP,
+ NAL_FIL_ICMP = 0x10,
+ NAL_FIL_OTHER = 0x20
+}nal_filter_type_t;
+
+typedef struct _nal_filter_info_t {
+ kal_int32 socketd;
+ nal_addr_struct* dest;
+ kal_uint8 icmpv4_type;
+ kal_uint8 icmpv6_type;
+}nal_filter_info_t;
+
+typedef struct _nal_info_struct {
+ nal_uint32 fields; /* see NAL_INFO_FIELD_x */
+ nal_uint32 recv_time;
+ nal_uint16 ttl;
+ nal_uint8 dscp;
+ nal_uint8 ts_confidence;
+ nal_uint8 udp_checksum_invalid;
+} nal_info_struct;
+
+
+#ifdef __cplusplus
+}
+#endif /* _cplusplus */
+
+#endif /* NAL_PUBLIC_SOCKDEFS_H */
diff --git a/mcu/interface/service/nal/nal_struct.h b/mcu/interface/service/nal/nal_struct.h
new file mode 100644
index 0000000..24125d0
--- /dev/null
+++ b/mcu/interface/service/nal/nal_struct.h
@@ -0,0 +1,82 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2012
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * nal_struct.h
+ *
+ * Project:
+ * --------
+ * UMOLYE
+ *
+ * Description:
+ * ------------
+ * Defines ILM structures for NAL socket services.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ * ==========================================================================
+ *
+ ****************************************************************************/
+#ifndef __NAL_STRUCT_H__
+#define __NAL_STRUCT_H__
+
+#include "kal_public_defs.h"
+#include "kal_public_api.h"
+#include "kal_general_types.h"
+#include "nal_general_types.h"
+
+/*******************************************************************************
+ * NAL socket API *
+ *******************************************************************************/
+
+#define NAL_SOCKET_EVENT_LIST_MAX_COUNT 10
+
+typedef struct {
+ nal_int32 socketd;
+ nal_uint8 event_type; /* See NAL_SOCKET_EVENT_x */
+} nal_socket_event_struct;
+
+/* Socket event indication */
+typedef struct {
+ LOCAL_PARA_HDR
+ nal_uint8 socket_list_len;
+ nal_socket_event_struct socket_list[NAL_SOCKET_EVENT_LIST_MAX_COUNT];
+} nal_socket_event_ind_struct;
+
+#endif /*__NAL_STRUCT_H__ */