Extracting the Service Set Information

As explained earlier, your management daemon on the Routing Engine uses the kernel communication (KCOM) API to extract information about the service set from the public blob.

To register or deregister and receive public blobs of a particular type, the application calls the junos_kcom_pub_blob_req() function. It is defined as follows:

 int junos_kcom_pub_blob_req (junos_kcom_pub_blob_req_t*  req);

junos_kcom_pub_blob_req() is a single-point function for all operations related to public blobs. You can call it to do the following:

The junos_kcom_pub_blob_req_t structure contains the information required to process a public blob. It is defined as follows:

 struct junos_kcom_pub_blob_req_s {

    junos_kcom_pub_blob_req_opcode_t   opcode;            /* Operation to be performed */
    u_int16_t                          blob_id;           /* Type of public blob */
    void*                              msg_user_info;     /* Info to be passed  with the async notification */   
    junos_kcom_pub_msg_handler_ptr     msg_user_handler;  /* User handler to process the async notification */
    void*                              get_all_user_info; /* Info to be passed with the get-all handler */ 
    junos_kcom_pub_blob_handler_ptr    get_all_user_func; /* User handler to process the blob */  

} junos_kcom_pub_blob_req_t;

The operations you can request to be performed are defined in the junos_kcom_pub_blob_opcode_t enumeration:

typedef enum {

   JUNOS_KCOM_PUB_BLOB_REG,    /* Register the handler for public blob    */
   JUNOS_KCOM_PUB_BLOB_DEREG,  /* Deregister the handler for public blob  */
   JUNOS_KCOM_PUB_BLOB_GET_ALL /* Get all the blobs related to a particular blob */

} junos_kcom_pub_blob_req_opcode_t;

The junos_kcom_pub_blob_msg_t structure describes the asynchronous notification sent to the application when the data changes. It is defined as follows:

struct junos_kcom_pub_blob_msg_s {

       junos_kcom_pub_blob_msg_opcode_t   op;       /* Operation: Add/Del/Modify */
       junos_kcom_pub_blob_key_t          key;      /* Key of the public blob */
       junos_kcom_pub_blob_t              pub_blob; /* Data  */
 } junos_kcom_pub_blob_msg_t;

The sample application defines the structure jnx_flow_ssrb_node_t to represent the public blob, in the file jnx-flow-mgmt-ssrb.h:

typedef struct jnx_flow_ssrb_node_s {

    patnode     node;
    char        svc_set_name[JNX_FLOW_STR_SIZE];
    u_int16_t   svc_set_id;
    nh_idx_t    in_nh_idx;
    nh_idx_t    out_nh_idx;

}jnx_flow_ssrb_node_t;

The asynchronous handler that registers for the blob uses this structure to save the information.

The management daemon registers the asynchronous handler for notifications and calls junos_kcom_pub_blob_req() as follows, in the file jnx-flow-mgmt_kcom.c (for the basics about using the kernel configuration (GENCFG) APIs, see Using the GENCFG/SSRB Library):

int
jnx_flow_mgmt_kcom_init(evContext ctxt)
{
    int                         error;
    junos_kcom_gencfg_t         kcom_req;
    junos_kcom_pub_blob_req_t   kpb_req;

    error = junos_kcom_init(KCOM_ID_JNX_FLOW_MGMT, ctxt);

    INSIST (error == KCOM_OK);

    /* register for GENCFG events */
    memset(&kcom_req, 0, sizeof(junos_kcom_gencfg_t));
    memset(&kpb_req, 0, sizeof(junos_kcom_pub_blob_req_t));

    kcom_req.opcode       = JUNOS_KCOM_GENCFG_OPCODE_INIT;
    kcom_req.user_handler = jnx_flow_gencfg_async_handler;

    error = junos_kcom_gencfg(&kcom_req);

    INSIST (error == KCOM_OK);

    /* Register for the public blobs */
    kpb_req.opcode           = JUNOS_KCOM_PUB_BLOB_REG;
    kpb_req.blob_id          = JNX_PUB_EXT_SVC_SSR_BLOB; 
    kpb_req.msg_user_info    = NULL;
    kpb_req.msg_user_handler = jnx_flow_mgmt_pub_ssrb_async_handler;

    error = junos_kcom_pub_blob_req(&kpb_req);
        
    INSIST (error == KCOM_OK);

    /* 
     * Now request KCOM to get all the public blobs registered 
     * till now
     */
    kpb_req.opcode  = JUNOS_KCOM_PUB_BLOB_GET_ALL;
    kpb_req.blob_id = JNX_PUB_EXT_SVC_SSR_BLOB; 
    kpb_req.get_all_user_info = NULL;
    kpb_req.get_all_user_func = jnx_flow_mgmt_process_ssrb;

    error = junos_kcom_pub_blob_req(&kpb_req);

jnx_flow_mgmt_pub_ssrb_async_handler() (in file jnx-flow-mgmt_kcom.c) performs the following actions upon receiving the request to store and handle the public blob:

Once it has received a public blob and extracted the information, the handler sets up an array of jnx_flow_ssrb_node_t structures and adds the service set name, ID, and input and output interface indices to the database as follows:

case JUNOS_KCOM_PUB_BLOB_MSG_ADD:
    
      jnx_flow_log(JNX_FLOW_KCOM, LOG_INFO,"public ssrb add event <%s, %d>",
                           pub_ssrb->svc_set_name, pub_ssrb->svc_set_id);
      /* Allocate an SSRB and add it to the tree */
      if((ssrb = jnx_flow_mgmt_alloc_ssrb_node()) == NULL) {
          jnx_flow_log(JNX_FLOW_KCOM, LOG_INFO,"alloc failed");
          break;
       }


static jnx_flow_ssrb_node_t*   svc_set_id_node_map[JNX_FLOW_MAX_SVC_SETID];

...

jnx_flow_ssrb_node_t*   ssrb = NULL;

...

 memcpy (ssrb->svc_set_name, pub_ssrb->svc_set_name, 
            strlen(pub_ssrb->svc_set_name));

    ssrb->svc_set_id = pub_ssrb->svc_set_id;
    ssrb->in_nh_idx  = pub_ssrb->in_nh_idx;
    ssrb->out_nh_idx = pub_ssrb->out_nh_idx;

    patricia_node_init_length (&ssrb->node, 
                               strlen(ssrb->svc_set_name) +1);

    patricia_add(&jnx_flow_mgmt.ssrb_db, &ssrb->node);

    svc_set_id_node_map[ssrb->svc_set_id] = ssrb;

Retrieving the Service Set Information on the PIC


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:47 2010 for Juniper Networks Partner Solution Development Platform JUNOS SDK 10.2R1 by Doxygen 1.4.5