pfd_conn.c File Reference

Relating to managing the connections. More...

#include <string.h>
#include <pthread.h>
#include <jnx/aux_types.h>
#include <jnx/trace.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <jnx/pconn.h>
#include <sync/policy_ipc.h>
#include "pfd_conn.h"
#include "pfd_kcom.h"
#include "pfd_packet.h"
#include "pfd_main.h"
#include "pfd_logging.h"
#include "pfd_config.h"

Go to the source code of this file.

Defines

#define evInitID(id)   ((id)->opaque = NULL)
 initialize the evTimerID
#define evTestID(id)   ((id).opaque != NULL)
 Test if the evTimerID has been initialized.
#define PED_CLIENT_CONNECT_RETRIES   1
 max number of connect retries
#define CPD_CLIENT_CONNECT_RETRIES   1
 max number of connect retries
#define RETRY_CONNECT   60

Functions

static void connect_ped (evContext ctx, void *uap, struct timespec due, struct timespec inter)
static void connect_cpd (evContext ctx, void *uap, struct timespec due, struct timespec inter)
static void cpd_client_connection (pconn_client_t *session, pconn_event_t event, void *cookie UNUSED)
static status_t cpd_client_message (pconn_client_t *session, ipc_msg_t *msg, void *cookie UNUSED)
static void ped_client_connection (pconn_client_t *session, pconn_event_t event, void *cookie UNUSED)
static status_t ped_client_message (pconn_client_t *session, ipc_msg_t *msg, void *cookie UNUSED)
static void connect_cpd (evContext ctx, void *uap UNUSED, struct timespec due UNUSED, struct timespec inter UNUSED)
static void connect_ped (evContext ctx, void *uap UNUSED, struct timespec due UNUSED, struct timespec inter UNUSED)
status_t init_connections (evContext ctx)
void close_connections (void)

Variables

boolean cpd_ready
 cnx to CPD is established
static pconn_client_t * ped_client
 client cnx to management component
static pconn_client_t * cpd_client
 client cnx to control component
static evTimerID ped_timer_id
 timer ID for retrying connection to PED
static evTimerID cpd_timer_id
 timer ID for retrying connection to CPD
static pconn_peer_info_t cpd_info
 current CPD connection info
static evContext main_ctx
 event context for main thread
thread_message_t update_messages [MAX_CPUS]


Detailed Description

Relating to managing the connections.

These functions and types will manage the connections.

Definition in file pfd_conn.c.


Define Documentation

#define RETRY_CONNECT   60

Retry connecting to a component every RETRY_CONNECT if connection is lost

Definition at line 61 of file pfd_conn.c.

Referenced by cpd_client_connection(), init_connections(), ped_client_connection(), and ped_client_message().


Function Documentation

void close_connections ( void   ) 

Terminate all the connections

Definition at line 603 of file pfd_conn.c.

References cpd_client, and ped_client.

Referenced by pfd_quit(), and pfd_shutdown().

static void connect_cpd ( evContext  ctx,
void *uap  UNUSED,
struct timespec due  UNUSED,
struct timespec inter  UNUSED 
) [static]

Setup the connection to the CPD

Parameters:
[in] ctx The event context for this application
[in] uap The user data for this callback
[in] due The absolute time when the event is due (now)
[in] inter The period; when this will next be called

Definition at line 479 of file pfd_conn.c.

References cpd_client, CPD_CLIENT_CONNECT_RETRIES, cpd_client_connection(), cpd_client_message(), cpd_info, CPD_PORT_NUM, and LOG.

static void connect_cpd ( evContext  ctx,
void *  uap,
struct timespec  due,
struct timespec  inter 
) [static]

Fwd declaration of function to setup the connection to the CPD

Referenced by cpd_client_connection(), and ped_client_message().

static void connect_ped ( evContext  ctx,
void *uap  UNUSED,
struct timespec due  UNUSED,
struct timespec inter  UNUSED 
) [static]

Setup the connection to the PED

Parameters:
[in] ctx The event context for this application
[in] uap The user data for this callback
[in] due The absolute time when the event is due (now)
[in] inter The period; when this will next be called

Definition at line 531 of file pfd_conn.c.

References LOG, ped_client, PED_CLIENT_CONNECT_RETRIES, ped_client_connection(), ped_client_message(), and PED_PORT_NUM.

static void connect_ped ( evContext  ctx,
void *  uap,
struct timespec  due,
struct timespec  inter 
) [static]

Fwd declaration of function to setup the connection to the PED

Referenced by init_connections(), and ped_client_connection().

static void cpd_client_connection ( pconn_client_t *  session,
pconn_event_t  event,
void *cookie  UNUSED 
) [static]

Connection handler for new and dying connections to CPD

Parameters:
[in] session The session information for the source peer
[in] event The event (established, or shutdown are the ones we care about)
[in] cookie user data passed back

Definition at line 115 of file pfd_conn.c.

References clear_config(), connect_cpd(), cpd_client, cpd_ready, cpd_timer_id, evInitID, evTestID, get_cpd_address(), get_pfd_address(), init_packet_loops(), INSIST_ERR, LOG, main_ctx, MSG_GET_AUTH_LIST, pfd_shutdown(), and RETRY_CONNECT.

Referenced by connect_cpd().

static status_t cpd_client_message ( pconn_client_t *  session,
ipc_msg_t *  msg,
void *cookie  UNUSED 
) [static]

Message handler for open connection to CPD. We receive MSG_AUTH_ENTRY_ADD and MSG_AUTH_ENTRY_DEL messages.

Parameters:
[in] session The session information for the source peer
[in] msg The inbound message
[in] cookie The cookie we passed in
Returns:
SUCCESS if successful; otherwise EFAIL with an error message.

Definition at line 205 of file pfd_conn.c.

References add_auth_user_addr(), cpd_client, delete_auth_user_addr(), INSIST_ERR, LOG, MSG_AUTH_ENTRY_ADD, and MSG_AUTH_ENTRY_DEL.

Referenced by connect_cpd().

status_t init_connections ( evContext  ctx  ) 

Initialize the connections

Parameters:
[in] ctx event context
Returns:
SUCCESS if successful; otherwise EFAIL with an error message.

Definition at line 576 of file pfd_conn.c.

References connect_ped(), cpd_client, cpd_ready, evInitID, LOG, main_ctx, ped_client, ped_timer_id, and RETRY_CONNECT.

Referenced by pfd_init().

static void ped_client_connection ( pconn_client_t *  session,
pconn_event_t  event,
void *cookie  UNUSED 
) [static]

Connection handler for new and dying connections to the PED

Parameters:
[in] session The session information for the source peer
[in] event The event (established, or shutdown are the ones we care about)
[in] cookie user data passed back

Definition at line 256 of file pfd_conn.c.

References connect_ped(), evInitID, evTestID, ID_PFD, INSIST_ERR, LOG, main_ctx, MSG_ID, ped_client, ped_timer_id, pfd_shutdown(), and RETRY_CONNECT.

Referenced by connect_ped().

static status_t ped_client_message ( pconn_client_t *  session,
ipc_msg_t *  msg,
void *cookie  UNUSED 
) [static]

Message handler for open connection to the PED. We receive MSG_ADDRESSES, and MSG_PEER messages.

Parameters:
[in] session The session information for the source peer
[in] msg The inbound message
[in] cookie The cookie we passed in.
Returns:
SUCCESS if successful; otherwise EFAIL with an error message.

Definition at line 340 of file pfd_conn.c.

References thread_message_s::addresses, connect_cpd(), address_bundle_s::cpd_addr, cpd_client, cpd_info, cpd_ready, cpd_timer_id, evInitID, evTestID, init_packet_loops(), INSIST_ERR, LOG, main_ctx, MAX_CPUS, MSG_ADDRESSES, MSG_PEER, ped_client, address_bundle_s::pfd_addr, pfd_shutdown(), RETRY_CONNECT, set_cpd_address(), set_pfd_address(), thread_message_s::update, and update_messages.

Referenced by connect_ped().


Variable Documentation

thread_message_t update_messages[MAX_CPUS]

update messages for threads' config. Defined in the packet module

Definition at line 84 of file pfd_packet.c.

Referenced by destroy_packet_loops_config(), init_packet_loops_config(), ped_client_message(), and pfd_process_packet().


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:27:07 2010 for SDK Your Net Corporation Policy Manager Example: Packet Filtering Daemon (pfd) 1.0 by Doxygen 1.5.1