Name

libpcp — port-control-protocol client library

Synopsis

#include <pcp.h>
int pcp_init( struct sockaddr *server,
  struct sockaddr *source,
  pcp_t *pcp);
 
int pcp_close( pcp_t *pcp);
 
int pcp_getsocket( pcp_t *pcp,
  int *sock);
 
int pcp_setsocket( pcp_t *pcp,
  int sock);
 
int pcp_gettries( pcp_t *pcp,
  int *tries);
 
int pcp_gettimeout( pcp_t *pcp,
  struct timeval *timeout,
  int relative);
 
int pcp_setreset( pcp_t *pcp,
  int reset,
  int *old);
 
int pcp_setautofill( pcp_t *pcp,
  int autofill,
  int *old);
 
int pcp_third_party4( pcp_option_t ***options,
  uint32_t *addr);
 
int pcp_third_party6( pcp_option_t ***options,
  uint8_t *addr);
 
int pcp_prefer_failure( pcp_option_t ***options);
 
int pcp_filter4( pcp_option_t ***options,
  int prefixlen,
  uint32_taddr,
  uint16_tport);
 
int pcp_filter6( pcp_option_t ***options,
  int prefixlen,
  uint8_t *addr,
  uint16_tport);
 
int pcp_makerequest( pcp_t *pcp,
  pcp_request_t *request,
  pcp_option_t **options);
 
int pcp_sendrequest( pcp_t *pcp);
 
int pcp_recvresponse( pcp_t *pcp,
  pcp_response_t *response);
 
const char *pcp_strerror( int error);
 
int pcp_getmapping( pcp_t *pcp,
  pcp_request_t *request,
  pcp_response_t *response,
  pcp_option_t **options);
 
int pcp_renewmapping( pcp_t *pcp,
  pcp_response_t *response);
 
int pcp_delmapping( pcp_t *pcp,
  pcp_response_t *response);
 
void pcp_freeoptions( pcp_options_t **options);
 
void pcp_mapintaddr( pcp_request_t *request);
 
void pcp_mapextaddr( pcp_request_t *request);
 
void pcp_mapremotepeer( pcp_request_t *request);
 
void pcp_mapoptaddr( pcp_option_t *option);
 
int pcp_unmapintaddr( pcp_request_t *request);
 
int pcp_unmapextaddr( pcp_request_t *request);
 
int pcp_unmapremotepeer( pcp_request_t *request);
 
int pcp_unmapoptaddr( pcp_option_t *option);
 

DESCRIPTION

pcp_init initializes a PCP handler (source may be NULL).

pcp_close closes a PCP handler.

pcp_getsocket gets the socket file descriptor.

pcp_setsocket sets the rapid recovery multicast listener socket file descriptor. It is the responsability of the caller to create, bind, register, wait for and close the socket. An invalid value for sock resets the rapid recovery state.

pcp_gettries gets the number of tries.

pcp_gettimeout gets the relative or absolute timeout for the next retry.

pcp_setreset sets the reset flag: when set to one, transient protocol errors are translated to restart of the whole procedure after a timeout.

pcp_setautofill sets the autofill flag: when set to one (the default), the internal address is filled from getsockname on the PCP socket in pcp_makerequest.

pcp_third_party4 stacks a THIRD_PARTY IPv4 option.

pcp_third_party6 stacks a THIRD_PARTY IPv6 option.

pcp_prefer_failure stacks a PREFER_FAILURE option.

pcp_filter4 stacks a FILTER IPv4 option.

pcp_filter6 stacks a FILTER IPv6 option.

pcp_makerequest clears/creates a request. The options is the NULL pointer or a NULL terminated table of pointers to options.

pcp_sendrequest sends/resends the current request.

pcp_recvresponse receives the response to the current request, including rapid recovery announces.

pcp_strerror translates an error to its human friendly description.

pcp_getmapping gets a mapping.

pcp_renewmapping renews a mapping. Note server reboots are not checked.

pcp_delmapping deletes a mapping.

pcp_freeoptions free allocated options.

pcp_mapintaddr converts the internal IPv4 address field intaddr4 into an IPv4 mapped IPv6 address.

pcp_mapextaddr converts the external IPv4 address field extaddr4 into an IPv4 mapped IPv6 address.

pcp_mapremotepeer converts the remote peer IPv4 address field remotepeer4 into an IPv4 mapped IPv6 address.

pcp_mapoptaddr converts the IPv4 address field optaddr4 in the option into an IPv4 mapped IPv6 address.

pcp_unmapintaddr converts the internal IPv4 mapped IPv6 address into an IPv4 address.

pcp_unmapextaddr converts the external IPv4 mapped IPv6 address into an IPv4 address.

pcp_unmapremotepeer converts the remote peer IPv4 mapped IPv6 address into an IPv4 address.

pcp_unmapoptaddr converts the IPv4 mapped IPv6 address in the option into an IPv4 address.

RETURN CODES

PCP_OK

OK

PCP_TRY_AGAIN

try again

PCP_ERR_INVAL

invalid arguments

PCP_ERR_NOMEM

malloc() failed

PCP_ERR_SOCKET

socket() syscall failed

PCP_ERR_BIND

bind() syscall failed

PCP_ERR_CONNECT

connect() syscall failed

PCP_ERR_SEND

send() syscall failed

PCP_ERR_RECV

recv() syscall failed

PCP_ERR_SYSCALL

miscellaneous syscall failed

PCP_ERR_NOREQUEST

no current request

PCP_ERR_RECVBAD

received a bad response

PCP_ERR_TOOMANYOPTS

too many options

PCP_ERR_FAILURE

mapping() function internal failure

PCP_ERR_APP0

user application error 0

PCP_ERR_APP1

user application error 1

PCP_ERR_APP2

user application error 2

PCP_ERR_PROTOBASE

base for protocol errors

PCP_ERR_UNSUPVERSION

unsupported version

PCP_ERR_NOTAUTH

not authorized

PCP_ERR_BADREQUEST

malformed request

PCP_ERR_UNSUPOPCODE

unsupported opcode

PCP_ERR_UNSUPOPTION

unsupported option

PCP_ERR_BADOPTION

malformed option

PCP_ERR_NETFAILURE

network failure

PCP_ERR_NORESOURCES

out of resources

PCP_ERR_UNSUPPROTO

unsupported protocol

PCP_ERR_EXQUOTA

user exceeded quota

PCP_ERR_CANTPROVIDE

cannot provide external

PCP_ERR_ADDRMISMATCH

address mismatch

PCP_ERR_TOOMANYPEER

excessive number of remote peers

PCP_ERR_PROCERROR

processing error

SEE ALSO

pcpd(8)

AUTHOR

Internet Systems Consortium