sockaddr.h File Reference

#include <isc/lang.h>
#include <isc/net.h>
#include <isc/types.h>

Go to the source code of this file.

Data Structures

struct  isc_sockaddr

Defines

#define ISC_SOCKADDR_H   1
#define ISC_SOCKADDR_CMPADDR   0x0001
 compare the address sin_addr/sin6_addr
#define ISC_SOCKADDR_CMPPORT   0x0002
 compare the port sin_port/sin6_port
#define ISC_SOCKADDR_CMPSCOPE   0x0004
 compare the scope sin6_scope
#define ISC_SOCKADDR_CMPSCOPEZERO   0x0008
 when comparing scopes zero scopes always match
#define ISC_SOCKADDR_FORMATSIZE   sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX%SSSSSSSSSS#YYYYY")
 Minimum size of array to pass to isc_sockaddr_format().

Functions

typedef ISC_LIST (struct isc_sockaddr) isc_sockaddrlist_t
ISC_LANG_BEGINDECLS isc_boolean_t isc_sockaddr_compare (const isc_sockaddr_t *a, const isc_sockaddr_t *b, unsigned int flags)
 Compare the elements of the two address ('a' and 'b') as specified by 'flags' and report if they are equal or not.
isc_boolean_t isc_sockaddr_equal (const isc_sockaddr_t *a, const isc_sockaddr_t *b)
 Return ISC_TRUE iff the socket addresses 'a' and 'b' are equal.
isc_boolean_t isc_sockaddr_eqaddr (const isc_sockaddr_t *a, const isc_sockaddr_t *b)
 Return ISC_TRUE iff the address parts of the socket addresses 'a' and 'b' are equal, ignoring the ports.
isc_boolean_t isc_sockaddr_eqaddrprefix (const isc_sockaddr_t *a, const isc_sockaddr_t *b, unsigned int prefixlen)
 Return ISC_TRUE iff the most significant 'prefixlen' bits of the socket addresses 'a' and 'b' are equal, ignoring the ports. If 'b''s scope is zero then 'a''s scope will be ignored.
unsigned int isc_sockaddr_hash (const isc_sockaddr_t *sockaddr, isc_boolean_t address_only)
 Return a hash value for the socket address 'sockaddr'. If 'address_only' is ISC_TRUE, the hash value will not depend on the port.
void isc_sockaddr_any (isc_sockaddr_t *sockaddr)
 Return the IPv4 wildcard address.
void isc_sockaddr_any6 (isc_sockaddr_t *sockaddr)
 Return the IPv6 wildcard address.
void isc_sockaddr_anyofpf (isc_sockaddr_t *sockaddr, int family)
 Set '*sockaddr' to the wildcard address of protocol family 'family'.
void isc_sockaddr_fromin (isc_sockaddr_t *sockaddr, const struct in_addr *ina, in_port_t port)
 Construct an isc_sockaddr_t from an IPv4 address and port.
void isc_sockaddr_fromin6 (isc_sockaddr_t *sockaddr, const struct in6_addr *ina6, in_port_t port)
 Construct an isc_sockaddr_t from an IPv6 address and port.
void isc_sockaddr_v6fromin (isc_sockaddr_t *sockaddr, const struct in_addr *ina, in_port_t port)
 Construct an IPv6 isc_sockaddr_t representing a mapped IPv4 address.
void isc_sockaddr_fromnetaddr (isc_sockaddr_t *sockaddr, const isc_netaddr_t *na, in_port_t port)
 Construct an isc_sockaddr_t from an isc_netaddr_t and port.
int isc_sockaddr_pf (const isc_sockaddr_t *sockaddr)
 Get the protocol family of 'sockaddr'.
void isc_sockaddr_setport (isc_sockaddr_t *sockaddr, in_port_t port)
 Set the port of 'sockaddr' to 'port'.
in_port_t isc_sockaddr_getport (const isc_sockaddr_t *sockaddr)
 Get the port stored in 'sockaddr'.
isc_result_t isc_sockaddr_totext (const isc_sockaddr_t *sockaddr, isc_buffer_t *target)
 Append a text representation of 'sockaddr' to the buffer 'target'. The text will include both the IP address (v4 or v6) and the port. The text is null terminated, but the terminating null is not part of the buffer's used region.
void isc_sockaddr_format (const isc_sockaddr_t *sa, char *array, unsigned int size)
 Format a human-readable representation of the socket address '*sa' into the character array 'array', which is of size 'size'. The resulting string is guaranteed to be null-terminated.
isc_boolean_t isc_sockaddr_ismulticast (const isc_sockaddr_t *sa)
 Returns ISC_TRUE if the address is a multicast address.
isc_boolean_t isc_sockaddr_isexperimental (const isc_sockaddr_t *sa)
isc_boolean_t isc_sockaddr_islinklocal (const isc_sockaddr_t *sa)
 Returns ISC_TRUE if the address is a link local address.
isc_boolean_t isc_sockaddr_issitelocal (const isc_sockaddr_t *sa)
 Returns ISC_TRUE if the address is a sitelocal address.
isc_result_t isc_sockaddr_frompath (isc_sockaddr_t *sockaddr, const char *path)


Detailed Description

Definition in file sockaddr.h.


Define Documentation

#define ISC_SOCKADDR_H   1

Definition at line 21 of file sockaddr.h.

#define ISC_SOCKADDR_CMPADDR   0x0001

compare the address sin_addr/sin6_addr

Definition at line 48 of file sockaddr.h.

Referenced by isc_sockaddr_compare(), isc_sockaddr_eqaddr(), isc_sockaddr_equal(), and recv_done().

#define ISC_SOCKADDR_CMPPORT   0x0002

compare the port sin_port/sin6_port

Definition at line 50 of file sockaddr.h.

Referenced by isc_sockaddr_compare(), isc_sockaddr_equal(), and recv_done().

#define ISC_SOCKADDR_CMPSCOPE   0x0004

compare the scope sin6_scope

Definition at line 52 of file sockaddr.h.

Referenced by isc_sockaddr_compare(), isc_sockaddr_eqaddr(), isc_sockaddr_equal(), and recv_done().

#define ISC_SOCKADDR_CMPSCOPEZERO   0x0008

when comparing scopes zero scopes always match

Definition at line 54 of file sockaddr.h.

Referenced by isc_sockaddr_compare(), and recv_done().

#define ISC_SOCKADDR_FORMATSIZE   sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX%SSSSSSSSSS#YYYYY")

Minimum size of array to pass to isc_sockaddr_format().

Definition at line 234 of file sockaddr.h.

Referenced by add_bad(), client_ok(), configure_listener(), connect_done(), control_newconn(), control_senddone(), create_tcp_dispatch(), dispatch_createudp(), dns_zone_notifyreceive(), do_scan(), doio_send(), forward_callback(), get_dispsocket(), get_view_querysource_dispatch(), got_transfer_quota(), internal_connect(), listener_bind(), log_formerr(), log_invalid(), log_lame(), log_nsid(), logfmtpacket(), next_master(), next_server(), notify_done(), notify_send_toaddr(), ns_add_reserved_dispatch(), ns_client_dumprecursing(), ns_client_logv(), ns_controls_configure(), ns_lwresd_configure(), ns_statschannels_configure(), parse_config(), printmessage(), received(), recv_done(), refresh_callback(), resquery_response(), rndc_connected(), rndc_startconnect(), send_update(), show_settings(), shutdown_listener(), socket_log(), stub_callback(), tcp_length_done(), tcp_recv(), xfrin_connect_done(), and xfrin_logv().


Function Documentation

typedef ISC_LIST ( struct  isc_sockaddr  ) 

ISC_LANG_BEGINDECLS isc_boolean_t isc_sockaddr_compare ( const isc_sockaddr_t a,
const isc_sockaddr_t b,
unsigned int  flags 
)

Compare the elements of the two address ('a' and 'b') as specified by 'flags' and report if they are equal or not.

'flags' is set from ISC_SOCKADDR_CMP*.

Definition at line 50 of file sockaddr.c.

References AF_INET6, ISC_FALSE, ISC_SOCKADDR_CMPADDR, ISC_SOCKADDR_CMPPORT, ISC_SOCKADDR_CMPSCOPE, ISC_SOCKADDR_CMPSCOPEZERO, ISC_TRUE, isc_sockaddr::length, REQUIRE, isc_sockaddr::sa, isc_sockaddr::sin, isc_sockaddr::sin6, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_port, sockaddr_in6::sin6_scope_id, and isc_sockaddr::type.

Referenced by isc_sockaddr_eqaddr(), isc_sockaddr_equal(), and recv_done().

isc_boolean_t isc_sockaddr_equal ( const isc_sockaddr_t a,
const isc_sockaddr_t b 
)

Return ISC_TRUE iff the socket addresses 'a' and 'b' are equal.

Definition at line 37 of file sockaddr.c.

References ISC_SOCKADDR_CMPADDR, ISC_SOCKADDR_CMPPORT, ISC_SOCKADDR_CMPSCOPE, and isc_sockaddr_compare().

Referenced by add_listenelt(), bad_edns(), bad_server(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), dns_resolver_createfetch3(), entry_search(), find_entry_and_lock(), find_listener(), find_matching_interface(), get_view_querysource_dispatch(), local_addr_match(), notify_isqueued(), ns_add_reserved_dispatch(), ns_client_error(), ns_interfacemgr_listeningon(), same_addrs(), send_tcp_connect(), setup_listenon(), soa_query(), socket_search(), triededns(), triededns512(), udp_recv(), and update_listener().

isc_boolean_t isc_sockaddr_eqaddr ( const isc_sockaddr_t a,
const isc_sockaddr_t b 
)

Return ISC_TRUE iff the address parts of the socket addresses 'a' and 'b' are equal, ignoring the ports.

Definition at line 44 of file sockaddr.c.

References ISC_SOCKADDR_CMPADDR, ISC_SOCKADDR_CMPSCOPE, and isc_sockaddr_compare().

Referenced by dispatch_createudp(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), dns_zone_notifyreceive(), local_addr_match(), notify_isself(), recv_done(), and udp_recv().

isc_boolean_t isc_sockaddr_eqaddrprefix ( const isc_sockaddr_t a,
const isc_sockaddr_t b,
unsigned int  prefixlen 
)

Return ISC_TRUE iff the most significant 'prefixlen' bits of the socket addresses 'a' and 'b' are equal, ignoring the ports. If 'b''s scope is zero then 'a''s scope will be ignored.

Definition at line 104 of file sockaddr.c.

References isc_netaddr_eqprefix(), and isc_netaddr_fromsockaddr().

unsigned int isc_sockaddr_hash ( const isc_sockaddr_t sockaddr,
isc_boolean_t  address_only 
)

Return a hash value for the socket address 'sockaddr'. If 'address_only' is ISC_TRUE, the hash value will not depend on the port.

IPv6 addresses containing mapped IPv4 addresses generate the same hash value as the equivalent IPv4 address.

Definition at line 204 of file sockaddr.c.

References AF_INET6, IN6_IS_ADDR_V4MAPPED, isc_hash_calc(), ISC_MSG_UNKNOWNFAMILY, isc_msgcat_get(), ISC_MSGSET_SOCKADDR, ISC_TRUE, isc_sockaddr::length, REQUIRE, s, isc_sockaddr::sa, isc_sockaddr::sin, isc_sockaddr::sin6, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_port, isc_sockaddr::type, and UNEXPECTED_ERROR.

Referenced by ATF_TC_BODY(), dns_hash(), find_entry_and_lock(), and grow_entries().

void isc_sockaddr_any ( isc_sockaddr_t sockaddr  ) 

Return the IPv4 wildcard address.

Definition at line 253 of file sockaddr.c.

References ISC_LINK_INIT, isc_sockaddr::length, isc_sockaddr::sin, and isc_sockaddr::type.

Referenced by client_create(), dns_dispatch_createtcp2(), dns_zone_create(), get_view_querysource_dispatch(), isc_sockaddr_anyofpf(), main(), make_dispatchset(), notify_create(), notify_isself(), recv_done(), send_tcp_connect(), and setup_system().

void isc_sockaddr_any6 ( isc_sockaddr_t sockaddr  ) 

Return the IPv6 wildcard address.

Definition at line 267 of file sockaddr.c.

References AF_INET6, in6addr_any, ISC_LINK_INIT, isc_sockaddr::length, isc_sockaddr::sin6, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_family, sockaddr_in6::sin6_port, and isc_sockaddr::type.

Referenced by add_listenelt(), dns_dispatch_createtcp2(), dns_zone_create(), get_view_querysource_dispatch(), isc_sockaddr_anyofpf(), main(), notify_isself(), recv_done(), send_tcp_connect(), and setup_system().

void isc_sockaddr_anyofpf ( isc_sockaddr_t sockaddr,
int  family 
)

Set '*sockaddr' to the wildcard address of protocol family 'family'.

Requires:

Definition at line 296 of file sockaddr.c.

References AF_INET6, INSIST, isc_sockaddr_any(), and isc_sockaddr_any6().

Referenced by create_tcp_dispatch(), dispatch_createudp(), getudpdispatch(), send_udp(), and udp_recv().

void isc_sockaddr_fromin ( isc_sockaddr_t sockaddr,
const struct in_addr *  ina,
in_port_t  port 
)

Construct an isc_sockaddr_t from an IPv4 address and port.

Definition at line 281 of file sockaddr.c.

References ISC_LINK_INIT, isc_sockaddr::length, isc_sockaddr::sin, and isc_sockaddr::type.

Referenced by ATF_TC_BODY(), bind9_getaddresses(), dash_option(), evaluate_local(), import_rdataset(), main(), ns_controls_configure(), ns_lwresd_configure(), parse_netprefix(), resolveaddr_done(), and setup_system().

void isc_sockaddr_fromin6 ( isc_sockaddr_t sockaddr,
const struct in6_addr ina6,
in_port_t  port 
)

Construct an isc_sockaddr_t from an IPv6 address and port.

Definition at line 310 of file sockaddr.c.

References AF_INET6, ISC_LINK_INIT, isc_sockaddr::length, isc_sockaddr::sin6, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_family, sockaddr_in6::sin6_port, and isc_sockaddr::type.

Referenced by ATF_TC_BODY(), bind9_getaddresses(), dash_option(), do_scan(), evaluate_local(), import_rdataset(), main(), ns_controls_configure(), parse_netprefix(), resolveaddr_done(), and setup_system().

void isc_sockaddr_v6fromin ( isc_sockaddr_t sockaddr,
const struct in_addr *  ina,
in_port_t  port 
)

Construct an IPv6 isc_sockaddr_t representing a mapped IPv4 address.

Definition at line 325 of file sockaddr.c.

References AF_INET6, ISC_LINK_INIT, isc_sockaddr::length, isc_sockaddr::sin6, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_family, sockaddr_in6::sin6_port, and isc_sockaddr::type.

Referenced by bind9_getaddresses().

void isc_sockaddr_fromnetaddr ( isc_sockaddr_t sockaddr,
const isc_netaddr_t na,
in_port_t  port 
)

Construct an isc_sockaddr_t from an isc_netaddr_t and port.

Definition at line 369 of file sockaddr.c.

References AF_INET6, isc_netaddr::family, isc_netaddr::in, isc_netaddr::in6, INSIST, ISC_LINK_INIT, isc_netaddr_getzone(), isc_sockaddr::length, isc_sockaddr::sin, isc_sockaddr::sin6, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_port, sockaddr_in6::sin6_scope_id, isc_netaddr::type, and isc_sockaddr::type.

Referenced by bind9_getaddresses(), do_scan(), lwaddr_sockaddr_fromlwresaddr(), ns_lwdclient_processgnba(), parse_netaddr(), parse_querysource(), parse_sockaddrsub(), and setup_listenon().

int isc_sockaddr_pf ( const isc_sockaddr_t sockaddr  ) 

Get the protocol family of 'sockaddr'.

Requires:

Returns:

Definition at line 342 of file sockaddr.c.

References AF_INET6, FATAL_ERROR, ISC_MSG_UNKNOWNFAMILY, isc_msgcat_get(), ISC_MSGSET_SOCKADDR, PF_INET6, isc_sockaddr::sa, and isc_sockaddr::type.

Referenced by add_listenelt(), add_listener(), client_request(), create_tcp_dispatch(), dispatch_createudp(), dns_dispatch_createtcp2(), dns_request_createraw4(), dns_request_createvia4(), dns_xfrin_create(), dns_zone_notifyreceive(), fctx_getaddresses(), fctx_query(), find_udp_dispatch(), get_dispsocket(), get_udpsocket(), get_view_querysource_dispatch(), got_transfer_quota(), listener_bind(), notify_isself(), notify_send_toaddr(), ns_add_reserved_dispatch(), ns_interface_accepttcp(), ns_interface_listenudp(), ns_query(), open_socket(), portavailable(), recv_done(), recvsoa(), resquery_connected(), resquery_response(), rndc_startconnect(), send_tcp_connect(), send_udp(), send_update(), sendrequest(), sendtomaster(), soa_query(), udp_recv(), xfrin_create(), and xfrin_start().

void isc_sockaddr_setport ( isc_sockaddr_t sockaddr,
in_port_t  port 
)

Set the port of 'sockaddr' to 'port'.

Definition at line 401 of file sockaddr.c.

References AF_INET6, FATAL_ERROR, ISC_MSG_UNKNOWNFAMILY, isc_msgcat_get(), ISC_MSGSET_SOCKADDR, isc_sockaddr::sa, isc_sockaddr::sin, isc_sockaddr::sin6, sockaddr_in6::sin6_port, and isc_sockaddr::type.

Referenced by configure_alternates(), configure_forward(), create_tcp_dispatch(), fctx_query(), findname(), get_dispsocket(), get_udpsocket(), listener_bind(), new_adbaddrinfo(), ns_config_getipandkeylist(), ns_config_getiplist(), ns_controls_configure(), ns_statschannels_configure(), parse_config(), and xfrin_create().

in_port_t isc_sockaddr_getport ( const isc_sockaddr_t sockaddr  ) 

Get the port stored in 'sockaddr'.

Definition at line 419 of file sockaddr.c.

References AF_INET6, FATAL_ERROR, ISC_MSG_UNKNOWNFAMILY, isc_msgcat_get(), ISC_MSGSET_SOCKADDR, port, isc_sockaddr::sa, isc_sockaddr::sin, isc_sockaddr::sin6, sockaddr_in6::sin6_port, and isc_sockaddr::type.

Referenced by add_listenelt(), cfg_print_sockaddr(), check_zoneconf(), client_request(), configure_alternates(), configure_forward(), configure_staticstub_serveraddrs(), dns_adb_findaddrinfo(), dns_dispatch_getudp_dup(), doio_recv(), get_udpsocket(), get_view_querysource_dispatch(), listener_bind(), local_addr_match(), ns_add_reserved_dispatch(), ns_client_error(), ns_config_getipandkeylist(), ns_config_getiplist(), ns_controls_configure(), ns_statschannels_configure(), parse_config(), portavailable(), print_querysource(), recv_done(), and udp_recv().

isc_result_t isc_sockaddr_totext ( const isc_sockaddr_t sockaddr,
isc_buffer_t target 
)

Append a text representation of 'sockaddr' to the buffer 'target'. The text will include both the IP address (v4 or v6) and the port. The text is null terminated, but the terminating null is not part of the buffer's used region.

Returns:

Definition at line 114 of file sockaddr.c.

References AF_INET6, isc_region::base, INSIST, isc_buffer_availablelength, isc_buffer_availableregion, isc_buffer_putmem, isc_netaddr_fromsockaddr(), isc_netaddr_totext(), ISC_R_FAILURE, ISC_R_NOSPACE, ISC_R_SUCCESS, isc_region::length, REQUIRE, isc_sockaddr::sa, isc_sockaddr::sin, isc_sockaddr::sin6, sockaddr_in6::sin6_port, and isc_sockaddr::type.

Referenced by isc_sockaddr_format().

void isc_sockaddr_format ( const isc_sockaddr_t sa,
char *  array,
unsigned int  size 
)

Format a human-readable representation of the socket address '*sa' into the character array 'array', which is of size 'size'. The resulting string is guaranteed to be null-terminated.

Definition at line 181 of file sockaddr.c.

References isc_buffer_init, ISC_MSG_UNKNOWNADDR, isc_msgcat_get(), ISC_MSGSET_NETADDR, ISC_R_SUCCESS, isc_sockaddr_totext(), isc_sockaddr::sa, and isc_sockaddr::type.

Referenced by add_bad(), client_ok(), configure_listener(), connect_done(), control_newconn(), control_senddone(), create_tcp_dispatch(), dispatch_createudp(), dns_zone_notifyreceive(), do_scan(), doio_send(), forward_callback(), get_dispsocket(), get_view_querysource_dispatch(), got_transfer_quota(), internal_connect(), listener_bind(), log_formerr(), log_invalid(), log_lame(), log_nsid(), logfmtpacket(), next_master(), next_server(), notify_done(), notify_send_toaddr(), ns_add_reserved_dispatch(), ns_client_name(), ns_controls_configure(), ns_lwresd_configure(), ns_statschannels_configure(), parse_config(), printmessage(), purge_old_interfaces(), received(), recv_done(), refresh_callback(), request_log(), resquery_response(), rndc_connected(), rndc_startconnect(), send_update(), show_settings(), shutdown_listener(), socket_log(), stub_callback(), tcp_length_done(), tcp_recv(), xfrin_connect_done(), and xfrin_logv().

isc_boolean_t isc_sockaddr_ismulticast ( const isc_sockaddr_t sa  ) 

Returns ISC_TRUE if the address is a multicast address.

Definition at line 441 of file sockaddr.c.

References AF_INET6, ISC_FALSE, isc_netaddr_fromsockaddr(), isc_netaddr_ismulticast(), isc_sockaddr::sa, and isc_sockaddr::type.

Referenced by possibly_mark(), and recv_done().

isc_boolean_t isc_sockaddr_isexperimental ( const isc_sockaddr_t sa  ) 

Definition at line 453 of file sockaddr.c.

References ISC_FALSE, isc_netaddr_fromsockaddr(), isc_netaddr_isexperimental(), isc_sockaddr::sa, and isc_sockaddr::type.

Referenced by possibly_mark().

isc_boolean_t isc_sockaddr_islinklocal ( const isc_sockaddr_t sa  ) 

Returns ISC_TRUE if the address is a link local address.

Definition at line 475 of file sockaddr.c.

References AF_INET6, ISC_FALSE, isc_netaddr_fromsockaddr(), isc_netaddr_islinklocal(), isc_sockaddr::sa, and isc_sockaddr::type.

isc_boolean_t isc_sockaddr_issitelocal ( const isc_sockaddr_t sa  ) 

Returns ISC_TRUE if the address is a sitelocal address.

Definition at line 464 of file sockaddr.c.

References AF_INET6, ISC_FALSE, isc_netaddr_fromsockaddr(), isc_netaddr_issitelocal(), isc_sockaddr::sa, and isc_sockaddr::type.

isc_result_t isc_sockaddr_frompath ( isc_sockaddr_t sockaddr,
const char *  path 
)

Definition at line 486 of file sockaddr.c.

References ISC_R_NOSPACE, ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, isc_sockaddr::length, isc_sockaddr::type, and UNUSED.

Referenced by bind9_check_controls(), get_addresses(), and ns_controls_configure().


Generated on Tue Apr 28 17:41:16 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha