Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers net_interface.h Source File

net_interface.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2014-2019, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef NET_INTERFACE_H_
00019 #define NET_INTERFACE_H_
00020 
00021 #include "ns_types.h"
00022 #include "platform/arm_hal_phy.h"
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 struct mac_api_s;
00029 struct eth_mac_api_s;
00030 
00031 /**
00032  * \file net_interface.h
00033  * \brief  Network API
00034 */
00035 
00036 /** Network Interface Status */
00037 typedef enum arm_nwk_interface_status_type_e {
00038     ARM_NWK_BOOTSTRAP_READY = 0, /**< Interface configured Bootstrap is ready.*/
00039     ARM_NWK_RPL_INSTANCE_FLOODING_READY, /**< RPL instance has been flooded. */
00040     ARM_NWK_SET_DOWN_COMPLETE, /**< Interface DOWN command completed successfully. */
00041     ARM_NWK_NWK_SCAN_FAIL,  /**< Interface has not detected any valid network. */
00042     ARM_NWK_IP_ADDRESS_ALLOCATION_FAIL, /**< IP address allocation failure (ND, DHCPv4 or DHCPv6). */
00043     ARM_NWK_DUPLICATE_ADDRESS_DETECTED, /**< User-specific GP16 was not valid. */
00044     ARM_NWK_AUHTENTICATION_START_FAIL, /**< No valid authentication server detected behind the access point. */
00045     ARM_NWK_AUHTENTICATION_FAIL,    /**< Network authentication failed by handshake. */
00046     ARM_NWK_NWK_CONNECTION_DOWN, /**< No connection between access point and default router. */
00047     ARM_NWK_NWK_PARENT_POLL_FAIL, /**< Sleepy host poll failed 3 times. Interface is shut down. */
00048     ARM_NWK_PHY_CONNECTION_DOWN, /**< Interface PHY cable off or serial port interface not responding anymore. */
00049 } arm_nwk_interface_status_type_e;
00050 
00051 /** Event library type. */
00052 typedef enum arm_library_event_type_e {
00053     ARM_LIB_TASKLET_INIT_EVENT = 0, /**< Tasklet init occurs always when generating a tasklet. */
00054     ARM_LIB_NWK_INTERFACE_EVENT,    /**< Interface bootstrap or state update event. */
00055     ARM_LIB_SYSTEM_TIMER_EVENT, /*!*< System timer event. */
00056     APPLICATION_EVENT, /**< Application-specific event. */
00057 } arm_library_event_type_e;
00058 
00059 
00060 /*
00061  *  Socket event description:
00062  *
00063  *  8-bit variable where four MSB bits describes the event type and
00064  *  four LSB bits describes the socket that has received the event.
00065  *
00066  *      Type   Socket ID
00067  *      ----   ----
00068  *      xxxx   xxxx
00069  *
00070  */
00071 
00072 
00073 /** \name Socket type exceptions.
00074  * @{
00075  */
00076 /** Socket event mask. */
00077 #define SOCKET_EVENT_MASK                   0xF0
00078 /** Data received. */
00079 #define SOCKET_DATA                         (0 << 4)
00080 /** TCP connection ready. */
00081 #define SOCKET_CONNECT_DONE                 (1 << 4)
00082 /** TCP connection failure. */
00083 #define SOCKET_CONNECT_FAIL                 (2 << 4)
00084 /** TCP connection authentication failed. */
00085 #define SOCKET_CONNECT_AUTH_FAIL            (3 << 4)
00086 /** TCP incoming connection on listening socket */
00087 #define SOCKET_INCOMING_CONNECTION          (4 << 4)
00088 /** Socket data send failure. */
00089 #define SOCKET_TX_FAIL                      (5 << 4)
00090 /** TCP connection closed (received their FIN and ACK of our FIN). */
00091 #define SOCKET_CONNECT_CLOSED               (6 << 4)
00092 /** TCP connection reset */
00093 #define SOCKET_CONNECTION_RESET             (7 << 4)
00094 /** No route available to the destination. */
00095 #define SOCKET_NO_ROUTE                     (8 << 4)
00096 /** Socket TX done. */
00097 #define SOCKET_TX_DONE                      (9 << 4)
00098 /** Out of memory failure. */
00099 #define SOCKET_NO_RAM                       (10 << 4)
00100 /** TCP connection problem indication (RFC 1122 R1) */
00101 #define SOCKET_CONNECTION_PROBLEM           (11 << 4)
00102 
00103 #define SOCKET_BIND_DONE                    SOCKET_CONNECT_DONE      /**< Backward compatibility */
00104 #define SOCKET_BIND_FAIL                    SOCKET_CONNECT_FAIL      /**< Backward compatibility */
00105 #define SOCKET_BIND_AUTH_FAIL               SOCKET_CONNECT_AUTH_FAIL /**< Backward compatibility */
00106 /* @} */
00107 
00108 /** Network security levels. */
00109 typedef enum net_security_t {
00110     NW_NO_SECURITY = 0,                       /**< No Security. */
00111     NW_SECURITY_LEVEL_MIC32 = 1,              /**< 32-bit MIC verify, no encoding. */
00112     NW_SECURITY_LEVEL_MIC64 = 2,              /**< 64-bit MIC verify, no encoding. */
00113     NW_SECURITY_LEVEL_MIC128 = 3,             /**< 128-bit MIC verify, no encoding. */
00114     NW_SECURITY_LEVEL_ENC = 4,                /**< AES encoding without MIC. */
00115     NW_SECURITY_LEVEL_ENC_MIC32 = 5,          /**< 32-bit MIC verify with encoding. */
00116     NW_SECURITY_LEVEL_ENC_MIC64 = 6,          /**< 64-bit MIC verify with encoding. */
00117     NW_SECURITY_LEVEL_ENC_MIC128 = 7          /**< 128-bit MIC verify with encoding. */
00118 } net_security_t;
00119 
00120 /** Ipv6 address type.*/
00121 typedef enum net_address_t {
00122     ADDR_IPV6_GP,             /**< Node default global address. */
00123     ADDR_IPV6_GP_SEC,         /**< Node secondary global address. */
00124     ADDR_IPV6_LL              /**< Node default link local address. */
00125 } net_address_t;
00126 
00127 /** MAC address type. */
00128 typedef enum net_mac_address_t {
00129     ADDR_MAC_SHORT16,             /**< Nodes 16-bit short address. */
00130     ADDR_MAC_LONG64,              /**< IP layer EUID64 based on MAC layer 64-bit long address after U/I -bit conversion.  */
00131 } net_mac_address_t;
00132 
00133 /** TLS cipher type */
00134 typedef enum {
00135     NET_TLS_PSK_CIPHER,         /**< Network authentication support, only PSK. */
00136     NET_TLS_ECC_CIPHER,         /**< Network authentication support, only ECC. */
00137     NET_TLS_PSK_AND_ECC_CIPHER, /**< Network authentication support, PSK & ECC. */
00138 } net_tls_cipher_e;
00139 
00140 /** PANA session type. */
00141 typedef enum {
00142     NET_PANA_SINGLE_SESSION,        /**< Client tracks only one PANA session data, default use case. */
00143     NET_PANA_MULTI_SESSION,         /**< Client supports many Start network coordinator session data */
00144 } net_pana_session_mode_e;
00145 
00146 /** 6LoWPAN network security & authentication modes. */
00147 typedef enum {
00148     NET_SEC_MODE_NO_LINK_SECURITY,      /**< Security disabled at link layer, DEFAULT. */
00149     NET_SEC_MODE_PSK_LINK_SECURITY,     /**< Link security by PSK key. */
00150     NET_SEC_MODE_PANA_LINK_SECURITY, /**< PANA network authentication defined link KEY. */
00151 } net_6lowpan_link_layer_sec_mode_e;
00152 
00153 
00154 /** Bootstrap modes */
00155 typedef enum {
00156     NET_6LOWPAN_BORDER_ROUTER,  /**< Root device for 6LoWPAN ND. */
00157     NET_6LOWPAN_ROUTER,         /**< Router device. */
00158     NET_6LOWPAN_HOST,           /**< Host device DEFAULT setting. */
00159     NET_6LOWPAN_SLEEPY_HOST,    /**< Sleepy host device. */
00160     NET_6LOWPAN_NETWORK_DRIVER, /**< 6LoWPAN radio host device, no bootstrap. */
00161     NET_6LOWPAN_SNIFFER         /**< Sniffer device, no bootstrap. */
00162 } net_6lowpan_mode_e;
00163 
00164 /**  6LoWPAN Extension modes. */
00165 typedef enum {
00166     NET_6LOWPAN_ND_WITHOUT_MLE,         /**< **UNSUPPORTED** */
00167     NET_6LOWPAN_ND_WITH_MLE,            /**< 6LoWPAN ND with MLE. */
00168     NET_6LOWPAN_THREAD,                 /**< 6LoWPAN Thread with MLE attached. */
00169     NET_6LOWPAN_WS,                     /**< WS. */
00170     NET_6LOWPAN_ZIGBEE_IP               /**< **UNSUPPORTED** */
00171 } net_6lowpan_mode_extension_e;
00172 
00173 
00174 /** IPv6 bootstrap modes */
00175 typedef enum {
00176     NET_IPV6_BOOTSTRAP_STATIC,  /**< Application defines the IPv6 prefix. */
00177     NET_IPV6_BOOTSTRAP_AUTONOMOUS /**< Interface gets IPv6 address automatically from network using ICMP and DHCP. */
00178 } net_ipv6_mode_e;
00179 
00180 /** IPv6 accept RA behaviour */
00181 typedef enum {
00182     NET_IPV6_RA_ACCEPT_IF_AUTONOMOUS, /**<Accept Router Advertisements when using autonomous IPv6 address allocation. Ignore when using a static address. This is the default value for the setting. */
00183     NET_IPV6_RA_ACCEPT_ALWAYS         /**<Accept Router Advertisements always, even when using static IPv6 address allocation. */
00184 } net_ipv6_accept_ra_e;
00185 
00186 /** Network coordinator parameter list.
00187  * Structure is used to read network parameter for warm start.
00188  */
00189 typedef struct link_layer_setups_s {
00190     uint16_t PANId;            /**< Network PAN-ID. */
00191     uint8_t LogicalChannel;    /**< Network logical channel. */
00192     net_mac_address_t addr_mode;   /**< Coordinator address mode. */
00193     uint8_t address[8];        /**< Coordinator address. */
00194     uint8_t sf;                /**< Network superframe setup. */
00195 } link_layer_setups_s;
00196 
00197 /** Network MAC address info. */
00198 typedef struct link_layer_address_s {
00199     uint16_t PANId;            /**< Network PAN-ID. */
00200     uint16_t mac_short;        /**< MAC short address, if <0xfffe then is valid. */
00201     uint8_t mac_long[8];       /**< MAC long address (EUI-48 for Ethernet; EUI-64 for IEEE 802.15.4). */
00202     uint8_t iid_eui64[8];      /**< IPv6 interface identifier based on EUI-64. */
00203 } link_layer_address_s;
00204 
00205 /** Network layer parent address info. */
00206 typedef struct network_layer_address_s {
00207     uint8_t border_router[16]; /**< ND Border Router Address. */
00208     uint8_t prefix[8];        /**< Long 64-bit network ID. */
00209 } network_layer_address_s;
00210 
00211 /** Different addressing modes for a network interface. */
00212 typedef enum {
00213     NET_6LOWPAN_GP64_ADDRESS,       /**< Interface registers only GP64 address. */
00214     NET_6LOWPAN_GP16_ADDRESS,       /**< Interface registers only GP16 address. */
00215     NET_6LOWPAN_MULTI_GP_ADDRESS,   /**< Interface registers GP16 & GP64 addresses. */
00216 } net_6lowpan_gp_address_mode_e;
00217 
00218 /** TLS PSK info */
00219 typedef struct net_tls_psk_info_s {
00220     uint32_t key_id;    /**< PSK Key ID can be 0x01-0xffff, storage size is intentionally 32 bits. */
00221     uint8_t key[16];    /**< 128-bit PSK Key. */
00222 } net_tls_psk_info_s;
00223 
00224 /** NETWORK PSK link key structure. */
00225 typedef struct {
00226     uint8_t key_id;             /**< Link layer PSK Key ID, can be 0x01-0xff. */
00227     uint8_t security_key[16];   /**< Link layer 128-bit PSK Key. */
00228 } net_link_layer_psk_security_info_s;
00229 
00230 /** Certificate chain structure. */
00231 typedef struct {
00232     uint8_t chain_length;           /**< Certificate chain length, indicates the chain length. */
00233     const uint8_t *cert_chain[4];   /**< Certificate chain pointer list. */
00234     uint16_t cert_len[4];           /**< Certificate length. */
00235     const uint8_t *key_chain[4];    /**< Certificate private key. */
00236 } arm_certificate_chain_entry_s;
00237 
00238 /** Certificate structure. */
00239 typedef struct {
00240     const uint8_t *cert;           /**< Certificate pointer. */
00241     const uint8_t *key;            /**< Key pointer. */
00242     uint16_t cert_len;             /**< Certificate length. */
00243     uint16_t key_len;              /**< Key length. */
00244 } arm_certificate_entry_s;
00245 
00246 /** Certificate Revocation List structure. */
00247 typedef struct {
00248     const uint8_t *crl;            /**< Certificate Revocation List pointer. */
00249     uint16_t crl_len;              /**< Certificate Revocation List length. */
00250 } arm_cert_revocation_list_entry_s;
00251 
00252 /** Structure for the network keys used by net_network_key_get */
00253 typedef struct ns_keys_t
00254 
00255 {
00256     uint8_t previous_active_network_key[16];    /**< The key that is currently active when a new key is generated and activated. */
00257     uint8_t previous_active_key_index;           /**< The index associated to the current_active_network_key. */
00258     uint8_t current_active_network_key[16];     /**< Last generated and activated key. */
00259     uint8_t current_active_key_index;           /**< The index associated to the current_active_network_key. */
00260 } ns_keys_t;
00261 
00262 /** 6LoWPAN border router information structure. */
00263 typedef struct {
00264     uint16_t mac_panid;             /**< Link layer PAN-ID, accepts only < 0xfffe.  */
00265     uint16_t mac_short_adr;         /**< Defines 802.15.4 short address. If the value is <0xfffe it indicates that GP16 is activated. */
00266     uint8_t beacon_protocol_id;     /**< ZigBeeIP uses always 2. */
00267     uint8_t network_id[16];         /**< Network ID 16-bytes, will be used at beacon payload. */
00268     uint8_t lowpan_nd_prefix[8];    /**< Define ND default prefix, ABRO, DODAG ID, GP address. */
00269     uint16_t ra_life_time;          /**< Define ND router lifetime in seconds, recommend value 180+. */
00270     uint32_t abro_version_num;      /**< ND ABRO version number (0 when starting a new ND setup). */
00271 } border_router_setup_s;
00272 
00273 /** Channel list */
00274 typedef struct channel_list_s {
00275     channel_page_e channel_page;    /**< Channel page */
00276     uint32_t channel_mask[8];       /**< Channel mask. Each bit defining one channel */
00277 } channel_list_s;
00278 
00279 /** 6LoWPAN radio interface setup. */
00280 typedef struct {
00281     uint16_t mac_panid;                 /**< Link layer PAN-ID, accepts only < 0xfffe. */
00282     uint16_t mac_short_adr;             /**< Defines 802.15.4 short address. If the value is <0xfffe it indicates that GP16 is activated. */
00283     uint8_t beacon_protocol_id;         /**< ZigBeeIP uses always 2. */
00284     uint8_t network_id[16];             /**< Network ID 16-bytes, will be used at beacon payload. */
00285     uint8_t beacon_payload_tlv_length; /**< Optional steering parameter length. */
00286     uint8_t *beacon_payload_tlv_ptr;  /**< Optional steering parameters. */
00287 } network_driver_setup_s;
00288 
00289 /**
00290   * Init 6LoWPAN library
00291   *
00292   * \return 0, Init OK.
00293   */
00294 extern int8_t net_init_core(void);
00295 
00296 /**
00297  * \brief Create network interface base to IDLE state.
00298  * \param api Generates interface with ethernet MAC.
00299  * \param interface_name_ptr String pointer to interface name. Need to end to '\0' character.
00300  *        Max length 32 characters including NULL at end. Note: the given name is not copied,
00301  *        so it must remain valid as long as the interface is.
00302  *
00303  * \return >=0 Interface ID (0-127). Application needs to save this information.
00304  * \return -1 api was NULL.
00305  * \return -2 Ethernet is not supported at this build.
00306  * \return -3 No memory for the interface.
00307  */
00308 extern int8_t arm_nwk_interface_ethernet_init(struct eth_mac_api_s *api, const char *interface_name_ptr);
00309 
00310 /**
00311  * \brief Create network interface base to IDLE state.
00312  * \param api Generates interface with 802.15.4 MAC.
00313  * \param interface_name_ptr String pointer to interface name. Need to end to '\0' character.
00314  *        Max length 32 characters including NULL at end. Note: the given name is not copied,
00315  *        so it must remain valid as long as the interface is.
00316  *
00317  * \return >=0 Interface ID (0-127). Application needs to save this information.
00318  * \return -1 api was NULL.
00319  * \return -3 No memory for the interface.
00320  */
00321 extern int8_t arm_nwk_interface_lowpan_init(struct mac_api_s *api, char *interface_name_ptr);
00322 
00323 /**
00324  * \brief Create network interface base to IDLE state.
00325  * \param api Generates interface with PPP.
00326  * \param interface_name_ptr String pointer to interface name. Need to end to '\0' character.
00327  *        Max length 32 characters including NULL at end. Note: the given name is not copied,
00328  *        so it must remain valid as long as the interface is.
00329  *
00330  * \return >=0 Interface ID (0-127). Application needs to save this information.
00331  * \return -1 api was NULL.
00332  * \return -2 PPP is not supported at this build.
00333  * \return -3 No memory for the interface.
00334  */
00335 extern int8_t arm_nwk_interface_ppp_init(struct eth_mac_api_s *api, const char *interface_name_ptr);
00336 
00337 /**
00338  * \brief Set IPv6 interface setup.
00339  *
00340  * \param interface_id Network interface ID.
00341  * \param bootstrap_mode Selected bootstrap mode:
00342  *      * NET_IPV6_BOOTSTRAP_STATIC, Application defines the IPv6 prefix.
00343  * \param ipv6_prefix_pointer Pointer to 64 bit IPv6 prefix. The data is copied, so it can be invalidated after function call.
00344  *
00345  * \return >=0 Bootstrap mode set OK.
00346  * \return -1 Unknown network ID.
00347  */
00348 extern int8_t arm_nwk_interface_configure_ipv6_bootstrap_set(int8_t interface_id, net_ipv6_mode_e bootstrap_mode, const uint8_t *ipv6_prefix_pointer);
00349 
00350 /**
00351  * \brief Accept Router Advertisements setting.
00352  *
00353  * Accept Router Advertisements setting. Setting can be changed after an interface is created.
00354  * If setting is changed it must be done before the bootstrap is started.
00355  *
00356  * \param interface_id The network interface ID.
00357  * \param accept_ra Router Advertisements handling mode.
00358  * \return 0 Setting done.
00359  * \return <0 Failed (for example an invalid interface ID).
00360  */
00361 extern int8_t arm_nwk_interface_accept_ipv6_ra(int8_t interface_id, net_ipv6_accept_ra_e accept_ra);
00362 
00363 /**
00364  * \brief Set network interface bootstrap setup.
00365  *
00366  * \param interface_id Network interface ID.
00367  * \param bootstrap_mode Selected bootstrap mode:
00368  *      * NET_6LOWPAN_BORDER_ROUTER, Initialize border router basic setup.
00369  *      * NET_6LOWPAN_ROUTER, Enable normal 6LoWPAN ND and RPL to bootstrap.
00370  *      * NET_6LOWPAN_HOST, Enable normal 6LoWPAN ND only to bootstrap.
00371  *      * NET_6LOWPAN_SLEEPY_HOST, Enable normal 6LoWPAN ND only to bootstrap.
00372  *      * NET_6LOWPAN_NETWORK_DRIVER, 6LoWPAN radio host device no bootstrap.
00373  *      * NET_6LOWPAN_SNIFFER, 6LoWPAN sniffer device no bootstrap.
00374  *
00375  * \param net_6lowpan_mode_extension Define 6LoWPAN MLE and mode as ZigBeeIP or Thread.
00376  *
00377  * \return >=0 Bootstrap mode set OK.
00378  * \return -1 Unknown network ID.
00379  * \return -2 Unsupported bootstrap type in this library.
00380  * \return -3 No memory for 6LoWPAN stack.
00381  * \return -4 Null pointer parameter.
00382  */
00383 extern int8_t arm_nwk_interface_configure_6lowpan_bootstrap_set(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode, net_6lowpan_mode_extension_e net_6lowpan_mode_extension);
00384 
00385 /**
00386  * \brief Set network interface link layer parameters.
00387  *
00388  * \param interface_id Network interface ID
00389  * \param nwk_channel_list Defines network channel page and channel.
00390  * \param link_setup Link layer parameters for NET_6LOWPAN_NETWORK_DRIVER defines NetworkID, PAN-ID Short Address.
00391  *
00392  * \return >=0 Configuration set OK.
00393  * \return -1 Unknown network ID.
00394  * \return -2 Interface is active, bootsrap mode not selected or is not NET_6LOWPAN_NETWORK_DRIVER or NET_6LOWPAN_SNIFFER.
00395  * \return -3 No memory for 6LoWPAN stack.
00396  * \return -4 Null pointer parameter.
00397  */
00398 extern int8_t arm_nwk_interface_network_driver_set(int8_t interface_id, const channel_list_s *nwk_channel_list, network_driver_setup_s *link_setup);
00399 
00400 /**
00401  * \brief Set configured network interface global address mode (border router bootstrap mode cannot set this).
00402  *
00403  * \param interface_id Network interface ID.
00404  * \param mode Define 6LoWPAN Global Address register mode:
00405  *      * NET_6LOWPAN_GP64_ADDRESS, Interface registers only GP64
00406  *      * NET_6LOWPAN_GP16_ADDRESS, Interface registers only GP16
00407  *      * NET_6LOWPAN_MULTI_GP_ADDRESS, Interface registers GP16 and GP64 addresses. GP16 is primary address and GP64 is secondary.
00408  *
00409  * \param short_address_base Short address base. If the application defines value 0-0xfffd, 6LoWPAN tries to register GP16 address
00410  * using that address. 0xfffe and 0xffff generate random 16-bit short address.
00411  *
00412  * \param define_new_short_address_at_DAD This parameter is only checked when mode is not NET_6LOWPAN_GP64_ADDRESS and
00413  * short_address_base is 0-0xfffd. Recommended value is 1. It enables automatic new address definition at
00414  * Duplicate Address Detection (DAD). Value 0 generates a DAD error for the interface bootstrap.
00415  * Border router device will not check that part.
00416  *
00417  * \return >=0 Bootstrap mode set OK.
00418  * \return -1 Unknown network ID.
00419  * \return -2 Illegal for border router.
00420  * \return -3 No memory for 6LoWPAN stack.
00421  */
00422 extern int8_t arm_nwk_6lowpan_gp_address_mode(int8_t interface_id, net_6lowpan_gp_address_mode_e mode, uint16_t short_address_base, uint8_t define_new_short_address_at_DAD);
00423 
00424 /**
00425  * \brief Set the channel list configuration to be used on the network interface.
00426  *
00427  * \param interface_id Network interface ID.
00428  * \param nwk_channel_list Channel list to be used.
00429  *
00430  * \return >=0 Channel configuration OK.
00431  * \return -1 Unknown network interface ID.
00432  * \return -2 Empty channel list, no channels enabled.
00433  * \return -4 If network interface is already active and cannot be re-configured.
00434  */
00435 extern int8_t arm_nwk_set_channel_list(int8_t interface_id, const channel_list_s *nwk_channel_list);
00436 
00437 /**
00438  * \brief Set the link scan time used on network interface.
00439  *
00440  * \param interface_id Network interface ID.
00441  * \param scan_time Value 0-14, scan duration/channel.
00442  *
00443  * \return >=0 Scan configuration OK.
00444  * \return -1 Unknown network interface ID.
00445  * \return -4 If network interface is already active and cannot be re-configured.
00446  * \return -5 Invalid scan time.
00447  */
00448 extern int8_t arm_nwk_6lowpan_link_scan_parameter_set(int8_t interface_id, uint8_t scan_time);
00449 
00450 /**
00451  * \brief A function to set the PAN ID filter.
00452  *
00453  * \param interface_id Network interface ID.
00454  * \param pan_id_filter Enable filter for specific PAN ID. 0xffff disables the filter.
00455  *
00456  * \return 0 Filter set OK.
00457  * \return -1 Unknown Network interface ID.
00458  * \return -2 Interface is active.
00459  *
00460  */
00461 extern int8_t arm_nwk_6lowpan_link_panid_filter_for_nwk_scan(int8_t interface_id, uint16_t pan_id_filter);
00462 
00463 /**
00464   * \brief Get current used channel.
00465   *
00466   * \param interface_id Network interface ID.
00467   *
00468   * \return Active channel.
00469   * \return -1 = Radio is closed.
00470   */
00471 extern int16_t arm_net_get_current_channel(int8_t interface_id);
00472 
00473 /**
00474  * \brief A function to read the PAN ID filter.
00475  *
00476  * \param interface_id Network interface ID.
00477  *
00478  * \return 16-bit value indicating a PAN ID filter.
00479  */
00480 extern uint16_t arm_net_get_nwk_pan_id_filter(int8_t interface_id);
00481 
00482 /**
00483   * \brief Enable/Disable network ID filter.
00484   *
00485   * \param interface_id Network interface ID.
00486   * \param nwk_id_filter A pointer to a new network ID filter, NULL disable filter.
00487   *
00488   * \return 0 On success.
00489   * \return -1 Unknown network ID.
00490   * \return -2 Interface active.
00491   */
00492 extern int8_t arm_nwk_6lowpan_link_nwk_id_filter_for_nwk_scan(int8_t interface_id, const uint8_t *nwk_id_filter);
00493 
00494 /**
00495   * \brief Enable/Disable network protocol ID filter.
00496   *
00497   * \param interface_id Network interface ID.
00498   * \param protocol_ID A value that filters only supported network protocols (0= Zigbee1.x, 2= ZigBeeIP).
00499   *
00500   * \return 0 On success.
00501   * \return -1 Unknown network ID.
00502   * \return -2 Interface active.
00503   */
00504 extern int8_t arm_nwk_6lowpan_link_protocol_id_filter_for_nwk_scan(int8_t interface_id, uint8_t protocol_ID);
00505 
00506 /**
00507   * \brief Beacon join priority transmit callback.
00508   *
00509   * Callback defines join priority that is transmitted in beacon. Join priority is
00510   * 8 bit field in beacon that can be set e.g. based on RPL protocol rank data.
00511   *
00512   * \param interface_id The network interface ID.
00513   *
00514   * \return Join priority to be transmitted in beacon. 0 to 255.
00515   */
00516 typedef uint8_t beacon_join_priority_tx_cb(int8_t interface_id);
00517 
00518 /**
00519   * \brief Compare received beacon callback.
00520   *
00521   * Callback defines how preferred the node that has sent beacon is for connecting
00522   * to the network.
00523   *
00524   * \param interface_id The network interface ID.
00525   * \param join_priority Join priority that has been received in beacon. 0 to 255.
00526   * \param link_quality Link quality. 0 to 255. 255 is best quality.
00527   *
00528   * \return Connect to preference. 0 to 255. 255 is highest connect to preference.
00529   */
00530 typedef uint8_t beacon_compare_rx_cb(int8_t interface_id, uint8_t join_priority, uint8_t link_quality);
00531 
00532 /**
00533   * \brief Set callback for beacon join priority transmit
00534   *
00535   * Sets callback that defines join priority that is transmitted in beacon.
00536   * If callback is not set default functionality is used. On default functionality
00537   * join priority is combined from RPL DAGRank and RPL DODAG preference.
00538   *
00539   * \param interface_id The network interface ID.
00540   * \param beacon_join_priority_tx_cb_ptr Function pointer.
00541   *
00542   * \return 0 on success.
00543   * \return -1 Unknown network ID.
00544   * \return -2 Other error.
00545   */
00546 extern int8_t arm_nwk_6lowpan_beacon_join_priority_tx_callback_set(int8_t interface_id, beacon_join_priority_tx_cb *beacon_join_priority_tx_cb_ptr);
00547 
00548 /**
00549   * \brief Set callback for comparing received beacon
00550   *
00551   * Sets callback that defines how preferred the node that has sent beacon is for
00552   * connecting to the network. If callback is not set default functionality is used.
00553   * On default functionality connecting priority is defined based on join priority
00554   * received in beacon and link quality.
00555   *
00556   * \param interface_id Network interface ID.
00557   * \param beacon_compare_rx_cb_ptr Function pointer.
00558   *
00559   * \return 0 on success.
00560   * \return -1 Unknown network ID.
00561   * \return -2 Other error.
00562   */
00563 extern int8_t arm_nwk_6lowpan_beacon_compare_rx_callback_set(int8_t interface_id, beacon_compare_rx_cb *beacon_compare_rx_cb_ptr);
00564 
00565 /**
00566   * \brief Initialize and configure the interface security mode.
00567   *
00568   * \param interface_id Network interface ID.
00569   * \param mode Defines link layer security mode.
00570   *  NET_SEC_MODE_NO_LINK_SECURITY, No security.
00571   *  NET_SEC_MODE_PSK_LINK_SECURITY, Predefined PSK link layer key and ID.
00572   *  NET_SEC_MODE_PANA_LINK_SECURITY, PANA bootstrap network authentication.
00573   *
00574   * \param sec_level Defined security level is checked only when the mode is not NET_SEC_MODE_NO_LINK_SECURITY.
00575   * \param psk_key_info Pointer for PSK link layer keys. Checked only when the mode is NET_SEC_MODE_PSK_LINK_SECURITY.
00576   *
00577   * \return 0 on success.
00578   */
00579 
00580 extern int8_t arm_nwk_link_layer_security_mode(int8_t interface_id, net_6lowpan_link_layer_sec_mode_e mode, uint8_t sec_level, const net_link_layer_psk_security_info_s *psk_key_info);
00581 
00582 /**
00583   * \brief Initialize and configure interface PANA network client.
00584   *
00585   * \param interface_id Network interface ID.
00586   * \param cipher_mode Defines TLS 1.2 Cipher mode PSK, ECC or both.
00587   * \param psk_key_id PSK KEY id for PSK Setup
00588   *
00589   * \return 0 on success.
00590   * \return -1 Unknown network ID or PANA is not supported at this library.
00591   * \return -2 Interface active.
00592   */
00593 extern int8_t arm_pana_client_library_init(int8_t interface_id, net_tls_cipher_e cipher_mode, uint32_t psk_key_id);
00594 
00595 /**
00596   * \brief Initialize and Configure interface PANA network server.
00597   *
00598   * \param interface_id Network interface ID.
00599   * \param cipher_mode Defines TLS 1.2 Cipher mode PSK, ECC or both.
00600   * \param key_material A pointer to 128-bit key material or NULL when the PANA server generates the random key.
00601   * \param time_period_before_activate_key Guard period after a succesful key delivery phase before the key will be activated by server.
00602   *
00603   * \return 0 On success.
00604   * \return -1 Unknown network ID.
00605   * \return -2 Interface active.
00606   */
00607 extern int8_t arm_pana_server_library_init(int8_t interface_id, net_tls_cipher_e cipher_mode, const uint8_t *key_material, uint32_t time_period_before_activate_key);
00608 
00609 /**
00610   * \brief Manually initiate a PANA client key pull. For test purposes only.
00611   *
00612   * \param interface_id Network interface ID.
00613   *
00614   * \return 0 On success.
00615   * \return -1 Unknown network ID.
00616   */
00617 extern int8_t arm_pana_client_key_pull(int8_t interface_id);
00618 
00619 /**
00620  * \brief Trigger network key update process
00621  *
00622  * This function delivers a new network key to all ZigBee routers that have registered a GP address to server.
00623  * The function call always trig new key-id. Key delivery is started in 300ms interval between nodes.
00624  * This function does not cause any traffic if the server does not have any router device sessions.
00625  *
00626  * \param interface_id Network interface ID.
00627  * \param network_key_material Pointer to new 128-bit key material, NULL generates a random key.
00628  *
00629  * \return 0 Key Update process OK.
00630  * \return -1 PANA server is not initialized yet.
00631  * \return -2 Old key update still active.
00632  * \return -3 Memory allocation fails.
00633  */
00634 extern int8_t arm_pana_server_key_update(int8_t interface_id, const uint8_t *network_key_material);
00635 
00636 /**
00637  * \brief Activate new key material before standard timeout.
00638  *
00639  * This function is only for testing.
00640  *
00641  * \param interface_id Network interface ID.
00642  *
00643  * \return 0 Key activate process OK.
00644  * \return -1 No Pending key update.
00645  * \return -2 PANA server is not initialized or PANA server API is disabled with this library.
00646  */
00647 extern int8_t arm_pana_activate_new_key(int8_t interface_id);
00648 
00649 /**
00650  * \brief Read PANA server security key material.
00651  *
00652  * previous_active_network_key Only valid when current_active_key_index is bigger than 1.
00653  *
00654  * \param interface_id Interface
00655  * \param key Pointer for key material information store.
00656  *
00657  * \return 0 Key read OK.
00658  * \return -1 PANA server key material not available.
00659  */
00660 extern int8_t arm_network_key_get(int8_t interface_id, ns_keys_t *key);
00661 
00662 /**
00663  * \brief Start network interface bootstrap.
00664  *
00665  * \param interface_id Network interface ID.
00666  *
00667  *
00668  * \return >=0 Bootstrap start OK.
00669  * \return -1 Unknown network ID.
00670  * \return -2 Not configured.
00671  * \return -3 Active.
00672  */
00673 extern int8_t arm_nwk_interface_up(int8_t interface_id);
00674 
00675 /**
00676  * \brief Stop and set interface to idle.
00677  *
00678  * \param interface_id Network interface ID
00679  *
00680  * \return >=0 Process OK.
00681  * \return -1 Unknown network ID.
00682  * \return -3 Not Active.
00683  */
00684 extern int8_t arm_nwk_interface_down(int8_t interface_id);
00685 
00686 /**
00687  * \brief Define border router MAC and 6LoWPAN ND setup for selected interface.
00688  *
00689  * \param interface_id Network interface ID.
00690  * \param border_router_setup_ptr Pointer to MAC and 6LoWPAN ND setup.
00691  *
00692  * \return 0 on success, negative value on error case.
00693  */
00694 extern int8_t arm_nwk_6lowpan_border_router_init(int8_t interface_id, const border_router_setup_s *border_router_setup_ptr);
00695 
00696 /**
00697  * \brief Add context at 6LoWPAN interface configure state.
00698  *
00699  * \param interface_id Network interface ID.
00700  * \param c_id_flags Bit 4 indicates compress support and bit 0-3 context ID.
00701  * \param context_len Context length in bits need to be 64-128.
00702  * \param ttl Context time to live, value in minutes.
00703  * \param context_ptr Pointer to full 128-bit memory area.
00704  *
00705  * \return 0 Context update OK.
00706  * \return -1 No memory for new context.
00707  * \return -2 Border router base not allocated.
00708  * \return -3 Given parameter fails (c_id_flags > 0x1f or contex_len < 64).
00709  * \
00710  */
00711 extern int8_t arm_nwk_6lowpan_border_router_context_update(int8_t interface_id, uint8_t c_id_flags, uint8_t context_len, uint16_t ttl, const uint8_t *context_ptr);
00712 
00713 /**
00714  * \brief Update runtime configured context.
00715  *
00716  * This function can change the value of context compress state or time to live.
00717  * It triggers a new ABRO version number, indicating that ND parameters are updated.
00718  *
00719  * \param interface_id Network interface ID.
00720  * \param c_id Context ID stack checks first 4 bits, supported values 0-15.
00721  * \param compress_mode 0 = Compress disabled, otherwise compress enabled.
00722  * \param ttl Context time to live value in minutes.
00723  *
00724  * \return 0 Update OK.
00725  * \return -1 Update fail by router state.
00726  *
00727  */
00728 extern int8_t arm_nwk_6lowpan_border_router_context_parameter_update(int8_t interface_id, uint8_t c_id, uint8_t compress_mode, uint16_t ttl);
00729 
00730 /**
00731  * \brief Delete allocated context by ID.
00732  *
00733  * \param interface_id Network interface ID.
00734  * \param c_id 4-bit Context ID to be deleted.
00735  *
00736  * \return 0 Context delete OK.
00737  * \return -1 Delete process fails.
00738  */
00739 extern int8_t arm_nwk_6lowpan_border_router_context_remove_by_id(int8_t interface_id, uint8_t c_id);
00740 
00741 /**
00742  * \brief Update ND ABRO version number.
00743  *
00744  * \param interface_id Network interface ID
00745  *
00746  * \return 0 ABRO version update OK.
00747  * \return -1 ABRO update fails (Interface is not up yet or the border router base is not allocated).
00748  */
00749 extern int8_t arm_nwk_6lowpan_border_router_configure_push(int8_t interface_id);
00750 
00751 /**
00752  * Set timeout for default prefix on cache.
00753  * Requires arm_nwk_6lowpan_border_router_configure_push() be called to settings be taken into use.
00754  * \param interface_id mesh interface.
00755  * \param time seconds
00756  * \return 0 on success, negative value on failure.
00757  */
00758 extern int8_t arm_nwk_6lowpan_border_route_nd_default_prefix_timeout_set(int8_t interface_id, uint32_t time);
00759 
00760 /**
00761  * \brief A function to read network layer configurations.
00762  * \param interface_id Network interface ID.
00763  * \param network_params A pointer to the structure where the network layer configs are written.
00764  * \return 0 On success.
00765  * \return Negative value if interface is not known.
00766  */
00767 int8_t arm_nwk_param_read(int8_t interface_id, link_layer_setups_s *network_params);
00768 
00769 /**
00770  * \brief A function to read MAC PAN-ID, Short address and EUID64.
00771  * \param interface_id Network interface ID.
00772  * \param mac_params A pointer to the structure where the MAC addresses are written.
00773  * \return 0 On success.
00774  * \return Negative value if interface is not known.
00775  */
00776 int8_t arm_nwk_mac_address_read(int8_t interface_id, link_layer_address_s *mac_params);
00777 
00778 /**
00779  * \brief A function to read 6LoWPAN ND border router address and NWK prefix.
00780  * \param interface_id Network interface ID.
00781  * \param nd_addr_info Pointer to the structure where the address is written.
00782  * \return 0 On success.
00783  * \return Negative value if network interface is not known or if the interface
00784  *          is not in active or ready state.
00785  */
00786 int8_t arm_nwk_nd_address_read(int8_t interface_id, network_layer_address_s *nd_addr_info);
00787 
00788 /**
00789  * \brief A function to read the networking address information.
00790  * \param interface_id Network interface ID.
00791  * \param addr_id The address information type to be read.
00792  * \param address A pointer to a structure where the address information is written.
00793  * \return 0 On success, -1 on failure.
00794  */
00795 extern int8_t arm_net_address_get(int8_t interface_id, net_address_t addr_id, uint8_t *address);
00796 
00797 /**
00798  * \brief A function to read networking addresses one by one.
00799  * \param interface_id Network interface ID.
00800  * \param n A pointer that is incremented every call. Start looping with n=0.
00801  * \param address_buffer A pointer to buffer where address is copied.
00802  * \return 0 On success.
00803  * \return -1 No more addresses available.
00804  */
00805 extern int8_t arm_net_address_list_get_next(int8_t interface_id, int *n, uint8_t address_buffer[16]);
00806 
00807 /**
00808  * \brief A function to read network interface address count.
00809  * \param interface_id Network interface ID.
00810  * \param address_count A pointer to the structure where the address count is saved.
00811  *
00812  * \return 0 On success, -1 on errors.
00813  */
00814 extern int8_t arm_net_interface_address_list_size(int8_t interface_id, uint16_t *address_count);
00815 
00816 /**
00817  * \brief A function to set interface metric.
00818  * \param interface_id Network interface ID.
00819  * \param metric Used to rank otherwise-equivalent routes. Lower is preferred and default is 0. The metric value is added to metric provided by the arm_net_route_add() function.
00820  *
00821  * \return 0 On success, -1 on errors.
00822  */
00823 extern int8_t arm_net_interface_set_metric(int8_t interface_id, uint16_t metric);
00824 
00825 /**
00826  * \brief A function to read the interface metric value on an interface.
00827  * \param interface_id Network interface ID.
00828  * \param metric A pointer to the variable where the interface metric value is saved.
00829  *
00830  * \return 0 On success, -1 on errors.
00831  */
00832 extern int8_t arm_net_interface_get_metric(int8_t interface_id, uint16_t *metric);
00833 
00834 /**
00835  * \brief A function to read the network interface.
00836  * \param interface_id Network interface ID.
00837  * \param address_buf_size Buffer size in bytes, minimum 16 bytes.
00838  * \param address_buffer A pointer to a structure where the addresses are saved one by one.
00839  * \param writed_address_count A pointer to the structure where the number of addresses saved is written.
00840  *
00841  * \return 0 on success, -1 on errors.
00842  */
00843 extern int8_t arm_net_address_list_get(int8_t interface_id, uint8_t address_buf_size, uint8_t *address_buffer, int *writed_address_count);
00844 
00845 /**
00846  * \brief A function to add an address to an interface.
00847  * \param interface_id Network interface ID.
00848  * \param address The address to be added to the interface.
00849  * \param prefix_len The length of the address prefix.
00850  * \param valid_lifetime The time in seconds until the address becomes invalid and is removed from the interface. Value 0xffffffff represents infinity.
00851  * \param preferred_lifetime The time in seconds until the address becomes deprecated. Value 0xffffffff represents infinity. The preferred lifetime should not be longer than a valid lifetime.
00852  * \return 0 on success, -1 on errors.
00853  */
00854 extern int8_t arm_net_address_add_to_interface(int8_t interface_id, const uint8_t address[16], uint8_t prefix_len, uint32_t valid_lifetime, uint32_t preferred_lifetime);
00855 
00856 /**
00857  * \brief A function to remove an address from an interface.
00858  * \param interface_id Network interface ID.
00859  * \param address The address to be removed from the interface.
00860  *
00861  * \return 0 on success, -1 on errors.
00862  */
00863 extern int8_t arm_net_address_delete_from_interface(int8_t interface_id, const uint8_t address[16]);
00864 
00865 /**
00866  * \brief A function to add a route to the routing table.
00867  * \param prefix Destination prefix for the route to be added.
00868  * \param prefix_len The length of the prefix.
00869  * \param next_hop Link-local address of the next hop (e.g. router); if NULL the route is marked as on-link.
00870  * \param lifetime The time in seconds until the route is removed from the routing table. Value 0xffffffff means infinite.
00871  * \param metric Used to rank otherwise-equivalent routes. Lower is preferred. Normally 128.
00872  * \param interface_id Network interface ID.
00873  * \return 0 on success, -1 on add failure, -2 on invalid function parameters.
00874  */
00875 extern int8_t arm_net_route_add(const uint8_t *prefix, uint8_t prefix_len, const uint8_t *next_hop, uint32_t lifetime, uint8_t metric, int8_t interface_id);
00876 
00877 /**
00878  * \brief A function to remove a route from the routing table.
00879  * \param prefix The prefix to be removed.
00880  * \param prefix_len The length of the prefix.
00881  * \param next_hop Link-local address of the next hop.
00882  * \param interface_id Network interface ID.
00883  * \return 0 on success, -1 on delete failure, -2 on invalid function parameters.
00884  */
00885 extern int8_t arm_net_route_delete(const uint8_t *prefix, uint8_t prefix_len, const uint8_t *next_hop, int8_t interface_id);
00886 
00887 /** Border Router ND NVM update types. */
00888 /** ND context update, 20 bytes data behind pointer. */
00889 #define ND_PROXY_CONTEXT_NVM_UPDATE         0
00890 /** ND context update flags update. */
00891 #define ND_PROXY_CONTEXT_FLAGS_NVM_UPDATE   1
00892 /** ND context remove. */
00893 #define ND_PROXY_CONTEXT_NVM_REMOVE         2
00894 /** ND prefix update. */
00895 #define ND_PROXY_PREFIX_NVM_UPDATE          3
00896 /** ND ABRO version update. */
00897 #define ND_PROXY_ABRO_VERSION_NVM_UPDATE    4
00898 
00899 /**
00900  * \brief Load context from NVM at ZigBeeIP interface configure state.
00901  *
00902  * \param interface_id Network Interface ID
00903  * \param contex_data A pointer to properly built 20 bytes update array.
00904  *
00905  * \return 0 Context reload OK.
00906  * \return <0 Load fail.
00907  */
00908 extern int8_t arm_nwk_6lowpan_border_router_nd_context_load(int8_t interface_id, uint8_t *contex_data);  //NVM
00909 
00910 /**
00911  * Set certificate chain
00912  *
00913  * \param chain_info Certificate chain.
00914  * \return 0 on success, negative on failure.
00915  */
00916 extern int8_t arm_network_certificate_chain_set(const arm_certificate_chain_entry_s *chain_info);
00917 
00918 /**
00919  * Add trusted certificate
00920  *
00921  * This is used to add trusted root or intermediate certificate in addition to those
00922  * added using certificate chain set call. Function can be called several times to add
00923  * more than one certificate.
00924  *
00925  * \param cert Certificate.
00926  * \return 0 on success, negative on failure.
00927  */
00928 extern int8_t arm_network_trusted_certificate_add(const arm_certificate_entry_s *cert);
00929 
00930 /**
00931  * Remove trusted certificate
00932  *
00933  * This is used to remove trusted root or intermediate certificate.
00934  *
00935  * \param cert Certificate.
00936  * \return 0 on success, negative on failure.
00937  */
00938 extern int8_t arm_network_trusted_certificate_remove(const arm_certificate_entry_s *cert);
00939 
00940 /**
00941  * Remove trusted certificates
00942  *
00943  * This is used to remove all trusted root or intermediate certificates.
00944  *
00945  * \return 0 on success, negative on failure.
00946  */
00947 extern int8_t arm_network_trusted_certificates_remove(void);
00948 
00949 /**
00950  * Add own certificate
00951  *
00952  * This is used to add own certificate and private key.
00953  * In case intermediate certificates are used, function can be called several times. Each call
00954  * to the function adds a certificate to own certificate chain.
00955  * Certificates are in bottom up order i.e. the top certificate is given last.
00956  *
00957  * \param cert Certificate.
00958  * \return 0 on success, negative on failure.
00959  */
00960 extern int8_t arm_network_own_certificate_add(const arm_certificate_entry_s *cert);
00961 
00962 /**
00963  * Remove own certificates
00964  *
00965  * This is used to remove own certificates (chain).
00966  *
00967  * \return 0 on success, negative on failure.
00968  */
00969 extern int8_t arm_network_own_certificates_remove(void);
00970 
00971 /**
00972  * Add Certificate Revocation List
00973  *
00974  * This is used to add Certificate Revocation List (CRL). Function can be called several
00975  * times to add more than one Certificate Revocation List.
00976  *
00977  * \param crl Certificate revocation list
00978  * \return 0 on success, negative on failure.
00979  */
00980 extern int8_t arm_network_certificate_revocation_list_add(const arm_cert_revocation_list_entry_s *crl);
00981 
00982 /**
00983  * Remove Certificate Revocation List
00984  *
00985  * This is used to remove Certificate Revocation List.
00986  *
00987  * \param crl Certificate revocation list
00988  * \return 0 on success, negative on failure.
00989  */
00990 extern int8_t arm_network_certificate_revocation_list_remove(const arm_cert_revocation_list_entry_s *crl);
00991 
00992 /**
00993  * \brief Add PSK key to TLS library.
00994  *
00995  * \param key_ptr A pointer to 16 bytes long key array.
00996  * \param key_id PSK key ID.
00997  *
00998  * \return 0 = success
00999  * \return -1 = failure
01000  */
01001 extern int8_t arm_tls_add_psk_key(const uint8_t *key_ptr, uint16_t key_id);
01002 
01003 /**
01004  * \brief Remove PSK key from TLS library.
01005  *
01006  * \param key_id PSK key ID.
01007  *
01008  * \return 0 = success
01009  * \return -1 = failure
01010  */
01011 extern int8_t arm_tls_remove_psk_key(uint16_t key_id);
01012 
01013 /**
01014  * \brief Check if PSK key ID exists.
01015  *
01016  * \param key_id PSK key ID
01017  *
01018  * \return 0 = success
01019  * \return -1 = failure
01020  */
01021 extern int8_t arm_tls_check_key(uint16_t key_id);
01022 
01023 /**
01024  * \brief Print routing table
01025  *
01026  * Prints the routing table to the command line
01027  */
01028 void arm_print_routing_table(void);
01029 
01030 /**
01031  * \brief Print routing table
01032  *
01033  * Outputs the routing table using the given printf style function
01034  *
01035  * \param print_fn pointer to a printf style output function
01036  */
01037 void arm_print_routing_table2(void (*print_fn)(const char *fmt, ...));
01038 
01039 /**
01040  * \brief Flush neighbor cache
01041  *
01042  * Flushes the neighbor cache
01043  */
01044 void arm_ncache_flush(void);
01045 
01046 /**
01047  * \brief Print neighbor cache
01048  *
01049  * Prints neighbor cache to the command line
01050  */
01051 void arm_print_neigh_cache(void);
01052 
01053 /**
01054  * \brief Print neighbor cache
01055  *
01056  * Outputs the neighbor cache using the given printf style function
01057  *
01058  * \param print_fn pointer to a printf style output function
01059  */
01060 void arm_print_neigh_cache2(void (*print_fn)(const char *fmt, ...));
01061 
01062 /**
01063  * \brief Print PCB list
01064  *
01065  * Prints Protocol Control Block list to the command line
01066  */
01067 void arm_print_protocols(void);
01068 
01069 /**
01070  * \brief Print PCB list
01071  *
01072  * Prints Protocol Control Block list using the given printf style function
01073  *
01074  * \param print_fn pointer to a printf style output function
01075  * \param sep column separator character
01076  */
01077 void arm_print_protocols2(void (*print_fn)(const char *fmt, ...), char sep);
01078 
01079 /**
01080   * \brief Get the library version information.
01081   *
01082   * \param *ptr Pointer to data location. Required size is 20 bytes.
01083   *
01084   *
01085   * The array containing the version information has the following structure.
01086   *
01087   *  | Platform type | Version | Build ID |
01088   *  | :-----------: | :----------------: |
01089   *  | 1 byte        |  1 byte | 4 bytes  |
01090   *
01091   */
01092 extern void net_get_version_information(uint8_t *ptr);
01093 
01094 /**
01095  * \brief Set buffer size for sleepy device parent.
01096  *
01097  * This function can be used to set sleepy device parent buffer size and packet threshold.
01098  *
01099  * Note! In Thread mode parent buffer size is automatically set during Thread initialization.
01100  *
01101  * \param interface_id Network interface ID.
01102  * \param big_packet_threshold Indicate how long packets are considered big. For Thread, must be 106 bytes.
01103  * \param small_packets_per_child_count Number of small packets stored for each sleepy children. For Thread, must be at least 1.
01104  * \param big_packets_total_count Total number of big packets parent can store for all sleepy children. For Thread, must be at least 1.
01105  * \return 0 on success, <0 on errors.
01106  */
01107 
01108 extern int arm_nwk_sleepy_device_parent_buffer_size_set(int8_t interface_id, uint16_t big_packet_threshold, uint16_t small_packets_per_child_count, uint16_t big_packets_total_count);
01109 
01110 /**
01111  * \brief Set CCA threshold.
01112  *
01113  * This function can be used to set CCA threshold to PHY layer. Threshold is given as percentage of maximum threshold.
01114  * 0 is the lowest(strictest) possible threshold and 100 is the highest possible threshold.
01115  *
01116  * Note! Software MAC must be created and registered before using this function.
01117  *
01118  * \param interface_id Network interface ID.
01119  * \param cca_threshold CCA threshold (%).
01120  * \return 0 on success, <0 on errors.
01121  */
01122 extern int8_t arm_nwk_set_cca_threshold(int8_t interface_id, uint8_t cca_threshold);
01123 
01124 /**
01125  * \brief Set TX output power.
01126  *
01127  * This function can be used to set TX output power to PHY layer. TX power is given as percentage of maximum output power.
01128  * 0 is the lowest possible TX power and 100 is the highest possible TX power.
01129  *
01130  * Note! Software MAC must be created and registered before using this function.
01131  *
01132  * \param interface_id Network interface ID.
01133  * \param tx_power TX output power (%).
01134  * \return 0 on success, <0 on errors.
01135  */
01136 extern int8_t arm_nwk_set_tx_output_power(int8_t interface_id, uint8_t tx_power);
01137 
01138 
01139 #ifdef __cplusplus
01140 }
01141 #endif
01142 #endif /* NET_INTERFACE_H_ */