Morse Micro IoT SDK  2.10.4
mmipal.h
1/*
2 * Copyright 2023 Morse Micro
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
16#pragma once
17
18#ifdef __cplusplus
19extern "C"
20{
21#endif
22
23#include <stdbool.h>
24#include <stdint.h>
25
27#ifndef MMIPAL_IPADDR_STR_MAXLEN
28#define MMIPAL_IPADDR_STR_MAXLEN (48)
29#endif
30
32#ifndef MMIPAL_MAX_IPV6_ADDRESSES
33#define MMIPAL_MAX_IPV6_ADDRESSES (3)
34#endif
35
37#ifndef MMIPAL_MACADDR_LEN
38#define MMIPAL_MACADDR_LEN (6)
39#endif
40
43{
54};
55
58{
63};
64
67{
78};
79
82
85
97{
106};
107
109#define MMIPAL_IP_CONFIG_DEFAULT \
110 { \
111 MMIPAL_DHCP, \
112 "", \
113 "", \
114 "", \
115 }
116
119{
130};
131
143{
148};
149
151#define MMIPAL_IP6_CONFIG_DEFAULT { MMIPAL_IP6_AUTOCONFIG }
152
157{
162};
163
175{
184
193};
194
199#define MMIPAL_INIT_ARGS_DEFAULT \
200 { MMIPAL_DHCP, { 0 }, { 0 }, { 0 }, MMIPAL_IP6_DISABLED, { 0 }, false, 0 }
201
218
223{
232};
233
239typedef void (*mmipal_link_status_cb_fn_t)(const struct mmipal_link_status *link_status);
240
253
263typedef void (*mmipal_ext_link_status_cb_fn_t)(const struct mmipal_link_status *link_status,
264 void *arg);
265
279
289void mmipal_get_link_packet_counts(uint32_t *tx_packets, uint32_t *rx_packets);
290
296void mmipal_set_tx_qos_tid(uint8_t tid);
297
321 const mmipal_ip_addr_t dest_addr);
322
333
344
353
364
375
386
396
403
416
427
428#ifdef __cplusplus
429}
430#endif
431
enum mmipal_status mmipal_init(const struct mmipal_init_args *args)
Initialize the IP stack and enable the MMWLAN interface.
enum mmipal_status mmipal_get_ip_broadcast_addr(mmipal_ip_addr_t broadcast_addr)
Gets the current IPv4 broadcast address.
void(* mmipal_ext_link_status_cb_fn_t)(const struct mmipal_link_status *link_status, void *arg)
Prototype for callback function invoked on link status changes.
Definition: mmipal.h:263
void mmipal_set_tx_qos_tid(uint8_t tid)
Set the QoS Traffic ID to use when transmitting.
void mmipal_get_link_packet_counts(uint32_t *tx_packets, uint32_t *rx_packets)
Get the total number of transmitted and received packets on the MMWLAN interface.
enum mmipal_status mmipal_get_dns_server(uint8_t index, mmipal_ip_addr_t addr)
Get the DNS server at the given index.
enum mmipal_status mmipal_set_ip_config(const struct mmipal_ip_config *config)
Set the IP configurations.
#define MMIPAL_MACADDR_LEN
Length of a MAC address.
Definition: mmipal.h:38
enum mmipal_status mmipal_set_dns_server(uint8_t index, const mmipal_ip_addr_t addr)
Set the DNS server at the given index.
void(* mmipal_link_status_cb_fn_t)(const struct mmipal_link_status *link_status)
Prototype for callback function invoked on link status changes.
Definition: mmipal.h:239
uint8_t mmipal_mac_addr_t[MMIPAL_MACADDR_LEN]
MAC address string type.
Definition: mmipal.h:84
enum mmipal_status mmipal_add_static_arp_entry(const struct mmipal_arp_config *config)
Add a static ARP entry.
mmipal_link_state
Enumeration of link states.
Definition: mmipal.h:58
enum mmipal_link_state mmipal_get_link_state(void)
Get current IPv4 link state.
mmipal_ip6_addr_mode
Enumeration of IPv6 address allocation modes.
Definition: mmipal.h:119
void mmipal_set_link_status_callback(mmipal_link_status_cb_fn_t fn)
Sets the callback function to be invoked on link status changes.
enum mmipal_status mmipal_remove_static_arp_entry(const struct mmipal_arp_config *config)
Remove a static ARP entry.
void mmipal_set_ext_link_status_callback(mmipal_ext_link_status_cb_fn_t fn, void *arg)
Sets the extended link status callback function to be invoked on link status changes.
enum mmipal_status mmipal_get_ip6_config(struct mmipal_ip6_config *config)
Get the IP configurations.
mmipal_status
Enumeration of status codes returned by MMIPAL functions.
Definition: mmipal.h:43
char mmipal_ip_addr_t[MMIPAL_IPADDR_STR_MAXLEN]
IP address string type.
Definition: mmipal.h:81
#define MMIPAL_MAX_IPV6_ADDRESSES
Maximum number of IPv6 addresses supported.
Definition: mmipal.h:33
enum mmipal_status mmipal_set_ip6_config(const struct mmipal_ip6_config *config)
Set the IPv6 configurations.
enum mmipal_status mmipal_get_ip_config(struct mmipal_ip_config *config)
Get the IP configurations.
#define MMIPAL_IPADDR_STR_MAXLEN
Maximum length of an IP address string, including null-terminator.
Definition: mmipal.h:28
mmipal_addr_mode
Enumeration of IP address allocation modes.
Definition: mmipal.h:67
enum mmipal_status mmipal_get_local_addr(mmipal_ip_addr_t local_addr, const mmipal_ip_addr_t dest_addr)
Gets the local address for the MMWLAN interface that is appropriate for a given destination address.
@ MMIPAL_LINK_UP
Link is up.
Definition: mmipal.h:62
@ MMIPAL_LINK_DOWN
Link is down.
Definition: mmipal.h:60
@ MMIPAL_IP6_AUTOCONFIG
IPv6 address allocated via autoconfiguration.
Definition: mmipal.h:126
@ MMIPAL_IP6_DISABLED
Disabled.
Definition: mmipal.h:121
@ MMIPAL_IP6_STATIC
Static IPv6 addresses.
Definition: mmipal.h:123
@ MMIPAL_IP6_DHCP6_STATELESS
IPv6 address allocated via stateless DHCPv6.
Definition: mmipal.h:129
@ MMIPAL_INVALID_ARGUMENT
One or more arguments were invalid.
Definition: mmipal.h:47
@ MMIPAL_SUCCESS
Completed successfully.
Definition: mmipal.h:45
@ MMIPAL_NOT_SUPPORTED
This functionality is not supported (e.g., due to build configuration).
Definition: mmipal.h:53
@ MMIPAL_NO_MEM
Failed due to memory allocation failure.
Definition: mmipal.h:51
@ MMIPAL_NO_LINK
The operation could not complete because the link is not up.
Definition: mmipal.h:49
@ MMIPAL_AUTOIP
IP address allocated via AutoIP.
Definition: mmipal.h:75
@ MMIPAL_DISABLED
Disabled.
Definition: mmipal.h:69
@ MMIPAL_DHCP
IP address allocated via DHCP.
Definition: mmipal.h:73
@ MMIPAL_DHCP_OFFLOAD
DHCP offloaded to chip.
Definition: mmipal.h:77
@ MMIPAL_STATIC
Static IP address.
Definition: mmipal.h:71
ARP configuration structure.
Definition: mmipal.h:157
mmipal_ip_addr_t ip_addr
IP address.
Definition: mmipal.h:159
mmipal_mac_addr_t mac_addr
MAC address.
Definition: mmipal.h:161
Initialize arguments structure.
Definition: mmipal.h:175
enum mmipal_ip6_addr_mode ip6_mode
IPv6 address allocation mode to use.
Definition: mmipal.h:186
uint32_t offload_arp_refresh_s
ARP refresh offload interval in seconds.
Definition: mmipal.h:192
mmipal_ip_addr_t ip6_addr
IPv6 address to use (if ip6_mode is MMIPAL_IP6_STATIC).
Definition: mmipal.h:188
bool offload_arp_response
Flag requesting ARP response offload feature.
Definition: mmipal.h:190
mmipal_ip_addr_t gateway_addr
Gateway IP address to use (if mode is MMIPAL_STATIC).
Definition: mmipal.h:183
enum mmipal_addr_mode mode
IP address allocation mode to use.
Definition: mmipal.h:177
mmipal_ip_addr_t netmask
Netmask to use (if mode is MMIPAL_STATIC).
Definition: mmipal.h:181
mmipal_ip_addr_t ip_addr
IP address to use (if mode is MMIPAL_STATIC).
Definition: mmipal.h:179
IPv6 configuration structure.
Definition: mmipal.h:143
enum mmipal_ip6_addr_mode ip6_mode
IPv6 addresses allocation mode.
Definition: mmipal.h:145
mmipal_ip_addr_t ip6_addr[MMIPAL_MAX_IPV6_ADDRESSES]
Array of IPv6 addresses.
Definition: mmipal.h:147
IPv4 configuration structure.
Definition: mmipal.h:97
enum mmipal_addr_mode mode
IP address allocation mode.
Definition: mmipal.h:99
mmipal_ip_addr_t gateway_addr
Gateway address.
Definition: mmipal.h:105
mmipal_ip_addr_t ip_addr
local IP address
Definition: mmipal.h:101
mmipal_ip_addr_t netmask
Netmask address.
Definition: mmipal.h:103