Network Component  Version 6.6
MDK-Professional Middleware for IP Networking
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Point-to-Point Protocol (PPP)

PPP routines enable IP communication over a direct connection between two networking nodes. More...

Functions

netStatus ppp_listen (const char *username, const char *password)
 Start PPP interface to accept incoming PPP connection.
 
netStatus ppp_connect (const char *dial_num, const char *username, const char *password)
 Start a dial-up connection to remote PPP server.
 
netStatus ppp_close (void)
 Disconnect PPP link between two modems.
 
bool ppp_is_up (void)
 Determine the state of PPP link.
 

Description

PPP routines enable IP communication over a direct connection between two networking nodes.

The Point-to-Point Protocol (PPP) is a data link protocol commonly used in establishing a direct connection between two networking nodes and has largely superseded the older Serial Line Internet Protocol (SLIP) and other standards. It can provide connection authentication, transmission encryption, and compression. PPP was designed to work with numerous network layer protocols, including for example Internet Protocol (IP).

PPP is used over many types of physical networks. In the Network Component of the Middleware, a serial connection over UART is the only supported type.

Note
For more information about the configuration please visit the Point-to-Point Protocol (PPP) page.

Function Documentation

netStatus ppp_close ( void  )

Disconnect PPP link between two modems.

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

The function ppp_close disconnects the PPP link between two modems.

Note
  • You can call the ppp_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 ppp_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.
}
netStatus ppp_connect ( const char *  dial_num,
const char *  username,
const char *  password 
)

Start a dial-up connection to remote PPP server.

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 as defined with netStatus.
Note
All parameters are null-terminated strings.

The function ppp_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 ASCII string containing the phone number of the remote PPP server.

The argument username points to the user name, whereas 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 ASCII strings.

Note
  • You must call the ppp_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.
ppp_connect ("04213372", "Keil", "test");
}
bool ppp_is_up ( void  )

Determine the state of PPP link.

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

The function ppp_is_up 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 ppp_is_up function when the PPP network daemon is either in client mode or in server mode.
  • You can also use the ppp_is_up function to continuously monitor the PPP link.

Code Example

void connect_soc (void) {
// Connect TCP socket when PPP is up.
if(ppp_is_up()) {
tcp_connect (socket_tcp, remip, 1000, 0);
}
}
netStatus ppp_listen ( const char *  username,
const char *  password 
)

Start PPP interface to accept incoming PPP connection.

Parameters
[in]usernameremote username for authentication.
[in]passwordremote password for authentication.
Returns
status code that indicates the execution status of the function as defined with netStatus.
Note
Both parameters are null-terminated strings.

The function ppp_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, and 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 ASCII strings.

Note
It is common to call the ppp_listen function at system start-up.

Code Example

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