getprotobynumber_r()--Get Protocol Information for Protocol Number


  Syntax
 #include <netdb.h>

 int getprotobynumber_r(int protocol_number,
                   struct protoent
                      *protoent_struct_addr,
                   struct protoent_data
                      *protoent_data_struct_addr)

  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: Yes

The getprotobynumber_r() function is used to retrieve information about a protocol. The information is retrieved from the protocol database file.

Parameters

int protocol_number  (input) 
Specifies the protocol number for which information is to be retrieved.

struct protoent *protoent_struct_addr  (input/output) 
Specifies the pointer to a protoent structure where the results will be placed. All results must be referenced through this structure.

struct protoent_data *protoent_data_struct_addr  (input/output) 
Specifies the pointer to the protoent_data structure, which is used to pass and preserve results between function calls. The field proto_control_blk in the protoent_data structures must be initialized with hexadecimal zeros before its initial use. If compatibility with other platforms is required, then the entire protoent_data structure must be initialized with hexadecimal zeros before initial use.

Authorities

No authorization is required.


Return Value

The getprotobynumber_r() function returns an integer. Possible values are:

The struct protoent denoted by protoent_struct_addr and struct protoent_data denoted by protoent_data_struct_addr are both defined in <netdb.h>. The structure struct protoentis defined as:

      struct protoent [
        char            *p_name;
        char            **p_aliases;
        int             p_proto;
      ];

p_name points to the character string that contains the name of the protocol. p_aliases is a pointer to a NULL-terminated list of pointers, each of which points to a character string that represents an alternative name for the protocol. p_proto is the protocol number.


Error Conditions

When the getprotobynumber_r() function fails, errno can be set to:

[EINVAL]

The protoent_data structure was not properly initialized with hexadecimal zeros before initial use. For corrective action, see the description for structure protoent_data.


Usage Notes

  1. System i® Navigator or the following CL commands can be used to access the protocol database file:


  2. When the protocol information is obtained from the protocol database file, the file is opened and the protocol information is retrieved (if it exists) from the file. The file is then closed only if a setprotoent_r() call with a non-zero parameter value was not previously done.

  3. A coded character set identifier (CCSID) of 65535 for the job requests that no database translation be performed. For translation to occur for the protocol names returned in the protoent structure, the job CCSID must be something other than 65535.

Related Information



API introduced: V3R1

[ Back to top | UNIX-Type APIs | APIs by category ]