X.25 Call Setup

Encode Clear Request


Encode cause and diagnostic codes, address, facilities and user data into a clear request packet.

#include "call.h"

LResult call_EncodeClearRequest
        CallClearData     data,
        CallBuffer        buffer,
        CallBufferSize    size
datainput for data to encode
bufferoutput buffer for clear request packet
sizesize of buffer in bytes

call_EncodeClearRequest() encodes a C language representation of cause and diagnostic codes, address, facilities and user data into a clear request packet. The example code given below shows how to set up the data structures passed to call_EncodeClearRequest(). Facilities and user data are optional, but if either is used, the address field is required.

Return Values

If successful, call_EncodeClearRequest() returns a non-negative value indicating the number of bytes of encoded data. Otherwise, it returns a negative value. Failure to encode indicates that the input parameters are invalid.

See Also


CallClearDataStruct    callClearData;
CallSetupDataStruct    callSetupData;
AddressBlock           addressBlock;
char                   packet[128];
LResult                result;

/* Set up clear data block */
callClearData.cause         = cause_CLEAR_INVALID_FACILITY_REQUEST;
callClearData.diag          = dg_FACILITY_CODE_NOT_ALLOWED;
callClearData.callSetupData = &callSetupData;

/* Set up call setup data block */
callSetupData.address       = &addressBlock;
callSetupData.facilities    = NULL;
callSetupData.userData      = NULL;
callSetupData.userDataCount = 0;

/* Set up address information */
addressBlock.format = call_STANDARD_ADDRESS_FORMAT;
strcpy(addressBlock.dte.std.calledDTE,  calledDte);
strcpy(addressBlock.dte.std.callingDTE, callingDte);

result = call_EncodeClearRequest(&callClearData, packet, (uint) sizeof(packet));

if (result < 0)
    /* Error encoding */
    lgo_ConnectReject(cid, packet, result);