|
|
#include <netdb.h> #include <errno.h>int endtosent()
struct tosent * gettosbyname (name, proto) const char *name; const char *proto;
struct tosent *gettosent ()
int parsetos (name, proto) char *name, *proto;
void settosent (stayopen) int stayopen
struct tosent { char *t_name; /* name */ char **t_aliases; /* alias list */ char *t_proto; /* protocol */ int t_tos; /* Type Of Service bits */ };
The members of this structure are as follows:
t_name
t_aliases
t_proto
t_tos
The settosent routine opens and rewinds the /etc/iptos file. If the stayopen flag is nonzero, successive calls to gettosbyname will not close and reopen the /etc/iptos file.
The endtosent routine closes the /etc/iptos file.
The gettosbyname routine fetches information for the Type Of Service with name (or alias) name for the protocol proto. If proto is NULL or the string * (a single asterisk), the gettosbyname routine fetches information for the first encountered Type Of Service with name name, regardless of protocol. The gettosbyname routine uses the settosent and endtosent routines, thereby opening and closing the file, if the stayopen flag is 0.
The gettosent routine returns the next entry in the /etc/iptos database, opening the file if necessary.
The
parsetos
routine returns the actual
t_tos
TOS value from the tosent
structure for the specified
``name''
and
``proto''
fields, as returned by
gettosbyname.
If the
gettosbyname
routine does not find an appropriate
tosent
value, the
parsetos
routine returns the presumed numeric value
specified in the string name.
The parsetos routine returns the actual Type Of Service value, or returns -1 and sets errno if it detects an error. If errno is set to EINVAL, no TOS entry for the name name was found, and name was not a numeric string. If errno is set to ERANGE, the specified TOS value is outside the legal range of TOS values (0 to 255).