Network Component  Version 7.19.0
MDK Middleware for IPv4 and IPv6 Networking

Functions of the PPP interface. More...

Functions

netStatus netPPP_Listen (const char *username, const char *password)
 Start PPP interface to accept incoming PPP connection. [thread-safe]. More...
 
netStatus netPPP_Connect (const char *dial_num, const char *username, const char *password)
 Start a dial-up connection to remote PPP server. [thread-safe]. More...
 
netStatus netPPP_Close (void)
 Disconnect PPP link between two modems. [thread-safe]. More...
 
bool netPPP_LinkUp (void)
 Determine the state of PPP link. [thread-safe]. More...
 

Description

Functions of the PPP interface.

To start a dial-up connection to a remote PPP server, use netPPP_Connect (client mode). If you want to wait for an incoming connection, use netPPP_Listen instead (server mode). To check the link status, use netPPP_LinkUp. This can be done in client and server mode and can be used to continuously monitor the PPP link. To disconnect the PPP link, use netPPP_Close (for client and server mode). Usually, this is done by the client. Note that the netPPP_Close function does not change the running mode of the PPP daemon. If the PPP daemon was in server mode, PPP daemon re-initializes the modem driver to accept further incoming calls.

Function Documentation

◆ netPPP_Close()

netStatus netPPP_Close ( void  )

Disconnect PPP link between two modems. [thread-safe].

Returns
status code that indicates the execution status of the function.

The function netPPP_Close disconnects the PPP link between two modems.

Possible netStatus return values:

  • netOK: Disconnection started.
Note
  • You can call the netPPP_Close function when the PPP network daemon is either in client mode or in server mode.
  • Because the PPP client starts a dial-up connection, it is also the PPP client that usually disconnects the PPP link.
  • The netPPP_Close function does not change the running mode of the PPP daemon. If the PPP daemon was in server mode, PPP daemon re-initializes the modem driver to accept further incoming calls.

Code Example

void disconnect_link (void) {
// Disconnect a dial-up link.
}

◆ netPPP_Connect()

netStatus netPPP_Connect ( const char *  dial_num,
const char *  username,
const char *  password 
)

Start a dial-up connection to remote PPP server. [thread-safe].

Parameters
[in]dial_numphone number of remote PPP server.
[in]usernameusername for authentication.
[in]passwordpassword for authentication.
Returns
status code that indicates the execution status of the function.

The function netPPP_Connect starts a dial-up connection to the remote PPP server by starting the PPP daemon in client mode.

The argument dial_num points to a null-terminated string containing the phone number of the remote PPP server.

The argument username points to the user name.

The argument password points to the password.

The Network Core authenticates the user credentials using the Password Authentication Protocol (PAP) or Challenge-Handshake Authentication Protocol (CHAP). Both arguments are null-terminated strings.

Possible netStatus return values:

  • netOK: Dial-up connection started.
  • netInvalidParameter: Invalid parameter provided.
  • netWrongState: Dial-up connection already established.
Note
  • You must call the netPPP_Connect function if you want to establish a dial-up connection using PPP.
  • When using a direct cable connection, dial_num can be set to NULL, because the Null_Modem device driver ignores dial_num.

Code Example

void dial_remote (void) {
// Dial remote PPP Server.
netPPP_Connect ("04213372", "Keil", "test");
}

◆ netPPP_LinkUp()

bool netPPP_LinkUp ( void  )

Determine the state of PPP link. [thread-safe].

Returns
link state:
  • true = Link is up, IP frames can be exchanged.
  • false = Link is down.

The function netPPP_LinkUp determines the state of PPP link between the two modems. It returns true if the PPP link state is network and IP frames can be exchanged.

Note
  • You can call the netPPP_LinkUp function when the PPP network daemon is either in client mode or in server mode.
  • You can also use the netPPP_LinkUp function to continuously monitor the PPP link.

Code Example

void connect_soc (void) {
// Connect TCP socket when PPP is up.
if(netPPP_LinkUp()) {
netTCP_Connect (socket_tcp, remip, 1000, 0);
}
}

◆ netPPP_Listen()

netStatus netPPP_Listen ( const char *  username,
const char *  password 
)

Start PPP interface to accept incoming PPP connection. [thread-safe].

Parameters
[in]usernameremote username for authentication.
[in]passwordremote password for authentication.
Returns
status code that indicates the execution status of the function.

The function netPPP_Listen configures the PPP interface to accept incoming PPP connections by starting the PPP daemon in server mode.

The argument username points to the user name.

The argument password points to the password.

The Network Core authenticates the user credentials using the Password Authentication Protocol (PAP). Both arguments are null-terminated strings.

Possible netStatus return values:

  • netOK: Listening to inbound dial-up connections started.
  • netInvalidParameter: Invalid parameter provided.
  • netWrongState: Dial-up connection already established.
Note
It is common to call the netPPP_Listen function at system start-up.

Code Example

int main (void) {
// Initialize the Network Core
// Activate the PPP interface.
netPPP_Listen ("Keil", "test");
..
}