tfPppSendEchoRequest

Jump to: navigation, search

Table of Contents >> Optional Protocols >> PPP Interface


#include <trsocket.h>


int tfPppSendEchoRequest (
ttUserInterface interfaceHandle,
ttUser8Bit echoRequestId,
const char * dataPtr,
int dataLen,
ttEchoReplyFuncPtr echoReplyFuncPtr
);


Function Description

This function sends a LCP Echo-Request message, and then later will call the user-defined function (specified by echoReplyFuncPtr) to process received LCP Echo-Reply messages. For each Echo-Request message sent, there should be one Echo-Reply message received containing the same data that was in the Echo-Request (possibly truncated, depending on what was negotiated for TM_LCP_MAX_RECV_UNIT). If you do not want to process received LCP Echo-Reply messages, set echoReplyFuncPtr to TM_PPP_ECHO_REPLY_FUNC_NULL_PTR.

It is important to note that the user is responsible for matching Echo-Request messages with their associated Echo-Reply messages. No attempt is made in this function to keep track of Echo-Request messages that have been sent for later matching them up with received Echo-Reply messages. However, the echoRequestId parameter is provided to assist the user in performing this matching. The correct usage of this parameter is described in RFC 1661 as follows:

On transmission, the Identifier field MUST be changed whenever the
content of the Data field changes, and whenever a valid reply has
been received for a previous request.  For retransmissions, the
Identifier MAY remain unchanged.

On reception, the Identifier field of the Terminate-Request is
copied into the Identifier field of the Terminate-Ack packet.

The user is responsible for incrementing echoRequestId as appropriate to ensure that the above RFC requirements on the use of the Identifier field are met.

Since poor link quality can result in no Echo-Reply message being received after an Echo-Request message was sent, tfPppSendEchoRequest() can be used to implement some level of link quality monitoring. This is especially useful when PPP LQM is not supported by the peer on the link.


The function prototype for the function called to process received LCP Echo-Reply messages (specified by echoReplyFuncPtr) is defined as follows:


int myHandleEchoReply (
ttUserInterface interfaceHandle,
ttUser8Bit echoRequestId,
const char * dataPtr,
int dataLen
);


Parameters

  • interfaceHandle
    The PPP interface to send the Echo-Request message on.
  • echoRequestId
    A unique ID for the Echo-Request message. This can be used to match Echo-Request messages with their associated Echo-Reply messages.
  • dataPtr
    A pointer to the data to send in the Echo-Request message.
  • dataLen
    The length of the data (in bytes) to send in the Echo-Request message.
  • echoReplyFuncPtr
    A function pointer pointing to a user-defined routine that handles a received LCP Echo-Reply message.


Returns

  • TM_ENOERROR
    Success.
  • TM_EINVAL
    Invalid parameter.
  • TM_ENETDOWN
    The PPP interface is not open/connected.
  • TM_EMSGSIZE
    The length of the LCP Echo-Request message exceeds the MRU used on the link.
  • TM_ENOBUFS
    Insufficient memory to complete the operation.


Table of Contents >> Optional Protocols >> PPP Interface