ped_services.c File Reference

Routines related to talking to psd. More...

#include <sync/common.h>
#include <sync/psd_ipc.h>
#include "ped_config.h"
#include "ped_services.h"
#include "ped_schedule.h"
#include "ped_logging.h"
#include "ped_ssd.h"
#include "ped_kcom.h"
#include "ped_policy_table.h"
#include "ped_snmp.h"
#include "ped_script.h"

Go to the source code of this file.


#define evInitID(id)   ((id)->opaque = NULL)
 initialize the evFileID
#define evTestID(id)   ((id).opaque != NULL)
 Test if the evFileID has been initialized.
#define BUFFER_SIZE   1024
 Send buffer size in bytes for any pipes / sockets.


static void send_psd_req (msg_type_e req_type, char *ifname, uint8_t af)
static void psd_ipc_read (evContext ctx __unused, void *param __unused, int fd __unused, int evmask __unused)
static boolean connect_psd (void)
void update_interface (char *ifname, uint32_t unit, uint8_t af, interface_op_e op)
boolean check_psd_hb (void)
void update_policies (void)
void disconnect_psd (void)
boolean psd_conn_state (void)
int get_psd_conn_time (void)


static int psd_sock = -1
 socket to psd -1 => not connected
static ipc_pipe_t * psd_pipe = NULL
 pipe to psd
static evFileID psd_read_id
 fd read ID
static boolean psd_hb = FALSE
 got heart-beat
static boolean psd_conn = FALSE
 state of PSD connection
static boolean need_policy_update = FALSE
 PSD or PED config changed.
static struct timespec psd_conn_time
 the up time of psd connection
evContext ped_ctx
 event context for ped

Detailed Description

Routines related to talking to psd.

Functions for connecting to psd and requesting policies from it

Definition in file ped_services.c.

Function Documentation

boolean check_psd_hb ( void   ) 

Check heartbeat from PSD. This function is routinely called by ped_periodic() If not received then disconnect and reconnect. This also establishes the connection when the application starts.

TRUE if a heartbeat was sent to the PSD, FALSE if the connection to the PSD is down and cannot be re-established.

Definition at line 487 of file ped_services.c.

References connect_psd(), disconnect_psd(), MSG_HB, psd_hb, and send_psd_req().

Referenced by ped_periodic().

static boolean connect_psd ( void   )  [static]

Establish a connection with the Policy Server Daemon (psd) and create/setup necessary infrastructure for communicating with it.

TRUE if the connection was successfully established, otherwise FALSE

Definition at line 317 of file ped_services.c.

References BUFFER_SIZE, disconnect_psd(), evInitID, need_policy_update, ped_ctx, psd_conn_time, PSD_CONNECT_ADDRESS, psd_ipc_read(), psd_pipe, PSD_PORT_NUM, psd_read_id, and psd_sock.

Referenced by check_psd_hb().

void disconnect_psd ( void   ) 

Disconnect the connection to the Policy Server Daemon (psd). Something's gone we'll schedule a reconnect using a heart beat failure flag (psd_hb).

Definition at line 527 of file ped_services.c.

References evInitID, evTestID, need_policy_update, ped_ctx, ped_notify_psd_state(), psd_conn, psd_hb, psd_pipe, psd_read_id, and psd_sock.

Referenced by check_psd_hb(), connect_psd(), and psd_ipc_read().

int get_psd_conn_time ( void   ) 

Get the number of seconds since that the connection to the PSD has been up

the number of seconds since that the connection to the PSD has been up

Definition at line 587 of file ped_services.c.

References psd_conn_time.

Referenced by handler_psd_time().

boolean psd_conn_state ( void   ) 

Get the state of PSD connection.

state of psd connection T=up, F=down

Definition at line 573 of file ped_services.c.

References psd_conn.

Referenced by handler_psd_state().

static void psd_ipc_read ( evContext ctx  __unused,
void *param  __unused,
int fd  __unused,
int evmask  __unused 
) [static]

Read messages from Policy Server Daemon (psd).

Definition at line 166 of file ped_services.c.

References policy_req_msg_s::af, disconnect_psd(), get_ssd_idle(), get_ssd_ready(), policy_req_msg_s::ifname, IPC_MSG_TYPE_PSD, MSG_FILTER, MSG_HB, MSG_POLICY_NA, MSG_POLICY_UPDATE, MSG_ROUTE, MSG_UPDATE_DONE, need_policy_update, ped_notify_psd_state(), policy_table_add_filter(), policy_table_add_route(), policy_table_clean(), policy_table_clear_policy(), policy_table_unverify_all(), psd_conn, psd_hb, psd_pipe, send_psd_req(), and update_all_interfaces().

Referenced by connect_psd().

static void send_psd_req ( msg_type_e  req_type,
char *  ifname,
uint8_t  af 
) [static]

Send a request to the policy server for this interface name and address family.

[in] req_type Type of message to send
[in] ifname The name of the interface for which we want to know of policies
[in] af The address family

Definition at line 90 of file ped_services.c.

References policy_req_msg_s::af, policy_req_msg_s::ifname, IPC_MSG_TYPE_PSD, MSG_HB, MSG_POLICY_REQ, MSG_UPDATE_DONE, and psd_pipe.

Referenced by check_psd_hb(), psd_ipc_read(), and update_interface().

void update_interface ( char *  ifname,
uint32_t  unit,
uint8_t  af,
interface_op_e  op 

Check interface name against the configured conditions. If it's match update this interface in the table of managed interfaces (associated policies) and if needed request a policy from the PSD.

[in] ifname interface name
[in] unit interface (IFL) unit number
[in] af address family
[in] op operation to this interface

Definition at line 438 of file ped_services.c.

References find_matching_condition(), INTERFACE_ADD, INTERFACE_DELETE, INTERFACE_REFRESH, MAX_IF_NAME_LEN, MSG_POLICY_REQ, policy_table_delete_policy(), and send_psd_req().

Referenced by iff_async_handler(), and iff_manage_handler().

void update_policies ( void   ) 

Update policies

Definition at line 514 of file ped_services.c.

References need_policy_update.

Referenced by ped_config_read(), and session_connect().

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:06 2010 for SDK Your Net Corporation Policy Manager Example: Policy Enforcement Daemon 1.0 by Doxygen 1.5.1