sppConfig()
PROTOTYPE
#include <spp.h>
int sppConfig(SppSpec *spp_spec);
DESCRIPTION
sppConfig() sets the runtime configuration specified by spp_spec, which points to a SppSpec structure. The SppSpec definition is in “spp.h” and reproduced below.
typedef struct
{
uint T1; /* resend timeout (tenths of seconds) */
uint T2_div; /* acknowledgment delay (divisor of T1) */
ui8 flags; /* SPPF_ACTIVE, SPPF_NOWAIT, both, or 0 */
} SppSpec;
These settings behave as follows:
T1: The initial value for the time after which, if no response is received, the protocol assumes a previously transmitted I-frame has been lost or discarded. The T1 value is automatically updated during operation using Karn’s algorithm and set to two standard deviations above the smoothed round-trip time.
T2_div: T2 is the maximum delay after an I-frame is received before an acknowledgment is sent and is equal to T1 / T2_div. Delayed acknowledgments allow a single ACK frame to acknowledge multiple I-frames. It also allows acknowledgments to be ‘piggy-backed’ on I-frames.
flags: Holds up to two flag values, SPPF_ACTIVE and SPPF_NOWAIT, that can be bitwise OR’d to configure the channel.
If SPPF_ACTIVE is set, sppConn() starts periodic transmission of SYN frames, requesting the remote peer to accept a connection. Otherwise, sppConn() silently waits for a SYN frame. Using SPPF_ACTIVE is like calling connect(), instead of listen()/accept(), to establish a TCP connection.
If SPPF_NOWAIT is set, the API is non-blocking. Calls that would otherwise cause the application to block return -1 with errno set to SPP_WOULD_BLOCK. Non-blocking operation requires polling to connect, send and receive frames, etc. TargetSPP may be used in non-blocking mode without the support of a real-time kernel or scheduler.
If the T1 parameter is zero, 3 * SPP_TICKS_PER_SEC is used. If the T1 parameter is less than MIN_RXT, then MIN_RXT (defined as 4) is used. If the T2_div parameter is less than 2, 2 is used. If the resulting T2 value is less than MIN_DELAY, MIN_DELAY (defined as 2) is used. MIN_RXT and MIN_DELAY are defined in “sppp.h”.
If successful, sppConfig() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EFAULT | The spp_spec pointer is NULL. |
| SPP_UNINITIALIZED | The initialization routine sppInit() has not been called. |
EXAMPLE
/*-------------------------------------------------------------------*/
/* Specify the SPP parameters. */
/*-------------------------------------------------------------------*/
spp_spec.T1 = 100; /* resend timeout: # of SPP ticks */
spp_spec.T2_div = 2; /* ack delay timeout: divisor of T1 */
spp_spec.flags = SPPF_ACTIVE;
rc = sppConfig(&spp_spec);
if (rc) error("sppConfig()");