Morse Micro IoT SDK  2.13.1
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
26#include "mmutils.h"
27
29#ifndef MMIPAL_IPADDR_STR_MAXLEN
30#define MMIPAL_IPADDR_STR_MAXLEN (48)
31#endif
32
34#ifndef MMIPAL_MAX_IPV6_ADDRESSES
35#define MMIPAL_MAX_IPV6_ADDRESSES (3)
36#endif
37
39#ifndef MMIPAL_MACADDR_LEN
40#define MMIPAL_MACADDR_LEN (6)
41#endif
42
45{
56};
57
60{
65};
66
69{
78};
79
82
85
97{
108};
109
111#define MMIPAL_IP_CONFIG_DEFAULT \
112 { \
113 MMIPAL_DHCP, "", "", "", "", \
114 }
115
118{
129};
130
142{
147};
148
150#define MMIPAL_IP6_CONFIG_DEFAULT { MMIPAL_IP6_AUTOCONFIG }
151
156{
161};
162
174{
185
190};
191
196#define MMIPAL_INIT_ARGS_DEFAULT \
197 { MMIPAL_DHCP, { 0 }, { 0 }, { 0 }, { 0 }, MMIPAL_IP6_DISABLED, { 0 } }
198
215
220{
229};
230
236typedef void (*mmipal_link_status_cb_fn_t)(const struct mmipal_link_status *link_status);
237
250
260typedef void (*mmipal_ext_link_status_cb_fn_t)(const struct mmipal_link_status *link_status,
261 void *arg);
262
276
286void mmipal_get_link_packet_counts(uint32_t *tx_packets, uint32_t *rx_packets);
287
293void mmipal_set_tx_qos_tid(uint8_t tid);
294
318 const mmipal_ip_addr_t dest_addr);
319
330
341
350
361
372
383
393
400
413
424
425#ifdef __cplusplus
426}
427#endif
428
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:260
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:40
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:236
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:60
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:118
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:45
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:35
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:30
mmipal_addr_mode
Enumeration of IP address allocation modes.
Definition: mmipal.h:69
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:64
@ MMIPAL_LINK_DOWN
Link is down.
Definition: mmipal.h:62
@ MMIPAL_IP6_AUTOCONFIG
IPv6 address allocated via autoconfiguration.
Definition: mmipal.h:125
@ MMIPAL_IP6_DISABLED
Disabled.
Definition: mmipal.h:120
@ MMIPAL_IP6_STATIC
Static IPv6 addresses.
Definition: mmipal.h:122
@ MMIPAL_IP6_DHCP6_STATELESS
IPv6 address allocated via stateless DHCPv6.
Definition: mmipal.h:128
@ MMIPAL_INVALID_ARGUMENT
One or more arguments were invalid.
Definition: mmipal.h:49
@ MMIPAL_SUCCESS
Completed successfully.
Definition: mmipal.h:47
@ MMIPAL_NOT_SUPPORTED
This functionality is not supported (e.g., due to build configuration).
Definition: mmipal.h:55
@ MMIPAL_NO_MEM
Failed due to memory allocation failure.
Definition: mmipal.h:53
@ MMIPAL_NO_LINK
The operation could not complete because the link is not up.
Definition: mmipal.h:51
@ MMIPAL_AUTOIP
IP address allocated via AutoIP.
Definition: mmipal.h:77
@ MMIPAL_DISABLED
Disabled.
Definition: mmipal.h:71
@ MMIPAL_DHCP
IP address allocated via DHCP.
Definition: mmipal.h:75
@ MMIPAL_STATIC
Static IP address.
Definition: mmipal.h:73
#define MM_HOSTNAME_MAX_LEN
Maximum length of a hostname string, including null-terminator.
Definition: mmutils.h:434
ARP configuration structure.
Definition: mmipal.h:156
mmipal_ip_addr_t ip_addr
IP address.
Definition: mmipal.h:158
mmipal_mac_addr_t mac_addr
MAC address.
Definition: mmipal.h:160
Initialize arguments structure.
Definition: mmipal.h:174
enum mmipal_ip6_addr_mode ip6_mode
IPv6 address allocation mode to use.
Definition: mmipal.h:187
mmipal_ip_addr_t ip6_addr
IPv6 address to use (if ip6_mode is MMIPAL_IP6_STATIC).
Definition: mmipal.h:189
char hostname[MM_HOSTNAME_MAX_LEN]
Interface hostname.
Definition: mmipal.h:184
mmipal_ip_addr_t gateway_addr
Gateway IP address to use (if mode is MMIPAL_STATIC).
Definition: mmipal.h:182
enum mmipal_addr_mode mode
IP address allocation mode to use.
Definition: mmipal.h:176
mmipal_ip_addr_t netmask
Netmask to use (if mode is MMIPAL_STATIC).
Definition: mmipal.h:180
mmipal_ip_addr_t ip_addr
IP address to use (if mode is MMIPAL_STATIC).
Definition: mmipal.h:178
IPv6 configuration structure.
Definition: mmipal.h:142
enum mmipal_ip6_addr_mode ip6_mode
IPv6 addresses allocation mode.
Definition: mmipal.h:144
mmipal_ip_addr_t ip6_addr[MMIPAL_MAX_IPV6_ADDRESSES]
Array of IPv6 addresses.
Definition: mmipal.h:146
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
char hostname[MM_HOSTNAME_MAX_LEN]
Interface hostname.
Definition: mmipal.h:107
mmipal_ip_addr_t netmask
Netmask address.
Definition: mmipal.h:103