portlist.c File Reference

#include <config.h>
#include <stdlib.h>
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/mutex.h>
#include <isc/net.h>
#include <isc/refcount.h>
#include <isc/result.h>
#include <isc/string.h>
#include <isc/types.h>
#include <isc/util.h>
#include <dns/types.h>
#include <dns/portlist.h>

Go to the source code of this file.

Data Structures

struct  dns_element
struct  dns_portlist

Defines

#define DNS_PORTLIST_MAGIC   ISC_MAGIC('P','L','S','T')
#define DNS_VALID_PORTLIST(p)   ISC_MAGIC_VALID(p, DNS_PORTLIST_MAGIC)
#define DNS_PL_INET   0x0001
#define DNS_PL_INET6   0x0002
#define DNS_PL_ALLOCATE   16

Typedefs

typedef struct dns_element dns_element_t

Functions

static int compare (const void *arg1, const void *arg2)
isc_result_t dns_portlist_create (isc_mem_t *mctx, dns_portlist_t **portlistp)
 Create a port list.
static dns_element_tfind_port (dns_element_t *list, unsigned int len, in_port_t port)
isc_result_t dns_portlist_add (dns_portlist_t *portlist, int af, in_port_t port)
 Add the given <port,af> tuple to the portlist.
void dns_portlist_remove (dns_portlist_t *portlist, int af, in_port_t port)
 Remove the given <port,af> tuple to the portlist.
isc_boolean_t dns_portlist_match (dns_portlist_t *portlist, int af, in_port_t port)
 Find the given <port,af> tuple to the portlist.
void dns_portlist_attach (dns_portlist_t *portlist, dns_portlist_t **portlistp)
 Attach to a port list.
void dns_portlist_detach (dns_portlist_t **portlistp)
 Detach from a port list.


Detailed Description

Definition in file portlist.c.


Define Documentation

#define DNS_PORTLIST_MAGIC   ISC_MAGIC('P','L','S','T')

Definition at line 39 of file portlist.c.

Referenced by dns_portlist_create().

#define DNS_VALID_PORTLIST (  )     ISC_MAGIC_VALID(p, DNS_PORTLIST_MAGIC)

Definition at line 40 of file portlist.c.

Referenced by dns_portlist_add(), dns_portlist_attach(), dns_portlist_detach(), dns_portlist_match(), and dns_portlist_remove().

#define DNS_PL_INET   0x0001

Definition at line 57 of file portlist.c.

Referenced by dns_portlist_add(), dns_portlist_match(), and dns_portlist_remove().

#define DNS_PL_INET6   0x0002

Definition at line 58 of file portlist.c.

Referenced by dns_portlist_add(), dns_portlist_match(), and dns_portlist_remove().

#define DNS_PL_ALLOCATE   16

Definition at line 59 of file portlist.c.

Referenced by dns_portlist_add().


Typedef Documentation

typedef struct dns_element dns_element_t


Function Documentation

static int compare ( const void *  arg1,
const void *  arg2 
) [static]

Definition at line 62 of file portlist.c.

References dns_element::port.

Referenced by comparekeys(), dns_portlist_add(), dns_portlist_remove(), and sink_down().

isc_result_t dns_portlist_create ( isc_mem_t mctx,
dns_portlist_t **  portlistp 
)

Create a port list.

Requires:

Returns:

Definition at line 74 of file portlist.c.

References dns_portlist::active, dns_portlist::allocated, DESTROYLOCK, DNS_PORTLIST_MAGIC, isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_refcount_init(), dns_portlist::list, dns_portlist::lock, dns_portlist::magic, dns_portlist::mctx, dns_portlist::refcount, and REQUIRE.

static dns_element_t* find_port ( dns_element_t list,
unsigned int  len,
in_port_t  port 
) [static]

Definition at line 105 of file portlist.c.

References INSIST.

Referenced by dns_portlist_add(), dns_portlist_match(), and dns_portlist_remove().

isc_result_t dns_portlist_add ( dns_portlist_t portlist,
int  af,
in_port_t  port 
)

Add the given <port,af> tuple to the portlist.

Requires:

Returns:

Definition at line 138 of file portlist.c.

References dns_portlist::active, AF_INET6, dns_portlist::allocated, compare(), DNS_PL_ALLOCATE, DNS_PL_INET, DNS_PL_INET6, DNS_VALID_PORTLIST, find_port(), dns_element::flags, isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_portlist::list, dns_portlist::lock, LOCK, dns_portlist::mctx, dns_element::port, REQUIRE, and UNLOCK.

void dns_portlist_remove ( dns_portlist_t portlist,
int  af,
in_port_t  port 
)

Remove the given <port,af> tuple to the portlist.

Requires:

Definition at line 189 of file portlist.c.

References dns_portlist::active, AF_INET6, compare(), DNS_PL_INET, DNS_PL_INET6, DNS_VALID_PORTLIST, find_port(), dns_element::flags, dns_portlist::list, dns_portlist::lock, LOCK, REQUIRE, and UNLOCK.

isc_boolean_t dns_portlist_match ( dns_portlist_t portlist,
int  af,
in_port_t  port 
)

Find the given <port,af> tuple to the portlist.

Requires:

Returns

Definition at line 215 of file portlist.c.

References dns_portlist::active, AF_INET6, DNS_PL_INET, DNS_PL_INET6, DNS_VALID_PORTLIST, find_port(), dns_element::flags, ISC_FALSE, ISC_TRUE, dns_portlist::list, dns_portlist::lock, LOCK, REQUIRE, and UNLOCK.

void dns_portlist_attach ( dns_portlist_t portlist,
dns_portlist_t **  portlistp 
)

Attach to a port list.

Requires:

Definition at line 236 of file portlist.c.

References DNS_VALID_PORTLIST, isc_refcount_increment, dns_portlist::refcount, and REQUIRE.

void dns_portlist_detach ( dns_portlist_t **  portlistp  ) 

Detach from a port list.

Requires:

Definition at line 246 of file portlist.c.

References dns_portlist::allocated, DESTROYLOCK, DNS_VALID_PORTLIST, isc_mem_put, isc_mem_putanddetach, isc_refcount_decrement, isc_refcount_destroy, dns_portlist::list, dns_portlist::lock, dns_portlist::magic, dns_portlist::mctx, dns_portlist::refcount, and REQUIRE.


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