getprotobynumber

Returns information about a protocol, given its protocol number.

Library:LibC
Standard:BSD
Service:Networking

Syntax

  #include <netdb.h> 
   
  struct protoent *getprotobynumber (
     int   proto);
  

Parameters

proto

(IN) Points to the protocol number. The following numbers have been defined in the netinet/in.h file:

Flag

Value

Description

IPPROTO_IP

0

IP

IPPROTO_ICMP

1

Internet Control Message Protocol

IPPROTO_IGMP

2

Internet Group Management Protocol

IPPROTO_TCP

6

TCP

IPPROTO_UDP

17

User Datagram Protocol

Return Values

If successful, returns a pointer to a structure of type protoent. Otherwise, returns NULL.

Remarks

The getprotobynumber function accepts an integer value representing the protocol number. The function begins searching for the protocol number from the beginning of the sys:\etc\protocol file and continues until it finds a matching entry or reaches end-of-file. A matching entry might not be defined in the netinet/in.h file, which lists some of the common protocols and assigns them numbers.

NOTE:Calling any database routine overwrites the results of the last call to getprotobynumber.

See Also

getprotobyname