Skip to content

File syn_netcfg.h

FileList > net > syn_netcfg.h

Go to the source code of this file

Unified Zero-Heap Network IP Address Manager. More...

  • #include "syntropic/common/syn_defs.h"
  • #include "syntropic/net/syn_autoip.h"
  • #include "syntropic/net/syn_dhcp.h"
  • #include "syntropic/net/syn_eth.h"
  • #include "syntropic/pt/syn_pt.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_NETCFG

Public Types

Type Name
typedef void(* SYN_NETCFG_LinkCb
enum SYN_NETCFG_LinkState
enum SYN_NETCFG_Mode

Public Functions

Type Name
SYN_Status syn_netcfg_init (SYN_NETCFG * netcfg, SYN_NETCFG_Mode mode, const uint8_t mac)
Initialize Unified Network IP Manager.
SYN_Status syn_netcfg_set_link_callback (SYN_NETCFG * netcfg, SYN_NETCFG_LinkCb cb, void * user_data)
Register Application Link Event Callback.
SYN_Status syn_netcfg_set_link_state (SYN_NETCFG * netcfg, SYN_ETH * eth, SYN_NETCFG_LinkState state)
Notify Network Manager of Physical Link State Change (Link Up / Link Down).
SYN_Status syn_netcfg_set_static (SYN_NETCFG * netcfg, SYN_ETH * eth, uint32_t ip, uint32_t netmask, uint32_t gateway)
Set Static IP configuration parameters.
SYN_Status syn_netcfg_trigger_autoip_fallback (SYN_NETCFG * netcfg, SYN_ETH * eth, const uint8_t mac)
Trigger AutoIP fallback when DHCP times out.

Macros

Type Name
define PT_NETCFG_BLOCK_BOUND (pt, task, netcfg) [**PT\_BLOCK\_CONDITION**](syn__pt_8h.md#define-pt_block_condition)(pt, task, (netcfg)-&gt;is\_bound == true)
Block task execution (SYN_TASK_BLOCKED) until IP configuration binding completes.
define PT_NETCFG_BLOCK_LINK_UP (pt, task, netcfg) [**PT\_BLOCK\_CONDITION**](syn__pt_8h.md#define-pt_block_condition)(pt, task, (netcfg)-&gt;link\_state == SYN\_NETCFG\_LINK\_UP)
Block task execution (SYN_TASK_BLOCKED) until physical link is UP.
define PT_NETCFG_WAIT_BOUND (pt, netcfg) [**PT\_WAIT\_UNTIL**](syn__pt_8h.md#define-pt_wait_until)(pt, (netcfg)-&gt;is\_bound == true)
Block a protothread coroutine until IP configuration binding completes.
define PT_NETCFG_WAIT_LINK_UP (pt, netcfg) [**PT\_WAIT\_UNTIL**](syn__pt_8h.md#define-pt_wait_until)(pt, (netcfg)-&gt;link\_state == SYN\_NETCFG\_LINK\_UP)
Block a protothread coroutine until physical link is UP.

Detailed Description

Unifies Static IP, DHCP Client, RFC 3927 AutoIP fallback, and Physical Link Event handling.

Public Types Documentation

typedef SYN_NETCFG_LinkCb

typedef void(* SYN_NETCFG_LinkCb) (struct SYN_NETCFG_s *netcfg, SYN_NETCFG_LinkState state, void *user_data);

Application Link Event Callback Signature.


enum SYN_NETCFG_LinkState

enum SYN_NETCFG_LinkState {
    SYN_NETCFG_LINK_DOWN = 0,
    SYN_NETCFG_LINK_UP
};

Physical Link States.


enum SYN_NETCFG_Mode

enum SYN_NETCFG_Mode {
    SYN_NETCFG_MODE_STATIC = 0,
    SYN_NETCFG_MODE_DHCP,
    SYN_NETCFG_MODE_AUTO
};

IP Manager Modes.


Public Functions Documentation

function syn_netcfg_init

Initialize Unified Network IP Manager.

SYN_Status syn_netcfg_init (
    SYN_NETCFG * netcfg,
    SYN_NETCFG_Mode mode,
    const uint8_t mac
) 

Parameters:

  • netcfg Pointer to Netcfg context.
  • mode Configuration mode (STATIC, DHCP, or AUTO).
  • mac 6-byte client MAC address.

Returns:

SYN_OK on success.


Register Application Link Event Callback.

SYN_Status syn_netcfg_set_link_callback (
    SYN_NETCFG * netcfg,
    SYN_NETCFG_LinkCb cb,
    void * user_data
) 

Parameters:

  • netcfg Pointer to Netcfg context.
  • cb Callback function pointer.
  • user_data User data context passed to callback.

Returns:

SYN_OK on success.


Notify Network Manager of Physical Link State Change (Link Up / Link Down).

SYN_Status syn_netcfg_set_link_state (
    SYN_NETCFG * netcfg,
    SYN_ETH * eth,
    SYN_NETCFG_LinkState state
) 

On LINK_DOWN: Invalidates IP binding, resets state machines back to INIT, and triggers callback. On LINK_UP: Automatically re-triggers IP acquisition state machine and triggers callback.

Parameters:

  • netcfg Pointer to Netcfg context.
  • eth Pointer to Ethernet context.
  • state Physical Link State (SYN_NETCFG_LINK_DOWN or SYN_NETCFG_LINK_UP).

Returns:

SYN_OK on success.


function syn_netcfg_set_static

Set Static IP configuration parameters.

SYN_Status syn_netcfg_set_static (
    SYN_NETCFG * netcfg,
    SYN_ETH * eth,
    uint32_t ip,
    uint32_t netmask,
    uint32_t gateway
) 

Parameters:

  • netcfg Pointer to Netcfg context.
  • eth Pointer to Ethernet context.
  • ip 32-bit IPv4 address.
  • netmask 32-bit netmask.
  • gateway 32-bit router gateway IP.

Returns:

SYN_OK on success.


function syn_netcfg_trigger_autoip_fallback

Trigger AutoIP fallback when DHCP times out.

SYN_Status syn_netcfg_trigger_autoip_fallback (
    SYN_NETCFG * netcfg,
    SYN_ETH * eth,
    const uint8_t mac
) 

Parameters:

  • netcfg Pointer to Netcfg context.
  • eth Pointer to Ethernet context.
  • mac 6-byte client MAC address.

Returns:

SYN_OK on success.


Macro Definition Documentation

define PT_NETCFG_BLOCK_BOUND

Block task execution (SYN_TASK_BLOCKED) until IP configuration binding completes.

#define PT_NETCFG_BLOCK_BOUND (
    pt,
    task,
    netcfg
) `PT_BLOCK_CONDITION (pt, task, (netcfg)->is_bound == true)`


Block task execution (SYN_TASK_BLOCKED) until physical link is UP.

#define PT_NETCFG_BLOCK_LINK_UP (
    pt,
    task,
    netcfg
) `PT_BLOCK_CONDITION (pt, task, (netcfg)->link_state == SYN_NETCFG_LINK_UP)`


define PT_NETCFG_WAIT_BOUND

Block a protothread coroutine until IP configuration binding completes.

#define PT_NETCFG_WAIT_BOUND (
    pt,
    netcfg
) `PT_WAIT_UNTIL (pt, (netcfg)->is_bound == true)`

Parameters:

  • pt Protothread context.
  • netcfg Pointer to Netcfg context.

Block a protothread coroutine until physical link is UP.

#define PT_NETCFG_WAIT_LINK_UP (
    pt,
    netcfg
) `PT_WAIT_UNTIL (pt, (netcfg)->link_state == SYN_NETCFG_LINK_UP)`

Parameters:

  • pt Protothread context.
  • netcfg Pointer to Netcfg context.


The documentation for this class was generated from the following file src/syntropic/net/syn_netcfg.h