msp_init.h File Reference

Defines the functions and external data structures for initialization of Multiservices PIC applications. More...


Typedefs

typedef int(* msp_app_cb_init_t )(evContext)
 Callback for application initialization.
typedef int(* msp_app_cb_cmd_line_opts_t )(char, char *)
 Callback for command-line option processing.
typedef option option_t
 Command-line option entry.
typedef void * mp_sdk_app_ctx_t
 Multiservices PIC application context.

Functions

int msp_app_init (mp_sdk_app_ctx_t ctx)
 Initializes the Multiservices PIC SDK application's environment.
mp_sdk_app_ctx_t msp_create_app_ctx (int argc, char **argv, const char *daemon_name)
 Creates an application context object.
int msp_destroy_app_ctx (mp_sdk_app_ctx_t app_ctx)
 Destroys an application context object.
int msp_set_app_cb_cmd_line_opts (mp_sdk_app_ctx_t app_ctx, msp_app_cb_cmd_line_opts_t cmd_line_proc)
 Sets a function to be used as a callback for command-line option processing.
int msp_set_app_cb_init (mp_sdk_app_ctx_t ctx, msp_app_cb_init_t app_init)
 Sets a function to be used as a callback for application-specific initialization.
void msp_sig_register (int32_t signo, void(*sig_handler)(int))
 Registers a signal handler.
int msp_reg_cmd_line_opts (mp_sdk_app_ctx_t app_ctx, const option_t *longopts)
 Registers the command-line options in which the application is interested.
int msp_daemon_init (int argc, char **argv, int(*daemon_init)(evContext), const char *daemon_name, int create_event_loop)
 Initializes the Multiservices PIC SDK application's environment.


Detailed Description

Defines the functions and external data structures for initialization of Multiservices PIC applications.

This file must be included in any implementation of the Multiservices PIC SDK library.


Function Documentation

int msp_app_init mp_sdk_app_ctx_t  ctx  ) 
 

Initializes the Multiservices PIC SDK application's environment.

The msp_app_init() function provides an environment required for a JUNOS daemon running on Multiservices PICs.

Called directly from main(), msp_app_init() performs initialization operations required of all daemons within the Multiservices PIC SDK.

Afterwards, it calls the function supplied by the cb_init function pointer to perform any additional initialization needed by the daemon.

Finally, the process is converted into a daemon and enters the ISC event loop if create_event_loop is TRUE.

Tracing is not set up by default and daemons have to use the trace function from libjuniper explicitly.

Parameters:
[in] ctx Pointer to the application context object returned by msp_create_app_ctx().
Returns:
No return on success; otherwise -1.

mp_sdk_app_ctx_t msp_create_app_ctx int  argc,
char **  argv,
const char *  daemon_name
 

Creates an application context object.

This function is the first call that should be made by an application/daemon. It creates an application context object which will be used to store all information related to an application or daemon.

Parameters:
[in] argc Number of arguments passed to main().
[in] argv Pointer to array of argument values (also passed to main()).
[in] daemon_name Name of application as a string in quotation marks.
Returns:
Pointer to a msp_app_ctx_t object on success; otherwise NULL.

int msp_daemon_init int  argc,
char **  argv,
int(*)(evContext)  daemon_init,
const char *  daemon_name,
int  create_event_loop
 

Initializes the Multiservices PIC SDK application's environment.

Note:
This API is deprecated. Please use msp_app_init() instead.
The msp_daemon_init() function provides an environment required for a JUNOS daemon running on Multiservices PICs.

Called directly from main(), msp_daemon_init() performs initialization operations required of all daemons within the Multiservices PIC SDK.

Afterwards, it calls the function supplied by daemon_init to perform any additional initialization needed by the daemon.

Finally, the process is converted into a daemon and enters the ISC event loop if create_event_loop is TRUE.

Tracing is not set up by default and daemons have to use the trace function from libjuniper explicitly.

Parameters:
[in] argc Number of arguments passed to main().
[in] argv Pointer to an array of argument values (also passed to main()).
[in] daemon_init Pointer to an application callback function that carries out initialization activities specific to the application. If the application needs to open any sockets, register for routing socket notifications, etc., these tasks should be done within this function. Context passed to daemon_init should not be used if create_event_loop is set to FALSE.
Optional: NULL may be specified.
[in] daemon_name Name of application, as a string in quotation marks.
[in] create_event_loop An event loop for the daemon is only created if this flag is set. This flag will be set to TRUE for daemons running on control cores and FALSE for daemons running on data cores.
Returns:
0 on success; otherwise -1.

int msp_destroy_app_ctx mp_sdk_app_ctx_t  app_ctx  ) 
 

Destroys an application context object.

This function should be called to free up memory allocated by msp_create_app_ctx() when it is no longer needed.

Parameters:
[in] app_ctx Pointer to the application context object returned by msp_create_app_ctx().
Returns:
Always returns 0.

int msp_reg_cmd_line_opts mp_sdk_app_ctx_t  app_ctx,
const option_t longopts
 

Registers the command-line options in which the application is interested.

Parameters:
[in] app_ctx Pointer to the application context object returned by msp_create_app_ctx().
[in] longopts An arrray of command-line options in which the application is interested in parsing.
Returns:
0 indicating success; otherwise -1 indicating failure.

int msp_set_app_cb_cmd_line_opts mp_sdk_app_ctx_t  app_ctx,
msp_app_cb_cmd_line_opts_t  cmd_line_proc
 

Sets a function to be used as a callback for command-line option processing.

Parameters:
[in] app_ctx Pointer to the application context object returned by msp_create_app_ctx().
[in] cmd_line_proc Pointer to an application callback function that handles processing application command-line options.
Returns:
0 indicating success; otherwise -1 indicating failure.

int msp_set_app_cb_init mp_sdk_app_ctx_t  ctx,
msp_app_cb_init_t  app_init
 

Sets a function to be used as a callback for application-specific initialization.

The callback function supplied by app_init will be called during application startup.

Parameters:
[in] ctx Pointer to the application context object returned by msp_create_app_ctx().
[in] app_init Pointer to an application callback function that carries out initialization activities specific to the application. If the application needs to open any sockets, register for routing socket notifications, etc., these tasks should be done within this function. Context passed to app_init should not be used if create_event_loop is set to FALSE.
Optional: NULL may be specified.
Returns:
0 indicating success; otherwise -1 indicating failure.

void msp_sig_register int32_t  signo,
void(*)(int)  sig_handler
 

Registers a signal handler.

When the specified signal is received, the handler will be called as soon as possible within the process context.

Parameters:
[in] signo Signal number.
[in] sig_handler Pointer to the signal handler to be registered for this signal.


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:24:47 2010 for libmp-sdk by Doxygen 1.4.5