The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
proto_ldap_sync_ldap.h File Reference
#include "proto_ldap_sync.h"
#include <lber.h>
+ Include dependency graph for proto_ldap_sync_ldap.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  proto_ldap_sync_ldap_t
 
struct  proto_ldap_sync_ldap_thread_t
 
struct  sync_packet_ctx_s
 Tracking structure for ldap sync packets. More...
 
struct  sync_state_s
 State of an individual sync. More...
 

Macros

#define SYNC_UUID_LENGTH   16
 

Typedefs

typedef struct sync_packet_ctx_s sync_packet_ctx_t
 
typedef struct sync_state_s sync_state_t
 

Enumerations

enum  sync_packet_status_t {
  SYNC_PACKET_PENDING = 0 ,
  SYNC_PACKET_PREPARING ,
  SYNC_PACKET_PROCESSING ,
  SYNC_PACKET_COMPLETE
}
 
enum  sync_packet_type_t {
  SYNC_PACKET_TYPE_CHANGE = 0 ,
  SYNC_PACKET_TYPE_COOKIE
}
 
enum  sync_phases_t {
  SYNC_PHASE_INIT = 0 ,
  SYNC_PHASE_PRESENT = 1 ,
  SYNC_PHASE_DELETE = 2 ,
  SYNC_PHASE_DONE = 3
}
 Phases of the initial refresh stage for RFC 4533 servers. More...
 

Functions

void ldap_sync_cookie_event (fr_event_list_t *el, fr_time_t now, void *uctx)
 
int ldap_sync_cookie_send (sync_packet_ctx_t *sync_packet_ctx)
 Enqueue a new cookie store packet. More...
 
int ldap_sync_cookie_store (sync_state_t *sync, bool refresh)
 Add a new cookie packet ctx to the pending list. More...
 
int ldap_sync_entry_send (sync_state_t *sync, uint8_t const uuid[SYNC_UUID_LENGTH], struct berval *orig_dn, LDAPMessage *msg, sync_op_t op)
 Enqueue a new entry change packet. More...
 
sync_state_tsync_state_alloc (TALLOC_CTX *ctx, fr_ldap_connection_t *conn, proto_ldap_sync_t const *inst, size_t sync_no, sync_config_t const *config)
 Allocate a sync state. More...
 
int8_t sync_state_cmp (void const *one, void const *two)
 Compare two sync state structures on msgid. More...
 

Variables

static fr_table_num_sorted_t const sync_ldap_msg_table []
 Types of LDAP messages relevant to LDAP sync. More...
 
static size_t const sync_ldap_msg_table_len = NUM_ELEMENTS(sync_ldap_msg_table)
 
fr_table_num_sorted_t const sync_op_table []
 Operations performed on entries. More...
 
size_t sync_op_table_len
 

Data Structure Documentation

◆ proto_ldap_sync_ldap_t

struct proto_ldap_sync_ldap_t

Definition at line 90 of file proto_ldap_sync_ldap.h.

+ Collaboration diagram for proto_ldap_sync_ldap_t:
Data Fields
CONF_SECTION * cs our configuration
fr_ldap_config_t handle_config Connection configuration instance.
uint32_t ldap_debug Debug flag for the SDK.
uint32_t max_outstanding Maximum number of outstanding packets.
proto_ldap_sync_t * parent The module that spawned us.
uint32_t recv_buff How big the kernel's receive buffer should be.
bool recv_buff_is_set Whether we were provided with a recv_buff.
char const * server Server string from the config.

LDAP sync needs to remain against a single server so this is used rather than the server_str array in fr_ldap_config_t.

char const * tls_random_file Path to the random file if /dev/random and /dev/urandom are unavailable.

◆ proto_ldap_sync_ldap_thread_t

struct proto_ldap_sync_ldap_thread_t

Definition at line 112 of file proto_ldap_sync_ldap.h.

+ Collaboration diagram for proto_ldap_sync_ldap_thread_t:
Data Fields
fr_connection_t * conn Our connection to the LDAP directory.
fr_event_timer_t const * conn_retry_ev When to retry re-establishing the conn.
fr_event_list_t * el Network side event list.
proto_ldap_sync_ldap_t const * inst instance data
fr_listen_t * li Our listener.
char const * name socket name
fr_network_t * nr Network handler.
fr_listen_t * parent master IO handler.

◆ sync_packet_ctx_s

struct sync_packet_ctx_s

Tracking structure for ldap sync packets.

Definition at line 140 of file proto_ldap_sync_ldap.h.

+ Collaboration diagram for sync_packet_ctx_s:
Data Fields
uint8_t * cookie Cookie to store - can be NULL.
fr_dlist_t entry Entry in list of pending packets.
fr_pair_list_t pairs Pairs to send with change packets.
bool refresh Does the sync require a refresh.
sync_packet_status_t status Status of this packet.
sync_state_t * sync Sync packet relates to.
sync_packet_type_t type Type of packet.

◆ sync_state_s

struct sync_state_s

State of an individual sync.

Definition at line 44 of file proto_ldap_sync_ldap.h.

+ Collaboration diagram for sync_state_s:
Data Fields
uint32_t changes_since_cookie How many changes have been added since the last cookie was stored.
sync_config_t const * config Configuration for this sync.
fr_ldap_connection_t * conn Connection the sync is running on.
uint8_t * cookie Opaque cookie, used to resume synchronisation.
fr_event_timer_t const * cookie_ev Timer event for sending cookies.
fr_dlist_head_t * filter Parsed filter to be applied on the network side before passing packets to the worker.

Predominantly to overcome Active Directory's lack of filtering in persistent searches.

proto_ldap_sync_t const * inst Module instance for this sync.
int msgid The unique identifier for this sync session.
fr_rb_node_t node Entry in the tree of nodes.
fr_dlist_head_t pending List of pending changes in progress.
uint32_t pending_cookies How many cookies are in the pending heap.
sync_phases_t phase Phase this sync is in.
fr_event_timer_t const * retry_ev Timer event for retrying failed changes.
size_t sync_no Array position of config for this sync.
fr_pair_list_t trigger_args Arguments to make available in triggers.

Macro Definition Documentation

◆ SYNC_UUID_LENGTH

#define SYNC_UUID_LENGTH   16

Definition at line 31 of file proto_ldap_sync_ldap.h.

Typedef Documentation

◆ sync_packet_ctx_t

Definition at line 88 of file proto_ldap_sync_ldap.h.

◆ sync_state_t

typedef struct sync_state_s sync_state_t

Definition at line 26 of file proto_ldap_sync_ldap.h.

Enumeration Type Documentation

◆ sync_packet_status_t

Enumerator
SYNC_PACKET_PENDING 

Packet not yet sent.

SYNC_PACKET_PREPARING 

Packet being prepared.

SYNC_PACKET_PROCESSING 

Packet sent to worker.

SYNC_PACKET_COMPLETE 

Packet response received from worker.

Definition at line 126 of file proto_ldap_sync_ldap.h.

◆ sync_packet_type_t

Enumerator
SYNC_PACKET_TYPE_CHANGE 

Packet is an entry change.

SYNC_PACKET_TYPE_COOKIE 

Definition at line 133 of file proto_ldap_sync_ldap.h.

◆ sync_phases_t

Phases of the initial refresh stage for RFC 4533 servers.

Enumerator
SYNC_PHASE_INIT 

We haven't entered any of the refresh phases.

SYNC_PHASE_PRESENT 

Currently in the present phase.

SYNC_PHASE_DELETE 

Currently in the delete phase.

SYNC_PHASE_DONE 

Refresh phase is complete.

Definition at line 35 of file proto_ldap_sync_ldap.h.

Function Documentation

◆ ldap_sync_cookie_event()

void ldap_sync_cookie_event ( fr_event_list_t el,
fr_time_t  now,
void *  uctx 
)

◆ ldap_sync_cookie_send()

int ldap_sync_cookie_send ( sync_packet_ctx_t sync_packet_ctx)

Enqueue a new cookie store packet.

Create a new internal packet containing the cookie we received from the LDAP server. This allows the administrator to store the cookie and provide it on a future call to load Cookie.

Parameters
[in]sync_packet_ctxpacket context containing the cookie to store.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 286 of file proto_ldap_sync_ldap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ldap_sync_cookie_store()

int ldap_sync_cookie_store ( sync_state_t sync,
bool  refresh 
)

Add a new cookie packet ctx to the pending list.

Does not actually send the packet.

Parameters
[in]syncthe cookie was received for.
[in]refreshthe sync after storing this cookie.
Returns
  • 0 on success.
  • -1 on failure

Definition at line 228 of file proto_ldap_sync_ldap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ldap_sync_entry_send()

int ldap_sync_entry_send ( sync_state_t sync,
uint8_t const  uuid[SYNC_UUID_LENGTH],
struct berval *  orig_dn,
LDAPMessage *  msg,
sync_op_t  op 
)

Enqueue a new entry change packet.

Parameters
[in]syncnotification has arrived for.
[in]uuidof the entry (RFC 4533 only).
[in]orig_dnoriginal DN of the entry - provided by those directories implementing persistent search, when an entry is renamed.
[in]msgcontaining the entry.
[in]opThe type of modification we need to perform to our representation of the entry.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 419 of file proto_ldap_sync_ldap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sync_state_alloc()

sync_state_t* sync_state_alloc ( TALLOC_CTX *  ctx,
fr_ldap_connection_t conn,
proto_ldap_sync_t const *  inst,
size_t  sync_no,
sync_config_t const *  config 
)

Allocate a sync state.

Parameters
[in]ctxto allocate the sync state in.
[in]connwhich the sync will run on.
[in]instmodule instance for the sync.
[in]sync_nonumber of the sync in the array of configs.
[in]configfor the sync.
Returns
new sync state.

Definition at line 188 of file proto_ldap_sync_ldap.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sync_state_cmp()

int8_t sync_state_cmp ( void const *  one,
void const *  two 
)

Compare two sync state structures on msgid.

Parameters
[in]onefirst sync to compare.
[in]twosecond sync to compare.
Returns
CMP(one, two)

Definition at line 140 of file proto_ldap_sync_ldap.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ sync_ldap_msg_table

fr_table_num_sorted_t const sync_ldap_msg_table[]
static
Initial value:
= {
{ L("intermediateResponse"), LDAP_RES_INTERMEDIATE },
{ L("searchRes"), LDAP_RES_SEARCH_RESULT },
{ L("searchResEntry"), LDAP_RES_SEARCH_ENTRY },
{ L("searchResReference"), LDAP_RES_SEARCH_REFERENCE }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207

Types of LDAP messages relevant to LDAP sync.

Definition at line 82 of file proto_ldap_sync_ldap.h.

◆ sync_ldap_msg_table_len

size_t const sync_ldap_msg_table_len = NUM_ELEMENTS(sync_ldap_msg_table)
static

Definition at line 88 of file proto_ldap_sync_ldap.h.

◆ sync_op_table

fr_table_num_sorted_t const sync_op_table[]
extern

Operations performed on entries.

Definition at line 109 of file proto_ldap_sync_ldap.c.

◆ sync_op_table_len

size_t sync_op_table_len
extern

Definition at line 115 of file proto_ldap_sync_ldap.c.