ped_filter.c File Reference

Works with filters. More...

#include <sync/common.h>
#include <jnx/provider_info.h>
#include <jnx/junos_dfw_api.h>
#include "ped_filter.h"
#include "ped_services.h"
#include "ped_script.h"

Go to the source code of this file.

Defines

#define INIT_FILTER_FILENAME   "ped_init_filter.xsl"
#define APPLY_FILTER_FILENAME   "ped_update_interface_filter.xsl"
#define ERR_BUF_SIZE   256

Functions

static int get_unit (char *ifname)
static void session_connect (junos_dfw_session_handle_t handle, junos_dfw_session_connect_return_t code, junos_dfw_client_id_t *client_id_list, int num_client_ids)
static void session_state_changed (junos_dfw_session_handle_t handle, junos_dfw_session_state_t state)
static void transaction_rejected (junos_dfw_session_handle_t handle, uint64_t ctx, junos_dfw_trans_reject_reason_info_t reason_info)
static void transaction_accepted (junos_dfw_session_handle_t handle, uint64_t ctx, uint32_t dfw_idx)
boolean is_pfd_filter_on (void)
void turn_on_pfd_filter (void)
void turn_off_pfd_filter (void)
int init_dfw (evContext ctx)
void shutdown_dfw (void)
boolean init_pfd_filter (char *interface_name)
boolean apply_pfd_filter_to_interface (char *interface_name)
void remove_pfd_filter_from_interface (char *interface_name)
boolean apply_filters_to_interface (char *interface_name, ped_policy_filter_t *filters)
boolean remove_filters_from_interface (char *interface_name)

Variables

static junos_dfw_session_handle_t dfw_handle
 the handle for all things DFW
static junos_dfw_client_id_t cid
 assigned ID w/ DFW
static boolean pfd_on = FALSE
 Apply the PFD filter.
static boolean ready = FALSE
 DFW is ready to use.
static junos_dfw_filter_info_t pfd_filter_info
 the pfd filter
static char * make_pfd_filter_on_int
 create(d) pfd on this interface


Detailed Description

Works with filters.

Create PFD filter and applies filters to interfaces

Prior to 10.2 All filters were created with op scripts, but in 10.2 we switched the PFD filter to work with with libdfwd to demonstrate the table redirect action.

Definition in file ped_filter.c.


Define Documentation

#define APPLY_FILTER_FILENAME   "ped_update_interface_filter.xsl"

File name of the op script to apply filters

Definition at line 47 of file ped_filter.c.

Referenced by apply_filters_to_interface(), and remove_filters_from_interface().

#define INIT_FILTER_FILENAME   "ped_init_filter.xsl"

File name of the op script to create filter and routing instance

Definition at line 42 of file ped_filter.c.

Referenced by init_pfd_filter().


Function Documentation

boolean apply_filters_to_interface ( char *  interface_name,
ped_policy_filter_t filters 
)

Apply filters on an interface

Parameters:
[in] interface_name Name of interface to apply filters on
[in] filters The filters to apply
Returns:
TRUE if successful; FALSE otherwise

Definition at line 704 of file ped_filter.c.

References APPLY_FILTER_FILENAME, exec_op_script(), ped_policy_filter_s::filter_data, get_unit(), policy_filter_msg_s::input_filter, and policy_filter_msg_s::output_filter.

Referenced by policy_table_add_filter().

boolean apply_pfd_filter_to_interface ( char *  interface_name  ) 

Apply PFD filters on an interface

Parameters:
[in] interface_name Name of interface to apply filters on
Returns:
TRUE if successful; FALSE otherwise

Definition at line 555 of file ped_filter.c.

References cid, dfw_handle, get_unit(), pfd_filter_info, pfd_on, and ready.

Referenced by policy_table_add_filter(), policy_table_add_route(), and policy_table_clean().

static int get_unit ( char *  ifname  )  [static]

Abstract unit number from interface name and get rid of the ".<unit>" on the ifname

Parameters:
[in] ifname Name of interface
Returns:
Unit number if successful; -1 otherwise

Definition at line 71 of file ped_filter.c.

Referenced by apply_filters_to_interface(), apply_pfd_filter_to_interface(), remove_filters_from_interface(), and remove_pfd_filter_from_interface().

int init_dfw ( evContext  ctx  ) 

Initialize the connection to the dfwd

Parameters:
[in] ctx event context
Returns:
0 if successful; otherwise -1 with an error message.

Definition at line 348 of file ped_filter.c.

References dfw_handle, make_pfd_filter_on_int, ready, session_connect(), session_state_changed(), transaction_accepted(), and transaction_rejected().

Referenced by ped_init().

boolean init_pfd_filter ( char *  interface_name  ) 

Create the configuration necessary for the PFD service routes to work

Parameters:
[in] interface_name Name of interface in the PFD routing instance
Returns:
TRUE if successful; FALSE otherwise

Definition at line 437 of file ped_filter.c.

References cid, dfw_handle, exec_op_script(), INIT_FILTER_FILENAME, make_pfd_filter_on_int, pfd_filter_info, and ready.

Referenced by ped_config_read().

boolean is_pfd_filter_on ( void   ) 

Is the PFD filter on

Definition at line 312 of file ped_filter.c.

References pfd_on.

Referenced by show_managed().

boolean remove_filters_from_interface ( char *  interface_name  ) 

Remove all configured filters from an interface

Parameters:
[in] interface_name Name of interface to remove filters on
Returns:
TRUE if successful; FALSE otherwise

Definition at line 774 of file ped_filter.c.

References APPLY_FILTER_FILENAME, exec_op_script(), and get_unit().

Referenced by policy_table_clean(), policy_table_clear_policy(), and policy_table_delete_policy().

void remove_pfd_filter_from_interface ( char *  interface_name  ) 

Remove PFD filter from an interface

Parameters:
[in] interface_name Name of interface to remove filters on

Definition at line 628 of file ped_filter.c.

References cid, dfw_handle, get_unit(), pfd_filter_info, pfd_on, and ready.

Referenced by policy_table_clean(), and policy_table_delete_policy().

static void session_connect ( junos_dfw_session_handle_t  handle,
junos_dfw_session_connect_return_t  code,
junos_dfw_client_id_t *  client_id_list,
int  num_client_ids 
) [static]

The connection to DFWD was accepted or has failed

Parameters:
[in] handle DFW handle
[in] code code to indicate status of connection
[in] client_id_list List of client IDs
[in] num_client_ids Number of IDs in client_id_list

Definition at line 106 of file ped_filter.c.

References cid, dfw_handle, make_pfd_filter_on_int, pfd_filter_info, ready, and update_policies().

Referenced by init_dfw().

static void session_state_changed ( junos_dfw_session_handle_t  handle,
junos_dfw_session_state_t  state 
) [static]

The connection to DFWD has gone down unexpectedly

Parameters:
[in] handle DFW handle
[in] state connection state

Definition at line 231 of file ped_filter.c.

References dfw_handle, and ready.

Referenced by init_dfw().

void shutdown_dfw ( void   ) 

Close down and free all resources

Definition at line 410 of file ped_filter.c.

References cid, dfw_handle, and ready.

static void transaction_accepted ( junos_dfw_session_handle_t  handle,
uint64_t  ctx,
uint32_t  dfw_idx 
) [static]

Report DFW transaction as accepted

Parameters:
[in] handle DFW handle
[in] ctx Transaction context
[in] reason_info The transaction index assigned by DFWD

Definition at line 293 of file ped_filter.c.

References dfw_handle.

Referenced by init_dfw().

static void transaction_rejected ( junos_dfw_session_handle_t  handle,
uint64_t  ctx,
junos_dfw_trans_reject_reason_info_t  reason_info 
) [static]

Report DFW transaction as rejected

Parameters:
[in] handle DFW handle
[in] ctx Transaction context
[in] reason_info Reason for rejection

Definition at line 264 of file ped_filter.c.

References dfw_handle.

Referenced by init_dfw().

void turn_off_pfd_filter ( void   ) 

Don't PFD filter automatically

Definition at line 332 of file ped_filter.c.

References pfd_on.

Referenced by ped_config_read().

void turn_on_pfd_filter ( void   ) 

Apply PFD filter automatically

Definition at line 322 of file ped_filter.c.

References pfd_on.

Referenced by ped_config_read().


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