passthru_main.c File Reference

Contains plug-in entry point and main handlers. More...

#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <jnx/aux_types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <jnx/logging.h>
#include <jnx/msp_trace.h>
#include <jnx/junos_kcom.h>
#include <jnx/mpsdk.h>
#include <sys/jnx/jbuf.h>
#include <jnx/msp_objcache.h>
#include <jnx/msp_policy_db.h>
#include <jnx/multi-svcs/msvcs_plugin.h>
#include <jnx/multi-svcs/msvcs_state.h>
#include <jnx/multi-svcs/msvcs_events.h>
#include <jnx/multi-svcs/msvcs_flow.h>
#include <jnx/multi-svcs/msvcs_session.h>
#include <jnx/junos_kcom_mpsdk_cfg.h>
#include <jnx/msp_pkt_utils.h>

Go to the source code of this file.

Defines

#define SESSION_BASED_MODE   1
#define PACKET_BASED_MODE   2
#define PROCESSING_MODE   SESSION_BASED_MODE
#define WITH_POLICY_DATABASE   1
#define NO_POLICY_DATABASE   2
#define CONFIG_MODE   NO_POLICY_DATABASE
#define PASSTHRU_PLUGIN_NAME   "passthru-plugin"
#define PASSTHRU_PLUGIN_ID   0
#define SESSION_DESC_LEN   (INET_ADDRSTRLEN + 4 + INET_ADDRSTRLEN + 1)
#define CLOG(_level, _fmt...)   logging((_level), "PASSTHRU PLUG-IN: " _fmt)
#define DLOG(_level, _fmt...)   msp_log((_level), "PASSTHRU PLUG-IN: " _fmt)

Functions

static status_t pullup_bytes (struct jbuf **pkt_buf, uint16_t num_bytes)
static int passthru_data_hdlr (msvcs_data_context_t *md_ctx, msvcs_data_event_t ev)
static int passthru_ctrl_hdlr (msvcs_control_context_t *mc_ctx, msvcs_control_event_t ev)
int passthru_entry (void)

Variables

const char * tcp_str = "TCP"
 TCP protocol string.
const char * udp_str = "UDP"
 UDP protocol string.
const char * icmp_str = "ICMP"
 ICMP protocol string.
const char * waiting_state = "waiting for primary"
 WAITING_FOR_PRIMARY.
const char * primary_state = "primary active"
 PRIMARY_ACTIVE.
const char * secondary_state = "secondary active"
 SECONDARY_ACTIVE.
const char * none_state = "none active"
 NONE_ACTIVE.
const char * no_op = "none"
 NONE.
const char * switch_op = "switch"
 SWITCH.
const char * revert_op = "revert"
 REVERT.
static int plugin_id
static evContext * ctx
static msp_oc_handle_t soc_handle


Detailed Description

Contains plug-in entry point and main handlers.

Definition in file passthru_main.c.


Define Documentation

#define CLOG ( _level,
_fmt...   )     logging((_level), "PASSTHRU PLUG-IN: " _fmt)

Ctrl-side logging

Definition at line 200 of file passthru_main.c.

Referenced by passthru_ctrl_hdlr(), and passthru_entry().

#define CONFIG_MODE   NO_POLICY_DATABASE

The currently active mode to compile with of the 2 above options

Definition at line 180 of file passthru_main.c.

#define DLOG ( _level,
_fmt...   )     msp_log((_level), "PASSTHRU PLUG-IN: " _fmt)

(More efficient) Data-side logging

Definition at line 206 of file passthru_main.c.

Referenced by passthru_data_hdlr(), and pullup_bytes().

#define NO_POLICY_DATABASE   2

Does not use the policy database

Definition at line 175 of file passthru_main.c.

#define PACKET_BASED_MODE   2

No sessions are created and no session context can be stored. Only makes sense when CONFIG_MODE is WITH_POLICY_DATABASE

Definition at line 160 of file passthru_main.c.

#define PASSTHRU_PLUGIN_ID   0

The per-provider plug-in id

Definition at line 190 of file passthru_main.c.

Referenced by passthru_entry().

#define PASSTHRU_PLUGIN_NAME   "passthru-plugin"

The plug-in's name

Definition at line 185 of file passthru_main.c.

Referenced by passthru_ctrl_hdlr(), passthru_data_hdlr(), and passthru_entry().

#define PROCESSING_MODE   SESSION_BASED_MODE

The currently active mode to compile with of the 2 above options

Definition at line 165 of file passthru_main.c.

#define SESSION_BASED_MODE   1

Full session affinity and session context is allowed. Also we get separate data events for the first packet and other packets. We also get session open, close, and destroy notifications

Definition at line 154 of file passthru_main.c.

#define SESSION_DESC_LEN   (INET_ADDRSTRLEN + 4 + INET_ADDRSTRLEN + 1)

Length of string for our "<src> -> <dst>" incl. NULL-byte suffix

Definition at line 195 of file passthru_main.c.

Referenced by passthru_data_hdlr().

#define WITH_POLICY_DATABASE   1

Uses the policy database

Definition at line 170 of file passthru_main.c.


Function Documentation

static int passthru_ctrl_hdlr ( msvcs_control_context_t *  mc_ctx,
msvcs_control_event_t  ev 
) [static]

Control events handler

Parameters:
[in] ctx Pointer to control context
[in] ev Control event
Returns:
Control handler status code

Definition at line 591 of file passthru_main.c.

References CLOG, ctx, no_op, none_state, PASSTHRU_PLUGIN_NAME, plugin_id, primary_state, revert_op, secondary_state, switch_op, and waiting_state.

Referenced by passthru_entry().

static int passthru_data_hdlr ( msvcs_data_context_t *  md_ctx,
msvcs_data_event_t  ev 
) [static]

Data event handler

Parameters:
[in] ctx Pointer to data context
[in] ev Data event
Returns:
Data handler status code

Definition at line 302 of file passthru_main.c.

References DLOG, icmp_str, PASSTHRU_PLUGIN_NAME, plugin_id, pullup_bytes(), SESSION_DESC_LEN, soc_handle, tcp_str, and udp_str.

Referenced by passthru_entry().

int passthru_entry ( void   ) 

The very first entry point into plug-in code called when the plug-in (shared object) is loaded by mspmand. The function name must be defined in in the entry tag of this plugin in the package's XML configuration file.

Returns:
Valid plugin ID on success, -1 on failure

Definition at line 768 of file passthru_main.c.

References CLOG, passthru_ctrl_hdlr(), passthru_data_hdlr(), PASSTHRU_PLUGIN_ID, PASSTHRU_PLUGIN_NAME, and plugin_id.

static status_t pullup_bytes ( struct jbuf **  pkt_buf,
uint16_t  num_bytes 
) [static]

Ensure or pullup enough data into the first jbuf of the chain in order to analyze it better where the bytes are contiguous

Parameters:
[in] pkt_buf The packet in jbuf format (chain of jbufs)
[in] num_bytes The number of contiguous bytes of data required in the first jbuf
Returns:
Returns the result of the jbuf_pullup on the pkt_buf upon SUCCESS; otherwise pkt_buf remains unchanged and EFAIL is returned

Definition at line 271 of file passthru_main.c.

References DLOG.

Referenced by passthru_data_hdlr().


Variable Documentation

evContext* ctx [static]

The main evContext on the ctrl side

Definition at line 237 of file passthru_main.c.

Referenced by passthru_ctrl_hdlr().

int plugin_id [static]

The id assigned by mspmand unique over all plugins

Definition at line 232 of file passthru_main.c.

Referenced by passthru_ctrl_hdlr(), passthru_data_hdlr(), and passthru_entry().

msp_oc_handle_t soc_handle [static]

Handle to alloc/free the session description OC

Definition at line 250 of file passthru_main.c.

Referenced by passthru_data_hdlr().


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:09 2010 for SDK Your Net Corporation Passthru Plug-in Example: passthru-plugin 1.0 by Doxygen 1.5.1