dpm-ctrl_main.c File Reference

Contains main entry point. More...

#include "dpm-ctrl_main.h"
#include "dpm-ctrl_config.h"
#include "dpm-ctrl_conn.h"
#include "dpm-ctrl_http.h"
#include "dpm-ctrl_dfw.h"
#include <jnx/msvcspmon_lib.h>

Go to the source code of this file.

Defines

#define DNAME_DPM_CTRL   "dpm-ctrl"
#define RETRY_FDB_ATTACH_INTERVAL   5
#define WAIT_FOR_DFW_INTERVAL   1
#define DPM_CTRL_HB_INTERVAL   3
#define DPM_CTRL_SICK_INTERVALS   3
#define DPM_CTRL_HM_IDENTIFIER   "sync-dpm-ctrl"

Functions

static void dpm_quit (int signo __unused)
static void retry_attach_fdb (evContext ctx, void *uap __unused, struct timespec due __unused, struct timespec inter __unused)
static void wait_for_dfw (evContext ctx, void *uap __unused, struct timespec due __unused, struct timespec inter __unused)
static void send_hb (evContext ctx __unused, void *uap __unused, struct timespec due __unused, struct timespec inter __unused)
static void heartbeat_setup_status (msvcspmon_hb_setup_status_t status)
static void hm_connection_status (msvcspmon_connection_status_t status)
static int dpm_init (evContext ctx)
int main (int32_t argc, char **argv)

Variables

msp_fdb_handle_t fdb_handle
 handle for FDB (forwarding DB)
int http_cpu_num
 CPU setup for use of HTTP server.
static evContext ev_ctx
 event context saved for when unavailable
static evTimerID retry_timer
 timer set to do fdb attach retry
static evTimerID wait_timer
 timer set to wait for DFW connection
static evTimerID hb_timer
 timer set to perform heartbeats
static struct msvcspmon_client_info * mci
 handle for msvcspmon API


Detailed Description

Contains main entry point.

Contains the main entry point and registers the application as a MSP daemon

Definition in file dpm-ctrl_main.c.


Define Documentation

#define DNAME_DPM_CTRL   "dpm-ctrl"

Constant string for the daemon name

Definition at line 428 of file dpm-ctrl_main.c.

Referenced by main().

#define DPM_CTRL_HB_INTERVAL   3

Normal interval for heartbeat monitoring signals

Definition at line 444 of file dpm-ctrl_main.c.

Referenced by heartbeat_setup_status(), and hm_connection_status().

#define DPM_CTRL_HM_IDENTIFIER   "sync-dpm-ctrl"

Heartbeat monitoring identifier. This SHOULD be prefixed with the assigned provider prefix.

Definition at line 458 of file dpm-ctrl_main.c.

Referenced by hm_connection_status().

#define DPM_CTRL_SICK_INTERVALS   3

If we miss this many heartbeat, we're "sick", so let the health monitoring infrastructure take care of us (will probably restart the process and log it)

Definition at line 451 of file dpm-ctrl_main.c.

Referenced by hm_connection_status().

#define RETRY_FDB_ATTACH_INTERVAL   5

Retry interval (every 5 seconds) for FDB attachment until it succeeds

Definition at line 433 of file dpm-ctrl_main.c.

Referenced by dpm_init().

#define WAIT_FOR_DFW_INTERVAL   1

Wait for DFW interval. Shouldn't be long, so 1 second is fine

Definition at line 438 of file dpm-ctrl_main.c.

Referenced by dpm_init().


Function Documentation

static int dpm_init ( evContext  ctx  )  [static]

Callback for the first initialization of the MP-SDK Application

Parameters:
[in] ctx Newly created event context
Returns:
SUCCESS (0) upon successful completion; EFAIL otherwise (exits)

Definition at line 700 of file dpm-ctrl_main.c.

References dfw_ready(), dpm_quit(), ev_ctx, fdb_handle, hm_connection_status(), http_cpu_num, init_configuration(), init_connections(), init_dfw(), init_http_server(), LOG, mci, retry_attach_fdb(), RETRY_FDB_ATTACH_INTERVAL, retry_timer, wait_for_dfw(), WAIT_FOR_DFW_INTERVAL, and wait_timer.

Referenced by main().

static void dpm_quit ( int signo  __unused  )  [static]

This function quits the application does an exit

Definition at line 479 of file dpm-ctrl_main.c.

References clear_configuration(), close_connections(), fdb_handle, LOG, mci, shutdown_dfw(), and shutdown_http_server().

Referenced by dpm_init(), and wait_for_dfw().

static void heartbeat_setup_status ( msvcspmon_hb_setup_status_t  status  )  [static]

Heartbeat setup status callback

Definition at line 623 of file dpm-ctrl_main.c.

References DPM_CTRL_HB_INTERVAL, ev_ctx, hb_timer, LOG, mci, and send_hb().

Referenced by hm_connection_status().

static void hm_connection_status ( msvcspmon_connection_status_t  status  )  [static]

Health monitor connection status callback

Parameters:
[in] status The status of the connection to pmon on the RE

Definition at line 656 of file dpm-ctrl_main.c.

References DPM_CTRL_HB_INTERVAL, DPM_CTRL_HM_IDENTIFIER, DPM_CTRL_SICK_INTERVALS, heartbeat_setup_status(), LOG, and mci.

Referenced by dpm_init().

int main ( int32_t  argc,
char **  argv 
)

Intialize dpm's environment

Parameters:
[in] argc Number of command line arguments
[in] argv String array of command line arguments
Returns:
0 upon successful exit of the application (shouldn't happen) or 1 upon failure

Definition at line 836 of file dpm-ctrl_main.c.

References DNAME_DPM_CTRL, and dpm_init().

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

Callback to periodically retry attaching to FDB. It stops being called once successfully attached.

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 523 of file dpm-ctrl_main.c.

References fdb_handle, init_http_server(), LOG, retry_timer, and wait_timer.

Referenced by dpm_init().

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

Callback to periodically send heartbeats

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 610 of file dpm-ctrl_main.c.

References mci.

Referenced by heartbeat_setup_status().

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

Callback to periodically wait until DFW module is ready. It stops being called once it is ready.

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 567 of file dpm-ctrl_main.c.

References dfw_ready(), dpm_quit(), init_connections(), init_http_server(), LOG, retry_timer, and wait_timer.

Referenced by dpm_init().


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:26:54 2010 for SDK Your Net Corporation Dynamic Policy Manager Example: dpm-ctrl 1.0 by Doxygen 1.5.1