HP OpenVMS Systems Documentation

Content starts here HP TCP/IP Services for OpenVMS

HP TCP/IP Services for OpenVMS
Guide to IPv6


Previous Contents Index


if_nameindex()

Returns an array of all interface names and indexes.


Format

#include <if.h>

struct if_nameindex *if_nameindex ( void );


Description

The if_nameindex() function dynamically allocates memory for an array of if_nameindex structures, one structure for each interface. A structure with an if_index value of 0 and a NULL if_name value indicates the end of the array.

The following if_nameindex structure must also be defined (by including <if.h>) prior to the call to if_nameindex() :



struct if_nameindex {
   unsigned int   if_index;
   char           *if_name;
};

To free the memory allocated by this function, use the if_freenameindex() function. If an error occurs, the function returns a NULL pointer and sets errno to an appropriate value.


Return Values

NULL Indicates an error; errno is set to an appropriate value.

if_nametoindex()

Maps an interface name to its corresponding index.


Format

#include <if.h>

unsigned int if_nametoindex ( const char *ifname );


Arguments

ifname

The name of the interface.


Description

If ifname is the name of an interface, the if_nametoindex() function returns the interface index corresponding to the name.

Return Values

Interface index Success
0 Failure

inet6_opt_append()

Returns the length of an IPv6 extension header with a new option and appends the option.


Format

#include <ip6.h>

int inet6_opt_append ( void *extbuf, size_t extlen, int offset, uint8_t type, size_t len, uint_t align, void **databufp );


Arguments

extbuf

Points to a buffer that contains an extension header. This is either a valid pointer or a NULL pointer.

extlen

Specifies the length of the extension header to initialize. Valid values are 0 if extbuf equals 0, a value returned by inet6_opt_finish() , or any number that is a multiple of 8.

offset

Specifies the length of the existing extension header. Obtain this value from a prior call to inet6_opt_init() or inet6_opt_append() .

type

Specifies the type of option. Specify a value from 2 to 255, inclusive, excluding 194.

len

Specifies the length of the option data, excluding the option type and option length fields. Specify a value from 0 to 255, inclusive.

align

Specifies the alignment of the option. Specify one of the following values: 1, 2, 4, or 8.

databufp

Points to a buffer that contains the option data.


Description

The inet6_opt_append() function, when called with extbuf as a NULL pointer and extlen as 0, returns the updated number of bytes in an extension header.

If you specify extbuf as a valid pointer and valid extlen and align parameters, the function returns the same information as in the previous case, but also inserts the pad option, initializes the type and len fields, and returns a pointer to the location for the option content.

After you call inet6_opt_append() , you can then use the data buffer directly or call inet6_optt_set_val() to specify the option contents.


Return Values

x Upon successful completion, the inet6_opt_append() function returns the updated number of bytes in an extension header.
-1 Failure

inet6_opt_find()

Finds a specific option in an extension header.


Format

#include <ip6.h>

int inet6_opt_find ( void *extbuf, size_t extlen, int offset, uint8_t type, size_t *lenp, void **databufp );


Arguments

extbuf

Points to a buffer that contains an extension header.

extlen

Specifies the length, in bytes, of the extension header.

offset

Specifies the location in the extension header of an option. Valid values are either 0 (zero) for the first option or the length returned from a previous call to either inet6_opt_next() or inet6_opt_find() .

type

Specifies the type of option to find.

lenp

Points to the length of the option found.

databufp

Points to the option data.


Description

The inet6_opt_find() function searches a received option extension header for an option specified by type. If it finds the specified option, it returns the option length and a pointer to the option data. In addition, it returns an offset to the next option that you specify in the offset parameter to subsequent calls to inet6_opt_next() in order to search for additional occurrences of the same option type.


Return Values

x Upon successful completion, the inet6_opt_find() function returns an offset from which you can begin the next search in the data buffer.
-1 Failure

inet6_opt_finish()

Returns the total length of an IPv6 extension header, including padding, and initializes the option.


Format

#include <ip6.h>

int inet6_opt_finish ( void *extbuf, size_t extlen, int offset );


Arguments

extbuf

Points to a buffer that contains an extension header. This is either a valid pointer or a NULL pointer.

extlen

Specifies the length of the extension header to finish initializing. A valid value is any number greater than or equal to 0.

offset

Specifies the length of the existing extension header. Obtain this value from a prior call to inet6_opt_init() or inet6_opt_append() .


Description

The inet6_opt_finish() function when called with extbuf as a NULL pointer and extlen as 0, returns the total number of bytes in an extension header, including final padding.

If you specify extbuf as a valid pointer and a valid extlen parameter, the function returns the same information as in the previous case, increments the buffer pointer, and verifies that the buffer is large enough to hold the header.


Return Values

x Upon successful completion, the inet6_opt_finish() function returns the total number of bytes in an extension header, including padding.
-1 Failure

inet6_opt_get_val()

Extracts data items from the data portion of an IPv6 option.


Format

#include <ip6.h>

int inet6_opt_get_val ( void *databuf, size_t offset, void *val, int vallen );


Arguments

databuf

Points to a buffer that contains an extension header. This is a pointer returned by a call to inet6_opt_find() or inet6_opt_next() .

offset

Specifies the location in the data portion of the option from which to extract the data. You can access the first byte after the option type and length by specifying the offset of 0.

val

Points to a destination for the extracted data.

vallen

Specifies the length of the data, in bytes, to be extracted.


Description

The inet6_opt_get_val() function copies data items from data buffer databuf beginning at offset to the location val. In addition, it returns the offset for the next data field to assist you in extracting option content that has multiple fields.

Make sure that each field is aligned on its natural boundaries.


Return Values

x Upon successful completion, the inet6_opt_get_val() function returns the offset for the next field in the data buffer.
-1 Failure

inet6_opt_init()

Returns the length of an IPv6 extension header with no options and initializes the header.


Format

#include <ip6.h>

int inet6_opt_init ( void *extbuf, size_t extlen );


Arguments

extbuf

Points to a buffer that contains an extension header. This is either a valid pointer or a NULL pointer.

extlen

Specifies the length of the extension header to initialize. Valid values are 0 and any number that is a multiple of 8.


Description

The inet6_opt_init() function when called with extbuf as a NULL pointer and extlen as 0, returns the number of bytes in an extension header that has no options.

If you specify extbuf as a valid pointer and extlen as a number that is a multiple of 8, the function returns the same information as in the previous case, initializes the extension header, and sets the length field.


Return Values

x Upon successful completion, the inet6_opt_init() function returns the number of bytes in an extension header with no options.
-1 Failure

inet6_opt_next()

Parses received option extension headers.


Format

#include <ip6.h>

int inet6_opt_next ( void *extbuf, size_t extlen, int offset, unit8_t *typep, size_t *lenp, void **databufp );


Arguments

extbuf

Points to a buffer that contains an extension header.

extlen

Specifies the length, in bytes, of the extension header.

offset

Specifies the location in the extension header of an option. Valid values are either 0 for the first option or the length returned from a previous call to either inet6_opt_next() or inet6_opt_find() .

typep

Points to the type of the option found.

lenp

Points to the length of the option found.

databufp

Points to the option data.


Description

The inet6_opt_next() function parses a received option extension header and returns the next option. In addition, it returns an offset to the next option that you specify in the offset parameter to subsequent calls to inet6_opt_next() .

This function does not return any PAD1 or PADN options.


Return Values

x Upon successful completion, the inet6_opt_next() function returns the offset for the next option in the data buffer.
-1 Failure

inet6_opt_set_val()

Adds one component of the option content to the options header.


Format

#include <ip6.h>

int inet6_opt_set_val ( void *databuf, size_t offset, void *val int vallen );


Arguments

databuf

Points to a buffer that contains an extension header. This is a pointer returned by a call to inet6_opt_append() .

offset

Specifies the location in the data portion of the option into which to insert the data. You can access the first byte after the option type and length by specifying the offset of 0 (zero).

val

Points to the data to be inserted.

vallen

Specifies the length of the data, in bytes, to be inserted.


Description

The inet6_opt_set_val() function copies data items at the location val into a data buffer databuf beginning at offset. In addition, it returns the offset for the next data field to assist you in composing content that has multiple fields.

Make sure that each field is aligned on its natural boundaries.


Return Values

x Upon successful completion, the inet6_opt_set_val() function returns the offset for the next field in the data buffer.
-1 Failure

inet6_rth_add()

Adds an IPv6 address to the routing header under construction.


Format

#include <ip6.h>

int inet6_rth_add ( void *bp, const struct in6_addr *addr );


Arguments

bp

Points to a buffer that is to contain an IPv6 routing header.

addr

Points to an IPv6 address to add to the routing header.


Description

The inet6_rth_add() function adds IPv6 address to the end of the routing header under construction. The address pointed to by addr cannot be either an IPv6 V4-mapped address or an IPv6 multicast address.

The function increments the ip60r_segleft member in the ip6_rthdr0 structure . The ip6_rthdr0 structure is defined in <ip6.h> .

Only routing header type 0 is supported.


Return Values

x Upon successful completion, the inet6_rth_add() function returns 0 (zero).
-1 Failure

inet6_rth_getaddr()

Retrieves an address for an index from an IPv6 routing header.


Format

#include <ip6.h>

struct in6_addr *inet6_rth_getaddr ( const void *bp, int index );


Arguments

bp

Points to a buffer that contains an IPv6 routing header.

index

Specifies a value that identifies a position in a routing header for a specific address. Valid values range from 0 to the return value from inet6_rth_segments() minus 1.


Description

The inet6_rth_getaddr() function uses a specified index value and retrieves a pointer to an address in a Routing header specified by bp. Call inet6_rth_segments() before calling this function in order to determine the number of segments (addresses) in the routing header.


Return Values

x Upon successful completion, the inet6_rth_getaddr() function returns a pointer to an address.
NULL pointer Failure

inet6_rth_init()

Initializes an IPv6 routing header buffer.


Format

#include <ip6.h>

void *inet6_rth_init ( void *bp, int bp_len, int type, int segments );


Arguments

bp

Points to a buffer that is to contain an IPv6 routing header.

bp_len

Specifies the length, in bytes, of the buffer.

type

Specifies the type of routing header. The valid value is IPV6_RTHDR_TYPE_0 for IPv6 routing header type 0.

segments

Specifies the number of segments or addresses that are to be included in the routing header. The valid value is from 0 to 127, inclusive.


Description

The inet6_rth_init() function initializes a buffer and buffer data for an IPv6 routing header. The function sets the ip6r0_segleft , ip6r0_nxt , and ip6r0_reserved members in the ip6_rthdr0 structure to zero. In addition, it sets the ip6r0_type member to type and sets the ip6r0_len member based in the segments parameter. (See RFC 2460 for a description of the actual value.) The ip6_rthdr0 structure is defined in <ip6.h> .

The application must allocate the buffer. Use the inet6_rth_space() function to determine the buffer size.

Use the returned pointer as the first argument to the inet6_rth_add() function.


Return Values

x Upon successful completion, the inet6_rth_init() function returns a pointer to the buffer that is to contain the routing header.
NULL pointer If the type is not supported, the bp is a null, or the number of bp_len is invalid.

inet6_rth_reverse()

Reverses the order of addresses in an IPv6 routing header.


Format

#include <ip6.h>

int inet6_rth_reverse ( const void *in, void *out );


Arguments

in

Points to a buffer that contains an IPv6 routing header.

out

Points to a buffer that is to contain the routing header with the reversed addresses. This parameter can point to the same buffer specified by the in parameter.


Description

The inet6_rth_reverse() function reads an IPv6 routing header and writes a new routing header, reversing the order of addresses in the new header. The in and out parameters can point to the same buffer.

The function sets the ip6r0_segleft member in the ip6_rthdr0 structure to the number of segments (addresses) in the new header.

The ip6_rthdr0 structure is defined in <ip6.h> .


Return Values

0 (zero) Success
-1 Failure

inet6_rth_segments()

Returns the number of segments (addresses) in an IPv6 routing header.


Format

#include <ip6.h>

int inet6_rth_segments ( const void *bp );


Arguments

bp

Points to a buffer that contains an IPv6 routing header.


Description

The inet6_rth_segments() function returns the number of segments (or addresses) in an IPv6 routing header.


Return Values

x Upon successful completion, the inet6_rth_segments() function returns the number of segments, 0 (zero) or greater than 0.
-1 Failure


Previous Next Contents Index