Synchronous API Reference

| Introduction | Function Summary | Function Reference |

Function Summary

sync_openOpens up a synchronous connection
sync_getconfigGet settings for the link configuration that is currently active
sync_closeCloses a SCALLT
sync_readReceive characters from a synchronous connection
sync_writeSend data over a synchronous link
sync_ioctlSends an ioctl message to the device driver
sync_logmsgLogs message to stdout
sync_setoptsSets global synchronous library options
sync_getoptsGets global synchronous library options
sync_findtagFind a tag in tags list
sync_geterror/sync_geterrnoRetrieve most recent library error number
sync_getsyserrorRetrieve current library system error number
sync_setuservalueSets a user supplied value inside SCALLT *
sync_getuservalueGets a user supplied value inside SCALLT *
sync_setnetentInitializes packetnets file for reading
sync_endnetentEnds packetnets file operations
sync_setfilterSets packetnets network type filter
sync_getnetentRetrieves next syncnetent structure
sync_getnetbynameLook up packetnets entry by name
sync_getnetbynetidLook up packetnets entry by netid
sync_lookinitInitialize selection mechanism
sync_lookaddAdd the SCALLT * to selection list
sync_lookdelsync_lookdel
sync_lookselChecks for readability of SCALLTs
sync_lookcloseClose selection list
sync_lookCheck readability of a single SCALLT *
sync_openstatsOpen statistics request
sync_closestatsCloses statistics request
sync_getstatsObtain statistics
sync_getdevtypeObtain the device name associated with netid
sync_getdevicenameObtain the device name associated with netid
sync_errorPrints error message to console
sync_errorstrCopies error message to provided buffer
sync_getfdReturns file descriptor associated with SCALLT *
sync_getdatafdReturns file descriptor associated with SCALLT *
sync_getdevnameReturn device name associated with SCALLT *
sync_getflagsGet flags currently set for SCALLT *
sync_getnetidReturn Network ID associated with SCALLT *





| Introduction | Function Summary | Function Reference |

Function Reference



sync_open

PrototypesSCALLT *sync_open(int netid, ...)

SCALLT *sync_opentags(int netid, TAGS *tags)

PurposeOpens up a synchronous connection
Description Open up a synchronous connection.
netid must be valid or this call will fail.
If ST_NETNAME is supplied then the netid argument is ignored.
Suppliying the ST_RAWOPEN, TRUE pair will cause no configuration of the link to take place.
The order of deciding on a configuration set to use is as follows:
  • If ST_RAWOPEN is specified as TRUE then no configuration will be done.
  • If ST_CONFIGFILE is specified then that specified configuration file will be read.
  • Otherwise the CONFIG directive in packetnets will be consulted and the corresponding file opened. This is the configuration set via tsgconfig or the web configurator.
  • If either ST_SPEED or ST_FRAMESIZE are set then those will override the values read from the configuration file.
If ST_TRACE is set to TRUE then this link may be traced. If accessing a remote link then the tracing facility on the remote server may be used otherwise the included tsgtrace utility may be used to trace activity on this link (local tracing only available on Unix).
Tags
  • All global tags
  • ST_NETNAME
  • ST_FLAGS
  • ST_RAWOPEN
  • ST_CONFIGFILE
  • ST_SETFM0
  • ST_FRAMESIZE
  • ST_SPEED
  • ST_TRACE
  • ST_REVDATA
  • ST_USEUDP (Experimental)
Parameters
netidnetwork ID to access
tagspointer to TAGS list
Returns
SCALLTSCALLT * on success
NULLon failure
Errors
  • SYE_BADNETID
  • SYE_SYSERR
  • SYE_BADCONFIG
  • SYE_BADPPA
  • SYE_BADSAP
  • SYE_BADPRIM
  • SYE_UNSUPPORTED
  • SYE_OPENFAIL
  • SYE_TCPBADHOST
  • SYE_CANTCONNECT
  • SYE_TIMEOUT
See Also

| Introduction | Function Summary | Function Reference |



sync_getconfig

Prototypesint sync_getconfig(SCALLT *ct, ...)

int sync_getconfigtags(SCALLT *ct, TAGS *tags)

PurposeGet settings for the link configuration that is currently active
Description Read the settings for the active link configuration.
Some or all of the configuration items for a link may not have been specified using tags passed to sync_open(). Rather, the link configuration items may have come from the link defaults. This function allows the application to determine the configuration for a link. It must be called after sync_open(). The application may, for example, use this function to determine the active framesize so that it can pass an appropriate sized buffer to sync_write().
It is a good idea to check the sync_geterror() return value for more information when a -1 is returned.
Tags
  • ST_SPEED
  • ST_FRAMESIZE
Parameters
ctSCALLT * for the synchronous connection
tagspointer to TAGS list
Returns
0on success
-1on failure
Errors
  • SYE_FAILCONFIG
  • SYE_BADSCALLT
See Also

| Introduction | Function Summary | Function Reference |



sync_close

Prototypesvoid sync_close(SCALLT *ct)

PurposeCloses a SCALLT
Description Closes the file descriptor associated with a specific SCALLT *.
Frees all internally allocated memory.
After this call ct should no longer be considered a valid pointer.
Parameters
ctSCALLT *
See Also

| Introduction | Function Summary | Function Reference |



sync_read

Prototypesint sync_read(SCALLT *ct, ...)

int sync_readtags(SCALLT *ct, TAGS *tags)

PurposeReceive characters from a synchronous connection
Description Receive characters from a synchronous connection.
This function returns the number of bytes read.
The function expects a buffer big enough to hold the largest frame. If the frame is larger than the buffer, this buffer is returned full, and the next sync_read will return the next bytes of the frame. This function returns the number of bytes read or -1 if there was an error.
It is a good idea to check the sync_geterror() return value for more information when a -1 is returned. If blocking is set (the default) then this function will attempt to read without error ST_MAXTRIES (default 20) times and will wait 1 second after each failed attempt.
Tags
  • All global tags
  • ST_BUFFER
  • ST_BUFLEN
  • ST_MAXTRIES
  • ST_BLOCK
  • ST_TIMEP
Parameters
ctSCALLT * to receive from
tagspointer to TAGS list
Returns
number of characters readon success
0if nothing could be read with ST_BLOCK 0
-1on failure
Errors
  • SYE_BADSCALLT
  • SYE_BADBUFFER
  • SYE_SYSERR
See Also

| Introduction | Function Summary | Function Reference |



sync_write

Prototypesint sync_write(SCALLT *ct, ...)

int sync_writetags(SCALLT *ct, TAGS *tags)

PurposeSend data over a synchronous link
Description Send data over a synchronous link.
The data appears "as is" except that the driver will prepend a flag character and append a 16 bit CRC to the data. This function returns the number of bytes written or -1 if a failure occurs. In the event of a failure use sync_geterror() to determine the cause. When unable to write data due to flow control, this function will sleep one second after receiving a time-out and then try again for ST_MAXTRIES (default 20) times.
Tags
  • All global tags
  • ST_BUFFER
  • ST_BUFLEN
  • ST_MAXTRIES
  • ST_BLOCK
Parameters
ctSCALLT * to send on
tagspointer to TAGS list
Returns
number of bytes writtenon success
0if nothing could be written given ST_BLOCK=FALSE
-1on failure
Errors
  • SYE_BADSCALLT
  • SYE_BADBUFFER
  • SYE_SYSERR
  • SYE_UNDELIVERED
See Also

| Introduction | Function Summary | Function Reference |



sync_ioctl

Prototypesint sync_ioctl(SCALLT *ct, int cmd, char *buf, int len, int timeout)

PurposeSends an ioctl message to the device driver
Description Sends an ioctl message down the streams stack associated with ct.
Parameters
ctpointer to SCALLT
cmdioctl type
bufioctl buffer
lenlength of buffer
timeouttimeout for ioctl
Returns
0on success
-1on failure
Errors
  • SYE_BADSCALLT
  • SYE_SYSERR

| Introduction | Function Summary | Function Reference |



sync_logmsg

Prototypesvoid sync_logmsg(char *s, ...)

PurposeLogs message to stdout
Description Logs messages to the console (stdout).
Parameters
sprintf style string

| Introduction | Function Summary | Function Reference |



sync_setopts

Prototypesint sync_setoptstags(SCALLT *ct, TAGS *tags)

int sync_setopts(SCALLT *ct, ...)

PurposeSets global synchronous library options
Description Sets global Synchronous library parameters.
Any function using tags arguments will call this function.
Tags
  • All global tags
  • ST_VERBOSE
  • ST_BLOCK
  • ST_OUTERR
  • ST_LOGFILE
  • ST_TIMEOUT
  • ST_SETCRC
  • ST_SETRTS
  • ST_SETDTR
Parameters
ctSCALLT *
tagspointer to TAGS list
Returns
0on success
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_getopts

Prototypesint sync_getoptstags(SCALLT *ct, TAGS *tags)

int sync_getopts(SCALLT *ct, ...)

PurposeGets global synchronous library options
Description Obtains the value of global Synchronous library parameters or parameters associated with a specific connection.
Tags
  • All global tags
  • ST_VERBOSE
  • ST_BLOCK
  • ST_OUTERR
  • ST_LOGFILE
  • ST_TIMEOUT
  • ST_GETDSR
  • ST_GETCTS
  • ST_GETDCD
Parameters
ctSCALLT *
tagspointer to TAGS list
Returns
0on success
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_findtag

Prototypesint sync_findtag(TAGS *tags, unsigned long item)

PurposeFind a tag in tags list
Description Finds the tag item in the tags array pointed to by tags.
Parameters
tagspointer to TAGS list
itemitem to find in tags
Returns
>= 0Index of the item
-1Item not found

| Introduction | Function Summary | Function Reference |



sync_geterror/sync_geterrno

Prototypesint sync_geterror(void)

int sync_geterrno(void)

PurposeRetrieve most recent library error number
Description Retrieves most recent library error code from the library.
If the return value is SYE_SYSERR, a call to sync_getsyserror() will retrieve the system error defined in errno.h.
See Also

| Introduction | Function Summary | Function Reference |



sync_getsyserror

Prototypesint sync_getsyserrno(void)

PurposeRetrieve current library system error number
Description Retrieves current library system error number if sync_geterror() returned SYE_SYSERR.
See Also

| Introduction | Function Summary | Function Reference |



sync_setuservalue

Prototypesvoid sync_setuservalue(SCALLT *ct, unsigned long val)

PurposeSets a user supplied value inside SCALLT *
Description Sets a 32bit value inside SCALLT * which can be retrieved at any later time using sync_getuservalue.
See Also

| Introduction | Function Summary | Function Reference |



sync_getuservalue

Prototypesunsigned long sync_getuservalue(SCALLT *ct)

PurposeGets a user supplied value inside SCALLT *
Description Sets a 32bit value inside SCALLT * which can be retrieved at any later time using sync_getuservalue.
See Also

| Introduction | Function Summary | Function Reference |



sync_setnetent

Prototypesvoid sync_setnetent(void)

PurposeInitializes packetnets file for reading
Description Allocates resources necessary to read the configuration database (packetnets database). This is only required for sync_getnetent(), but not for other sync_getnetby... functions. After sync_getnetent() returns NULL, a call to sync_endnetent() is required to release the resources.
See Also

| Introduction | Function Summary | Function Reference |



sync_endnetent

Prototypesvoid sync_endnetent(void)

PurposeEnds packetnets file operations
Description Ends packetnets file operations.
See Also

| Introduction | Function Summary | Function Reference |



sync_setfilter

Prototypesvoid sync_setfilter(int typemask)

PurposeSets packetnets network type filter
Description Sets a network type filter for all accesses to the packetnets file so that the functions sync_getnetent(), sync_getnetby...() will return only the specified network types. Default type is NETSYNC_TYPE. After using the net functions, it is usually a good idea to reset the filter to defaults.
The typemask is a type of network ie. NETX25_TYPE, NETFREL_TYPE, etc. may be OR'd together or NETALL_TYPE selecting all protocol/card types except disabled network IDs.
If typemask is set to 0 or -1 we reset to the default type (NETSYNC_TYPE).
Parameters
typemasktype of network
See Also

| Introduction | Function Summary | Function Reference |



sync_getnetent

Prototypessyncnetent *sync_getnetent(void)

PurposeRetrieves next syncnetent structure
Description Retrieves next syncnetent entry from the packetnets file.
This function only returns synchronous (NETSYNC_TYPE) entries by default. See sync_setfilter() to change.
Returns
syncnetent *structure containing information about this network
NULLon failure
See Also

| Introduction | Function Summary | Function Reference |



sync_getnetbyname

Prototypessyncnetent *sync_getnetbyname(char *name)

PurposeLook up packetnets entry by name
Description Attempts to look up a network entry given a name.
This function only returns synchronous (NETSYNC_TYPE) entries by default. See sync_setfilter() to change.
Parameters
namename of network in packetnets
Returns
syncnetent *structure containing information about this network
NULLon failure
See Also

| Introduction | Function Summary | Function Reference |



sync_getnetbynetid

Prototypessyncnetent *sync_getnetbynetid(int netid)

PurposeLook up packetnets entry by netid
Description Attempts to look up a network entry given a netid.
This function only returns synchronous (NETSYNC_TYPE) entries by default. See sync_setfilter() to change.
Parameters
netidnetid of network in packetnets
Returns
syncnetent *structure containing information about this network
NULLon failure
See Also

| Introduction | Function Summary | Function Reference |



sync_lookinit

Prototypessync_lookent *sync_lookinit(int maxnetids)

PurposeInitialize selection mechanism
Description Initializes the selection mechanism for file descriptors. Currently the limit for the number of file descriptors to listen on is 256. If maxnetids is specfied to be more than 256 the call will succeed, but still only 256 file descriptors are allowed. The pointer returned by this function must be used in all the other "sync_look" functions expecting a sync_lookent.
Parameters
maxnetidsmaximum number of netids
Returns
looksync_lookent * - on success
NULLon failure
See Also

| Introduction | Function Summary | Function Reference |



sync_lookadd

Prototypesint sync_lookadd(sync_lookent *look, SCALLT *ct)

PurposeAdd the SCALLT * to selection list
Description Add the file descriptor associated with ct to the selection list contained in look.
Parameters
looksync_lookent pointer
ctSCALLT *
Returns
0on success
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_lookdel

Prototypesint sync_lookdel(sync_lookent *look, SCALLT *ct)

Purposesync_lookdel
Description Remove the file descriptor associated with ct from the selection list contained in look.
Parameters
looksync_lookent pointer
ctSCALLT *
Returns
0on success
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_looksel

PrototypesSCALLT *sync_looksel(sync_lookent *look, int tmout)

PurposeChecks for readability of SCALLTs
Description Checks for availability of frames for the SCALLTs in the selection list created through sync_lookadd()s.
Parameters
looksync_lookent pointer
tmouttimeout: -1 block indefinitely, 0 do not block
Returns
ctSCALLT * if a frame is readable on that SCALLT *
NULLnoting is readable or timeout has occured
See Also

| Introduction | Function Summary | Function Reference |



sync_lookclose

Prototypesvoid sync_lookclose(sync_lookent *look)

PurposeClose selection list
Description Closes the selection mechanism for look.
Parameters
looksync_lookent pointer
See Also

| Introduction | Function Summary | Function Reference |



sync_look

Prototypesint sync_look(SCALLT *ct, int tmout)

PurposeCheck readability of a single SCALLT *
Description Checks for availability of a frame to be read for the netid associated with ct.
Parameters
ctSCALLT *
tmouttimeout: -1 block indefinitely, 0 do not block
Returns
1if there is a frame to be read
0nothing to read or timeout
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_openstats

Prototypesint sync_openstats(int netid, int type)

PurposeOpen statistics request
Description Open statistics request of type "type" on given Network ID.
Only one type of statistics request may be made at a time.
Parameters
netidnetwork ID
typeonly SYNC_BOARDSTATS
Returns
0on success
-1on failure: type is not SYNC_BOARDSTATS
-2on failure: can't open device
See Also

| Introduction | Function Summary | Function Reference |



sync_closestats

Prototypesvoid sync_closestats(void)

PurposeCloses statistics request
Description Close statistics request.
See Also

| Introduction | Function Summary | Function Reference |



sync_getstats

Prototypesint sync_getstats(int netid, char *buf, int len)

PurposeObtain statistics
Description Obtain statistics of the type declared in sync_openstats into an adequately sized buffer buf of length len.
Example

    #include "libsynctcp.h"
    #include "brdstats.h"
    WANlinkstats linkstats;
    int netid = 0;
    if (sync_open(netid, SYNC_BOARDSTATS) == 0)
    {
        if (sync_getstats(netid, (char *) &linkstats, sizeof(linkstats)) == 0)
        {
    	// statistics gathered
    	printf("Transmitted %d frames.\n", linkstats.tx_frames);
        }
        sync_closestats();
    }
    
Parameters
netidnetwork ID
bufbuffer which is to contain stats
lenlength of buffer which is to contain stats
Returns
0on success
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_getdevtype

Prototypesint sync_getdevtype(int netid)

PurposeObtain the device name associated with netid
Description Get the device type of the physical device for the Network identified by netid.
Parameters
netidnetwork ID
Returns
iddevice ID
0if not found
See Also

| Introduction | Function Summary | Function Reference |



sync_getdevicename

Prototypesint sync_getdevicename(int netid, char *name)

PurposeObtain the device name associated with netid
Description Get the device name of physical device for the Network identified by netid.
Parameters
netidnetwork ID
namestring to hold name of device or NULL
Returns
iddevice ID
0if not found
See Also

| Introduction | Function Summary | Function Reference |



sync_error

Prototypesvoid sync_error(char *errstring)

PurposePrints error message to console
Description Writes the error message associated with a Synchronous library error to stdout.
Also prints out the error string associated with a system error (in errno.) (not under SV4 & Windows NT)
SV4 only: the errno value is appended to the error string.
Windows NT only: the value returned by GetLastError() is appended to the error string.
Use of stdout is restricted to Console (Text mode) applications.
Parameters
errstringstring to prepend to output
See Also

| Introduction | Function Summary | Function Reference |



sync_errorstr

Prototypesint sync_errorstr(char *buf, int buflen)

PurposeCopies error message to provided buffer
Description Copies the error message associated with the most recent Synchronous library error into buf.
Parameters
bufpointer to a string to hold the error message
buflenlength of provided buf
Returns
0on success
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_getfd

Prototypesint sync_getfd(SCALLT *ct)

PurposeReturns file descriptor associated with SCALLT *
Description Returns control message file descriptor associated with SCALLT *.
Parameters
ctSCALLT *
Returns
fdfile descriptor
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_getdatafd

Prototypesint sync_getdatafd(SCALLT *ct)

PurposeReturns file descriptor associated with SCALLT *
Description Returns file descriptor for data messages associated with SCALLT *.
Parameters
ctSCALLT *
Returns
fddata file descriptor
-1on failure
See Also

| Introduction | Function Summary | Function Reference |



sync_getdevname

Prototypeschar *sync_getdevname(SCALLT *ct)

PurposeReturn device name associated with SCALLT *
Description Returns the device name associated with SCALLT. For Synchronous over TCP this returns "TCP".
Parameters
ctSCALLT *
Returns
char *name of device
NULLon failure

| Introduction | Function Summary | Function Reference |



sync_getflags

Prototypesint sync_getflags(SCALLT *ct

PurposeGet flags currently set for SCALLT *
Description Get flags currently set for SCALLT *.
Parameters
ctSCALLT *
Returns
flagsflags
-1on failure

| Introduction | Function Summary | Function Reference |



sync_getnetid

Prototypesint sync_getnetid(SCALLT *ct)

PurposeReturn Network ID associated with SCALLT *
Description Returns Network ID associated with SCALLT * as provided to sync_open().
Parameters
ctSCALLT *
Returns
netidNetwork ID
-1on failure

| Introduction | Function Summary | Function Reference |






Mon May 3 12:14:47 2004 by xtractxml.pl$Revision: 1.2 $

Copyright (C) 2003 The Software Group Limited. All Rights Reserved.