Network Component  Version 6.7.4
MDK-Professional Middleware for IP Networking
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
System Functions (User)

Core system functions to be called by user. More...

Functions

netStatus net_initialize (void)
 Initialize Network Component, resources and interfaces. More...
 
int net_main (void)
 Run Network Component main function. More...
 
netStatus netif_set_default (uint8_t netif)
 Set default network interface used for internet access. More...
 

Description

Core system functions to be called by user.

System Functions represent the core of the protocol stack. They form an operating system that calls all other protocol module functions. The functions require a CMSIS-RTOS compatible RTOS to run and are not reentrant.

The functions are part of the Network Component library and are defined in rl_net.h.

Function Documentation

netStatus net_initialize ( void  )

Initialize Network Component, resources and interfaces.

Returns
status code that indicates the execution status of the function as defined with netStatus.

The function net_initialize initializes the Network Core's system resources, protocols, and applications.

Note
You must call the function at system start-up to properly initialize the networking environment.

Code Example

void main (void) {
init ();
// Initialize the Network Core
while (1) {
// Run main Network Core 'thread'
..
}
}
int net_main ( void  )

Run Network Component main function.

Returns
system status information:
  • 1 = Another call to this function needed.
  • 0 = System is idle.

The function net_main is the main function of the Network Core. It handles:

  • Protocol time-outs
  • ARP address cache
  • Polling of the Ethernet controller for received data.

When net_main receives data from a remote machine, it calls the appropriate protocol functions to process the data. It then passes the resulting data to the user application.

Note
You must call net_main frequently. Otherwise the Network Core fails to run.

Code Example

void main (void) {
init ();
// Initialize the Network Core
while (1) {
// Run main Network Core 'thread'
..
}
}
netStatus netif_set_default ( uint8_t  netif)

Set default network interface used for internet access.

Parameters
[in]netifNetwork interface number:
  • NETIF_ETH = Ethernet interface.
  • NETIF_PPP = PPP interface.
  • NETIF_SLIP = SLIP interface.
Returns
status code that indicates the execution status of the function as defined with netStatus.

The function netif_set_default sets the default network interface, which is used for internet connectivity. It can be used when multiple network interfaces are active simultaneously, for example ethernet and PPP interface.

The argument netif specifies the default network interface as shown in the following table:

netif Description
NETIF_ETH Ethernet network interface
NETIF_PPP PPP network interface using serial connection over UART
NETIF_SLIP SLIP network interface using serial connection over UART

Code Example

void dial_remote (void) {
// Use PPP interface for internet access.
ppp_connect ("04213372", "Keil", "test");
}