junos_kcom.h File Reference

Definitions for JUNOS Kernel Communication by SDK daemons. More...


Data Structures

struct  kcom_ifdev_redundancy_info_s
 Redundancy options structure associated with rms ifd. More...
struct  kcom_ifdev_detail_info_entry_s
 List for detail info associated with ifd. More...
struct  kcom_ifdev_s
 Interface device (IFD) structure. More...
struct  kcom_ifl_s
 Logical interface (IFL) structure. More...
struct  kcom_iff_s
 Data structure holding information about the interface family (IFF). More...
struct  kcom_ifa_s
 Data stducture holding interface address (IFA) information. More...
struct  kcom_rtb_s
 Route table (RTB) structure. More...
struct  junos_kcom_gencfg_size_pointer_s
 Size-value structure used in the main structure above. More...
struct  junos_kcom_gencfg_peer_info_s
 Peer information used in the junos_kcom_gencfg_t data structure. More...
struct  junos_kcom_gencfg_s
 This is the main structure for the KCOM-GENCFG and SDK interface. More...
struct  junos_kcom_gencfg_dep_s
 Dependency component structure. More...

Defines

#define KCOM_OK   0
 Operation succeeded.
#define KCOM_COOKIE_FAIL   -100
 Cookie creation failed.
#define KCOM_OPEN_FAIL   -101
 Open operation failed.
#define KCOM_ERRREG_FAIL   -102
 Error registration failed.
#define KCOM_ASYNC_FAIL   -103
 Asynchronous operation failed.
#define KCOM_INVALID_OP   -104
 Invalid operation.
#define KCOM_INVAL_PARAM   -105
 Invalid parameters.
#define KCOM_LIB_ERR   -106
 Generic error, refer to errno for more details.
#define KCOM_ITER_END   -107
 User defined functions can use this bail out of kcom get all functions.
#define KCOM_IGNORE_HANDLER   -108
 Used to inform that call back handler.
#define KCOM_ADD   1
 Add something or something added.
#define KCOM_CHANGE   2
 Change something which exists.
#define KCOM_DELETE   3
 Delete something.
#define KCOM_GET   4
 Get a thing (described by message).
#define KCOM_IFNAMELEN   60
#define KCOM_MAX_PREFIX_LEN   20
 Maximum prefix length.
#define KCOM_IFDEV_REDUNDANCY_STATE_WAITING_FOR_PRIMARY   (1 << 0)
 Rms is waiting for primary ms-a/b/c to come up.
#define KCOM_IFDEV_REDUNDANCY_STATE_PRIMARY_ACTIVE   (1 << 1)
 Primary ms-a/b/c is active.
#define KCOM_IFDEV_REDUNDANCY_STATE_SECONDARY_ACTIVE   (1 << 2)
 Secondary ms-x/y/z is active.
#define KCOM_IFDEV_REDUNDANCY_STATE_NONE_ACTIVE   (1 << 3)
 Both primary and secondday ar down.
#define KCOM_IFDEV_REDUNDANCY_CMD_NONE   0
 Default cmd (No command executed from cli to swtich/revert.
#define KCOM_IFDEV_REDUNDANCY_CMD_SWITCH   1
 Switch to secondary ms-x/y/z.
#define KCOM_IFDEV_REDUNDANCY_CMD_REVERT   2
 Revert to primary ms-a/b/c.
#define KCOM_IFDEV_REDUNDANCY_N_CMDS   3
#define KCOM_IFDEV_REDUNDANCY_INFO   (1 << 0)
 Flag for redundancy options.
#define KCOM_RTBNAMELEN   128
#define JUNOS_KCOM_GENCFG_VERSION   1
 Version of the junos_kcom_gencfg_t data structure.
#define JUNOS_KCOM_GENCFG_INIT(_data)
 Macro to initialize junos_kcom_gencfg_t data structure.
#define JUNOS_KCOM_GENCFG_KEY_MAX   32
 Maximum kcom gencfg key size.
#define JUNOS_KCOM_BLOB_ID_MAX   0x3f
 Maximum kcom gencfg blob ID.

Typedefs

typedef kcom_ifdev_redundancy_info_s kcom_ifdev_redundancy_info_t
 Redundancy options structure associated with rms ifd.
typedef kcom_ifdev_detail_info_entry_s kcom_ifdev_detail_info_entry_t
 List for detail info associated with ifd.
typedef kcom_ifdev_s kcom_ifdev_t
 Interface device (IFD) structure.
typedef kcom_ifl_s kcom_ifl_t
 Logical interface (IFL) structure.
typedef kcom_iff_s kcom_iff_t
 Data structure holding information about the interface family (IFF).
typedef kcom_ifa_s kcom_ifa_t
 Data stducture holding interface address (IFA) information.
typedef kcom_rtb_s kcom_rtb_t
 Route table (RTB) structure.
typedef enum junos_kcom_gencfg_opcode_e junos_kcom_gencfg_opcode_t
 Operation codes convey all requests in the single-interface approach and for asynchronous messages in both cases.
typedef junos_kcom_gencfg_size_pointer_s junos_kcom_gencfg_szptr_t
 Size-value structure used in the main structure above.
typedef enum junos_kcom_gencfg_dest_e junos_kcom_gencfg_dest_t
 Gencfg blob destination flag.
typedef junos_kcom_gencfg_peer_info_s junos_kcom_gencfg_peer_info_t
 Peer information used in the junos_kcom_gencfg_t data structure.
typedef junos_kcom_gencfg_s junos_kcom_gencfg_t
 This is the main structure for the KCOM-GENCFG and SDK interface.
typedef junos_kcom_gencfg_dep_s junos_kcom_gencfg_dep_t
 Dependency component structure.
typedef int(* kcom_ifd_handler_ptr )(kcom_ifdev_t *, void *)
 kcom_ifd_handler is a user-supplied function called when retrieving device information.
typedef int(* kcom_ifl_handler_ptr )(kcom_ifl_t *, void *)
 kcom_ifl_handler_ptr is a user-supplied function called when retrieving logical interface information.
typedef int(* kcom_iff_handler_ptr )(kcom_iff_t *, void *)
 kcom_iff_handler_ptr is a user-supplied function called when retrieving interface family information.
typedef int(* kcom_ifa_handler_ptr )(kcom_ifa_t *, void *)
 kcom_ifa_handler_ptr is a user-supplied function called when retrieving interface address information.
typedef int(* kcom_rtb_handler_ptr )(kcom_rtb_t *, void *)
 kcom_route_table_handler_ptr is a user-supplied function called when retrieving route table information.

Enumerations

enum  junos_kcom_gencfg_opcode_e {
  JUNOS_KCOM_GENCFG_OPCODE_MIN, JUNOS_KCOM_GENCFG_OPCODE_INIT, JUNOS_KCOM_GENCFG_OPCODE_BLOB_ADD, JUNOS_KCOM_GENCFG_OPCODE_BLOB_DEL,
  JUNOS_KCOM_GENCFG_OPCODE_BLOB_GET, JUNOS_KCOM_GENCFG_OPCODE_BLOB_GETNEXT, JUNOS_KCOM_GENCFG_OPCODE_FILTER_ADD, JUNOS_KCOM_GENCFG_OPCODE_FILTER_DEL,
  JUNOS_KCOM_GENCFG_OPCODE_GET_FREE, JUNOS_KCOM_GENCFG_OPCODE_MAX, JUNOS_KCOM_GENCFG_OPCODE_BLOB_CHG, JUNOS_KCOM_GENCFG_OPCODE_ALL
}
 Operation codes convey all requests in the single-interface approach and for asynchronous messages in both cases. More...
enum  junos_kcom_gencfg_dest_e { JUNOS_KCOM_GENCFG_DEST_RE_LOCAL_ONLY, JUNOS_KCOM_GENCFG_DEST_RE_AND_PFE }
 Gencfg blob destination flag. More...

Functions

int junos_kcom_init (u_int8_t sender_id, evContext context)
 Initializes the JUNOS Kernel Communication Subsystem.
int junos_kcom_shutdown (void)
 Closes the JUNOS Kernel Communication Library.
void junos_kcom_msg_free (void *msg)
 Deallocates the message buffer msg.
int junos_kcom_ifd_get_all (kcom_ifd_handler_ptr func, const char *prefix, void *user_info)
 Extracts the IFDs present in the system with the given prefix.
int junos_kcom_ifd_get_by_index (u_int16_t idx, kcom_ifdev_t *ifd)
 Retrieves device information based on the interface index.
int junos_kcom_ifd_get_by_snmp_index (ifl_idx_t snmp_index, kcom_ifdev_t *ifd)
 Retrieves device information based on the SNMP index.
int junos_kcom_ifd_get_by_name (const char *name, kcom_ifdev_t *ifd)
 Retrieves device information based on the name.
int junos_kcom_register_ifd_handler (void *user_info, kcom_ifd_handler_ptr user_handler)
 Registers a callback handler for device information.
int junos_kcom_ifd_down (kcom_ifdev_t *ifdev)
 Checks for the down status of the interface.
int junos_kcom_ifd_set_detail_info_flags (uint32_t ifd_detail_info_flags)
 Sets the detail information flag associated with ifd.
int junos_kcom_ifd_clear_detail_info_flags (uint32_t ifd_detail_info_flags)
 Clears the detail information flags associated with ifd.
bool junos_kcom_ifd_is_detail_info_flag_set (uint32_t ifd_detail_info_flags)
 Checks if the detail information flag associated with ifd is set.
const void * junos_kcom_ifd_retrieve_detail_info (kcom_ifdev_detail_info_list_t *ifd_detail_list, uint32_t ifd_detail_flags)
 Retrieves the detail info associated with ifd.
const kcom_ifdev_redundancy_info_tjunos_kcom_ifd_retrieve_redundancy_info (kcom_ifdev_detail_info_list_t *ifd_detail_list)
 Retrieves redundancy info associated with ifd.
int junos_kcom_ifd_detail_info_free (kcom_ifdev_detail_info_list_t *ifd_detail, uint32_t ifd_detail_flags)
 Free the ifd detail info entries.
int junos_kcom_ifl_get_all (kcom_ifl_handler_ptr func, char *prefix, void *user_info)
 Extracts all IFLs having a given prefix.
int junos_kcom_ifl_get_by_index (ifl_idx_t idx, kcom_ifl_t *ifl)
 Retrieves logical interface information based on index.
int junos_kcom_ifl_get_by_snmp_index (ifl_idx_t snmp_index, kcom_ifl_t *ifl)
 Retrieves logical interface information based on the SNMP index.
int junos_kcom_ifl_get_by_name (char *name, if_subunit_t subunit, kcom_ifl_t *ifl)
 Retrieves logical interface information based on the name.
int junos_kcom_register_ifl_handler (void *user_info, kcom_ifl_handler_ptr user_handler)
 Registers a handler for interface information.
int junos_kcom_ifl_down (kcom_ifl_t *ifl)
 Checks for the down status of the interface.
int junos_kcom_iff_get_all (kcom_iff_handler_ptr func, ifl_idx_t idx, void *user_info)
 Retrieves all address families for the given interface.
int junos_kcom_iff_get_by_index (ifl_idx_t idx, u_int8_t af, kcom_iff_t *iff)
 Retrieve address family information based on IFL index.
int junos_kcom_iff_get_by_dev_name (const char *ifd_name, if_subunit_t subunit, u_int8_t af, kcom_iff_t *iff)
 Retrieves address family information based on IFD name, family, and sub-unit.
int junos_kcom_register_iff_handler (void *user_info, kcom_iff_handler_ptr user_handler)
 Registers a user-supplied handler for address family information.
int junos_kcom_iff_down (kcom_iff_t *iff)
 Checks for the down status of the family.
int junos_kcom_iff_isprimary (kcom_iff_t *iff)
 Checks if the IFF is currently primary for protocol.
int junos_kcom_iff_primary (kcom_iff_t *iff)
 Checks if the IFF can be primary for protocol.
int junos_kcom_ifa_get_all (kcom_ifa_handler_ptr func, ifl_idx_t idx, u_int8_t af, void *user_info)
 Retrieves all IFAs for the given interface.
int junos_kcom_ifa_get_first (ifl_idx_t idx, u_int8_t af, kcom_ifa_t *ifa)
 Retrieves first IFA for the given IFL index and family.
int junos_kcom_ifa_get_next (ifl_idx_t idx, u_int8_t af, u_int8_t *local, u_int16_t localplen, kcom_ifa_t *ifa)
 Retrieves next IFA for the given IFL index, local address and family.
int junos_kcom_ifa_get_by_dest (ifl_idx_t idx, u_int8_t af, u_int8_t *dest, u_int16_t destplen, kcom_ifa_t *ifa)
 Retrieves information about address based on destination prefix.
int junos_kcom_ifa_get_by_local (ifl_idx_t idx, u_int8_t af, u_int8_t *local, u_int16_t localplen, kcom_ifa_t *ifa)
 Retrieves address information based on local prefix.
int junos_kcom_register_ifa_handler (void *user_info, kcom_ifa_handler_ptr user_handler)
 Registers a user-supplied handler for address information.
int junos_kcom_ifa_down (kcom_ifa_t *ifa)
 Checks for the down status of the address.
int junos_kcom_ifa_isprimary (kcom_ifa_t *ifa)
 Checks if the IFA is the current primary address.
int junos_kcom_ifa_ispreferred (kcom_ifa_t *ifa)
 Checks if the IFA is the current preferred address to destination.
int junos_kcom_ifa_isdefault (kcom_ifa_t *ifa)
 Checks if the IFA is the current default address.
int junos_kcom_ifa_primary (kcom_ifa_t *ifa)
 Checks if the IFA can be primary address.
int junos_kcom_ifa_preferred (kcom_ifa_t *ifa)
 Checks if the IFA is the preferred address for destination.
int junos_kcom_gencfg (junos_kcom_gencfg_t *user_p)
 Main entry routine for all SDK gencfg-related user calls.
int junos_kcom_gencfg_build_blob_id (junos_kcom_gencfg_t *user_p, provider_origin_id_t origin_id, u_int16_t blob_id)
 Build a blob ID in a KCOM GENCFG request structure from an origin ID and blob ID.
int junos_kcom_gencfg_extract_blob_id (junos_kcom_gencfg_t *user_p, provider_origin_id_t *origin_id_p, u_int16_t *blob_id_p)
 Extract origin ID and blob ID from a KCOM GENCFG request structure.
int junos_kcom_rtb_get_all (kcom_rtb_handler_ptr func, u_int8_t af, void *user_info)
 Retrieves all RTBs for the given family.
int junos_kcom_register_rtb_handler (void *user_info, kcom_rtb_handler_ptr user_handler)
 Registers a handler for route table information.
int junos_kcom_rtb_deleting (kcom_rtb_t *rtb)
 Checks if the route table is being deleted.

Variables

typedef kcom_ifdev_detail_info_list_t


Detailed Description

Definitions for JUNOS Kernel Communication by SDK daemons.


Define Documentation

#define JUNOS_KCOM_GENCFG_INIT _data   ) 
 

Value:

do { \
        memset((_data), 0, sizeof(junos_kcom_gencfg_t)); \
        (_data)->ver = JUNOS_KCOM_GENCFG_VERSION; \
        (_data)->size = sizeof(junos_kcom_gencfg_t); \
    } while(0)
Macro to initialize junos_kcom_gencfg_t data structure.

This one should be called to initialize the data structure before it is used. It first set all fields to zero then setup some internal used fields.

#define JUNOS_KCOM_GENCFG_VERSION   1
 

Version of the junos_kcom_gencfg_t data structure.

If the data structure is changed in the future, please bump up the version number.

#define KCOM_IGNORE_HANDLER   -108
 

Used to inform that call back handler.

It is used internally in KCOM


Typedef Documentation

typedef struct junos_kcom_gencfg_dep_s junos_kcom_gencfg_dep_t
 

Dependency component structure.

The dep.data_p field of the junos_kcom_gencfg_dep_t structure will point to an array containing one or more (multiple dependencies) of these component field structures.

KCOM-GENCFG will only handle dependency type of IFSTATE_GENCFG, so the type field is not needed. Other KCOM components handle other IFSTATE types.

Dependencies convey, for example, the order of creation: The physical interface must be operational before logical links can be activated on it.

typedef enum junos_kcom_gencfg_dest_e junos_kcom_gencfg_dest_t
 

Gencfg blob destination flag.

This flag indicates the destination of the blob.

typedef struct junos_kcom_gencfg_peer_info_s junos_kcom_gencfg_peer_info_t
 

Peer information used in the junos_kcom_gencfg_t data structure.

For JUNOS_KCOM_GENCFG_OPCODE_BLOB_ADD and JUNOS_KCOM_GENCFG_OPCODE_BLOB_DEL, peer_name needs to be filled in. For JUNOS_KCOM_GENCFG_OPCODE_BLOB_GET and JUNOS_KCOM_GENCFG_OPCODE_BLOB_GETNEXT, peer_index and peer_class_mask will be passed out.

typedef struct junos_kcom_gencfg_s junos_kcom_gencfg_t
 

This is the main structure for the KCOM-GENCFG and SDK interface.

All required parameters are conveyed through this structure, and specific fields are mandatory for each request or notification. Non-zero length in length-pointer fields indicates field presence. The memory pointed by peer_info for JUNOS_KCOM_GENCFG_OPCODE_BLOB_GET and JUNOS_KCOM_GENCFG_OPCODE_BLOB_GETNEXT will be dynamically allocated inside of junos_kcom_gencfg () api, caller is supposed to free this memory by using opcode JUNOS_KCOM_GENCFG_OPCODE_GET_FREE.

typedef int(* kcom_ifa_handler_ptr)(kcom_ifa_t *, void *)
 

kcom_ifa_handler_ptr is a user-supplied function called when retrieving interface address information.

See also:
junos_kcom_ifa_get_all()

junos_kcom_register_ifa_handler()

typedef int(* kcom_ifd_handler_ptr)(kcom_ifdev_t *, void *)
 

kcom_ifd_handler is a user-supplied function called when retrieving device information.

See also:
junos_kcom_ifd_get_all()

junos_kcom_register_ifd_handler()

typedef int(* kcom_iff_handler_ptr)(kcom_iff_t *, void *)
 

kcom_iff_handler_ptr is a user-supplied function called when retrieving interface family information.

See also:
junos_kcom_iff_get_all()

junos_kcom_register_iff_handler()

typedef int(* kcom_ifl_handler_ptr)(kcom_ifl_t *, void *)
 

kcom_ifl_handler_ptr is a user-supplied function called when retrieving logical interface information.

See also:
junos_kcom_ifl_get_all()

junos_kcom_register_ifl_handler()

typedef int(* kcom_rtb_handler_ptr)(kcom_rtb_t *, void *)
 

kcom_route_table_handler_ptr is a user-supplied function called when retrieving route table information.

See also:
junos_kcom_rtb_get_all()

junos_kcom_register_rtb_handler()


Enumeration Type Documentation

enum junos_kcom_gencfg_dest_e
 

Gencfg blob destination flag.

This flag indicates the destination of the blob.

Enumerator:
JUNOS_KCOM_GENCFG_DEST_RE_LOCAL_ONLY  RE local only.
JUNOS_KCOM_GENCFG_DEST_RE_AND_PFE  To PFE peer as well as RE local.

enum junos_kcom_gencfg_opcode_e
 

Operation codes convey all requests in the single-interface approach and for asynchronous messages in both cases.

Enumerator:
JUNOS_KCOM_GENCFG_OPCODE_INIT  Initialize KCOM GENCFG feature.
JUNOS_KCOM_GENCFG_OPCODE_BLOB_ADD  Add user blob to kernel space.
JUNOS_KCOM_GENCFG_OPCODE_BLOB_DEL  Delete blob from kernel space.
JUNOS_KCOM_GENCFG_OPCODE_BLOB_GET  Get blob from kernel space.
JUNOS_KCOM_GENCFG_OPCODE_BLOB_GETNEXT  Get next blob in tree.
JUNOS_KCOM_GENCFG_OPCODE_FILTER_ADD  Add a filter request.
JUNOS_KCOM_GENCFG_OPCODE_FILTER_DEL  Delete an added filter.
JUNOS_KCOM_GENCFG_OPCODE_GET_FREE  Free allocated get resorces.
JUNOS_KCOM_GENCFG_OPCODE_MAX  Maximum count of requests.

Use this for any range-checking

JUNOS_KCOM_GENCFG_OPCODE_BLOB_CHG  Change async notification.


Function Documentation

int junos_kcom_gencfg junos_kcom_gencfg_t user_p  ) 
 

Main entry routine for all SDK gencfg-related user calls.

This routine dispatches to other specific handlers based on the request.

The routine performs some basic checks and actual actions in all cases. It does translations in most. Error codes are returned in all.

Note: For JUNOS_KCOM_GENCFG_OPCODE_BLOB_GET and JUNOS_KCOM_GENCFG_OPCODE_BLOB_GETNEXT, peer_info of user_p may be dynamically allocated inside the library to hold peer info. Caller needs to call this API with opcode JUNOS_KCOM_GENCFG_OPCODE_GET_FREE to free this dynamic memory.

Parameters:
[in] user_p Pointer to user request structure.
Returns:
The following return codes are possible:
  • 0 Everything OK.
  • E2BIG Holder buffer size exceeded.
  • EACCES Permission denied.
  • EEXIST Blob already in chain.
  • EFAULT Bad or mismatched address.
  • EINVAL Invalid parameter.
  • EMSGSIZE Attempt to add more than 65472 bytes with opcode JUNOS_KCOM_GENCFG_OPCODE_BLOB_ADD.
  • ENOMEM No memory left.
  • EPERM Call made in incorrect state.

int junos_kcom_gencfg_build_blob_id junos_kcom_gencfg_t user_p,
provider_origin_id_t  origin_id,
u_int16_t  blob_id
 

Build a blob ID in a KCOM GENCFG request structure from an origin ID and blob ID.

Parameters:
[in] user_p Pointer to user request structure.
[in] origin_id Origin ID
[in] blob_id GENCFG blob ID
Returns:
The following return codes are possible:
  • 0 Everything OK.
  • EINVAL Invalid parameter.

int junos_kcom_gencfg_extract_blob_id junos_kcom_gencfg_t user_p,
provider_origin_id_t *  origin_id_p,
u_int16_t *  blob_id_p
 

Extract origin ID and blob ID from a KCOM GENCFG request structure.

Parameters:
[in] user_p Pointer to user request structure.
[out] origin_id_p Pointer to location to store origin ID.
[out] blob_id_p Pointer to location to store blob ID.
Returns:
The following return codes are possible:
  • 0 Everything OK.
  • EINVAL Invalid parameter.

int junos_kcom_ifa_down kcom_ifa_t ifa  ) 
 

Checks for the down status of the address.

Parameters:
[in] ifa Address information
Returns:
1 if the interface is down; otherwise 0.

int junos_kcom_ifa_get_all kcom_ifa_handler_ptr  func,
ifl_idx_t  idx,
u_int8_t  af,
void *  user_info
 

Retrieves all IFAs for the given interface.

The user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] func User-supplied function. This function is called for each IFA found
[in] idx Interface index. the interface intex
[in] af Address family.
[in] user_info User parameter. The user_handler is called with this parameter as an argument.
Returns:
  • KCOM_INVALID_OP The Kernel Communication Library has not been initialized, or func is NULL.
  • KCOM_INVALID_PARAM The parameters to the function is not valid.
  • KCOM_LIB_ERR There was an error gettting IFA information, refer to errno.
  • KCOM_ITER_END The user handler aborted the operation.
  • KCOM_OK The operation completed without any errors.

int junos_kcom_ifa_get_by_dest ifl_idx_t  idx,
u_int8_t  af,
u_int8_t *  dest,
u_int16_t  destplen,
kcom_ifa_t ifa
 

Retrieves information about address based on destination prefix.

The caller has to provide memory for the kcom_ifa_t structure, which will contain the address.

Parameters:
[in] idx Interface ID. This is the index of the IFL in the kernel.
[in] af Address family.
[in] dest Destination address.
[in] destplen Destination Address length
[out] ifa Address information. Pointer to structure in which address information is stored.
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_ifa_get_by_local ifl_idx_t  idx,
u_int8_t  af,
u_int8_t *  local,
u_int16_t  localplen,
kcom_ifa_t ifa
 

Retrieves address information based on local prefix.

The caller has to provide memory for the kcom_ifa_t structure, which will contain the address.

Parameters:
[in] idx Interface ID. This is the index of the IFL in the kernel.
[in] af Address family.
[in] local Local address.
[in] localplen Local address length
[out] ifa Address information. Pointer to structure in which address information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_ifa_get_first ifl_idx_t  idx,
u_int8_t  af,
kcom_ifa_t ifa
 

Retrieves first IFA for the given IFL index and family.

The caller has to provide memory for the kcom_ifa_t structure, which will contain the address.

Parameters:
[in] idx Interface ID. This is the index of the IFL in the kernel.
[in] af Address family.
[out] ifa Address information. Pointer to structure in which address information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_ifa_get_next ifl_idx_t  idx,
u_int8_t  af,
u_int8_t *  local,
u_int16_t  localplen,
kcom_ifa_t ifa
 

Retrieves next IFA for the given IFL index, local address and family.

The caller has to provide memory for the kcom_ifa_t structure, which will contain the address.

Parameters:
[in] idx Interface ID. This is the index of the IFL in the kernel.
[in] af Address family.
[in] local Local Address.
[in] localplen Local Address length
[out] ifa Address information. Pointer to structure in which address information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_ifa_isdefault kcom_ifa_t ifa  ) 
 

Checks if the IFA is the current default address.

Parameters:
[in] ifa Address information
Returns:
1 if true; otherwise 0.

int junos_kcom_ifa_ispreferred kcom_ifa_t ifa  ) 
 

Checks if the IFA is the current preferred address to destination.

Parameters:
[in] ifa Address information
Returns:
1 if true; otherwise 0.

int junos_kcom_ifa_isprimary kcom_ifa_t ifa  ) 
 

Checks if the IFA is the current primary address.

Parameters:
[in] ifa Address information
Returns:
1 if true; otherwise 0.

int junos_kcom_ifa_preferred kcom_ifa_t ifa  ) 
 

Checks if the IFA is the preferred address for destination.

Parameters:
[in] ifa Address information
Returns:
1 if true; otherwise 0.

int junos_kcom_ifa_primary kcom_ifa_t ifa  ) 
 

Checks if the IFA can be primary address.

Parameters:
[in] ifa Address information
Returns:
1 if true; otherwise 0.

int junos_kcom_ifd_clear_detail_info_flags uint32_t  ifd_detail_info_flags  ) 
 

Clears the detail information flags associated with ifd.

This function is used to clear the ifd detail info flags. The flags supported are defined in this file, should use combination of one or more of these flags. Currently KCOM_IFDEV_REDUNDANCY_INFO is the only flag supported.

Parameters:
[in] ifd_detail_info_flags 32-bit bitmap indicating the interest in detail info of ifd.
Returns:
KCOM_OK if successful, KCOM_COOKIE_FAIL in case of error.

int junos_kcom_ifd_detail_info_free kcom_ifdev_detail_info_list_t *  ifd_detail,
uint32_t  ifd_detail_flags
 

Free the ifd detail info entries.

This function is used to free the memory allocated to detail info structures in library.

Parameters:
[in] ifd_detail_list Pointer to ifd's detail info list
[in] ifd_detail_info_flags 32-bit bitmap indicating the interest in detail info of ifd.
Returns:
  • KCOM_OK if successful
  • KCOM_INVAL_PARAM in case of failure

int junos_kcom_ifd_down kcom_ifdev_t ifdev  ) 
 

Checks for the down status of the interface.

Parameters:
[in] ifdev Device Information
Returns:
1 if the interface is down; otherwise 0.

int junos_kcom_ifd_get_all kcom_ifd_handler_ptr  func,
const char *  prefix,
void *  user_info
 

Extracts the IFDs present in the system with the given prefix.

A user-supplied function is called for each device retrieved. The user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] func User-supplied callback function of type kcom_ifd_handler_ptr. This function is called for every device found
[in] prefix Prefix info. The prefix of the IFD, if prefix is NULL, extract all IFDs
[in] user_info User parameter. The callback func is called with this parameter.
Returns:
The possible return values are:
  • KCOM_INVALID_OP The Kernel Communication Library has not been initialized, or func is NULL.
  • KCOM_LIB_ERR There was an error gettting device information, refer to errno.
  • KCOM_ITER_END The user handler aborted the get all operation.
  • KCOM_OK The operation completed without any errors.

int junos_kcom_ifd_get_by_index u_int16_t  idx,
kcom_ifdev_t ifd
 

Retrieves device information based on the interface index.

The caller has to provide memory for the kcom_ifdev_t structure which will contain the device information.

Parameters:
[in] idx Device ID. This is the index of the device in the kernel.
[out] ifd Device information. Pointer to structure in which device information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_ifd_get_by_name const char *  name,
kcom_ifdev_t ifd
 

Retrieves device information based on the name.

The caller has to provide memory for the kcom_ifdev_t structure which will contain the device information.

Parameters:
[in] name Device name.
[out] ifd Device information. Pointer to structure in which device information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_ifd_get_by_snmp_index ifl_idx_t  snmp_index,
kcom_ifdev_t ifd
 

Retrieves device information based on the SNMP index.

The caller has to provide memory for the kcom_ifdev_t structure which will contain the device information.

Parameters:
[in] snmp_index SNMP Device ID. This is the SNMP index of the device.
[out] ifd Device information. Pointer to structure in which device information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

bool junos_kcom_ifd_is_detail_info_flag_set uint32_t  ifd_detail_info_flags  ) 
 

Checks if the detail information flag associated with ifd is set.

This function is used to check if any of the ifd detail info flag is set.

Parameters:
[in] ifd_detail_info_flags 32-bit bitmap indicating the interest in detail info of ifd.
Returns:
true if set, false if flag is not set or no cookie present.

const void* junos_kcom_ifd_retrieve_detail_info kcom_ifdev_detail_info_list_t *  ifd_detail_list,
uint32_t  ifd_detail_flags
 

Retrieves the detail info associated with ifd.

This function is used to retrieve the detail info associated with an ifd. Pointer to ifd detail info list and the detail info flag should be passed to get the appropriate detail info structure. Only one flag needs to be set. If more detail info is needed, this function needs to be called multiple times with needed detail info flag set. NULL is returned incase there is no associated detail info with the ifd.

Parameters:
[in] ifd_detail_list Pointer to ifd's detail info list
[in] ifd_detail_info_flags 32-bit bitmap indicating the interest in detail info of ifd.
Returns:
  • void * if successful
  • NULL in case of failure

const kcom_ifdev_redundancy_info_t* junos_kcom_ifd_retrieve_redundancy_info kcom_ifdev_detail_info_list_t *  ifd_detail_list  ) 
 

Retrieves redundancy info associated with ifd.

Given the ifd detail info list, this function returns a pointer to ifd redudancy info. NULL is returned incase there is no redundancy info associated with the ifd.

Parameters:
[in] ifd_detail_list Pointer to ifd's detail info list
Returns:
  • kcom_ifdev_redundancy_info_t * if successful
  • NULL in case of failure

int junos_kcom_ifd_set_detail_info_flags uint32_t  ifd_detail_info_flags  ) 
 

Sets the detail information flag associated with ifd.

This function is used to set flags to show interest in getting the detailed info associated with ifd. The flags supported are defined in this file, should use combination of one or more of these flags. Currently KCOM_IFDEV_REDUNDANCY_INFO is the only flag supported.

Parameters:
[in] ifd_detail_info_flags 32-bit bitmap indicating the interest in detail info of ifd.
Returns:
KCOM_OK if successful, KCOM_COOKIE_FAIL in case of error.

int junos_kcom_iff_down kcom_iff_t iff  ) 
 

Checks for the down status of the family.

Parameters:
[in] iff Family information
Returns:
1 if the interface is down; otherwise 0.

int junos_kcom_iff_get_all kcom_iff_handler_ptr  func,
ifl_idx_t  idx,
void *  user_info
 

Retrieves all address families for the given interface.

Retrieves all address families for all interfaces if idx is 0. The user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] func User-supplied callback. This function is called for each IFF found
[in] idx Interface index. the interface intex.
[in] user_info User parameter. The user_handler function is called with this parameter as an argument.
Returns:
  • KCOM_INVALID_OP The Kernel Communication Library has not been initialized, or func is NULL.
  • KCOM_INVALID_PARAM The parameters to the function is not valid.
  • KCOM_LIB_ERR There was an error gettting IFF information, refer to errno.
  • KCOM_ITER_END The user handler aborted the operation.
  • KCOM_OK The operation completed without any errors.

int junos_kcom_iff_get_by_dev_name const char *  ifd_name,
if_subunit_t  subunit,
u_int8_t  af,
kcom_iff_t iff
 

Retrieves address family information based on IFD name, family, and sub-unit.

The caller has to provide memory for the kcom_iff_t structure, which will contain the address family information.

Parameters:
[in] ifd_name Name of the device.
[in] subunit Sub unit
[in] af Protocol family.
[out] iff Address family information. Pointer to structure in which address family information is stored.
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_iff_get_by_index ifl_idx_t  idx,
u_int8_t  af,
kcom_iff_t iff
 

Retrieve address family information based on IFL index.

The caller has to provide memory for the kcom_iff_t structure, which will contain the address family information.

Parameters:
[in] idx Interface ID. This is the index of the IFL in the kernel.
[in] af Protocol family.
[out] iff Address family information. Pointer to structure in which address family information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_iff_isprimary kcom_iff_t iff  ) 
 

Checks if the IFF is currently primary for protocol.

Parameters:
[in] iff Address family information
Returns:
1 if true; otherwise 0.

int junos_kcom_iff_primary kcom_iff_t iff  ) 
 

Checks if the IFF can be primary for protocol.

Parameters:
[in] iff Address family information
Returns:
1 if true, else 0.

int junos_kcom_ifl_down kcom_ifl_t ifl  ) 
 

Checks for the down status of the interface.

Parameters:
[in] ifl Interface Information.
Returns:
1 if the interface is down; otherwise 0.

int junos_kcom_ifl_get_all kcom_ifl_handler_ptr  func,
char *  prefix,
void *  user_info
 

Extracts all IFLs having a given prefix.

The user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] func User callback function. This function is called for every logical interface found
[in] prefix Prefix info. The prefix of the IFL, if prefix is NULL extract all IFLs
[in] user_info User parameter. The user_handler function is called with this parameter as an argument.
Returns:
The possible return values are
  • KCOM_INVALID_OP The Kernel Communication Library has not been initialized, or func is NULL.
  • KCOM_INVALID_PARAM The parameters to the function is not valid.
  • KCOM_LIB_ERR There was an error gettting IFL information, refer to errno.
  • KCOM_ITER_END The user handler aborted the operation.
  • KCOM_OK The operation completed without any errors.

int junos_kcom_ifl_get_by_index ifl_idx_t  idx,
kcom_ifl_t ifl
 

Retrieves logical interface information based on index.

The caller has to provide memory for the kcom_ifl_t structure which contains the device information.

Parameters:
[in] idx Interface ID. This is the index of the device in the kernel.
[out] ifl Interface information. Pointer to structure in which interface information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_ifl_get_by_name char *  name,
if_subunit_t  subunit,
kcom_ifl_t ifl
 

Retrieves logical interface information based on the name.

The caller has to provide memory for the kcom_ifl_t structure which contains the device information.

Parameters:
[in] name Interface name.
[in] subunit The subunit number.
[out] ifl Interface information. Pointer to structure in which interface information is stored
Returns:
0 indicating success; otherwise a failure code.

int junos_kcom_ifl_get_by_snmp_index ifl_idx_t  snmp_index,
kcom_ifl_t ifl
 

Retrieves logical interface information based on the SNMP index.

The caller has to provide memory for the kcom_ifl_t structure which contains the device information.

Parameters:
[in] snmp_index SNMP interface ID. This is the SNMP index of the device.
[out] ifl Interface information. Pointer to structure in which interface information is stored
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_init u_int8_t  sender_id,
evContext  context
 

Initializes the JUNOS Kernel Communication Subsystem.

This function opens and initializes a synchronous and asynchronous connection between the daemon and the kernel. It should be called once from the daemon.

Parameters:
[in] sender_id Sender ID. Used by kernel to identify communication client.
[in] context Context identifier. ISC context for async notification.
Returns:
KCOM_OK on success; otherwise, return the error code.

void junos_kcom_msg_free void *  msg  ) 
 

Deallocates the message buffer msg.

Use this function to free data that was allocated in the library.

Parameters:
[in] msg The pointer to the message buffer

int junos_kcom_register_ifa_handler void *  user_info,
kcom_ifa_handler_ptr  user_handler
 

Registers a user-supplied handler for address information.

The user-supplied function will be called when address information is added, changed, or deleted by the JUNOS kernel. This user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] user_info The user_handler function is called with this parameter as an argument.
[in] user_handler This function is called when a device is added/changed/changed by the JUNOS kernel.
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_register_ifd_handler void *  user_info,
kcom_ifd_handler_ptr  user_handler
 

Registers a callback handler for device information.

The user-supplied function provided will be called when a device is added, changed, or deleted by the JUNOS kernel. This user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] user_info The user_handler function is called with this parameter as an argument.
[in] user_handler This function is called when a device is added/changed/changed
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_register_iff_handler void *  user_info,
kcom_iff_handler_ptr  user_handler
 

Registers a user-supplied handler for address family information.

The user-supplied function will be called when the address family information is added, changed, or deleted by the JUNOS kernel. This user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] user_info The user_handler function is called with this parameter as an argument.
[in] user_handler This function is called when a device is added/changed/changed by the JUNOS kernel
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_register_ifl_handler void *  user_info,
kcom_ifl_handler_ptr  user_handler
 

Registers a handler for interface information.

The user-supplied function will be called when an interface is added, changed, or deleted by the JUNOS kernel This user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] user_info The user_handler function is called with this parameter as an argument.
[in] user_handler This function is called when a device is added/changed/changed by the JUNOS kernel
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_register_rtb_handler void *  user_info,
kcom_rtb_handler_ptr  user_handler
 

Registers a handler for route table information.

The user-supplied function will be called when a route table is added, changed, or deleted by the JUNOS kernel. This user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] user_info The user_handler function is called with this parameter as an argument.
[in] user_handler This function is called when a device is added/changed/changed by the JUNOS kernel
Returns:
KCOM_OK indicating success; otherwise a failure code.

int junos_kcom_rtb_deleting kcom_rtb_t rtb  ) 
 

Checks if the route table is being deleted.

A route table is marked as deleting before being removed. This gives an opportunity to the user daemons to remove any routes that are added to this route table.

Parameters:
[in] rtb Route table Information.
Returns:
1 if the route table is down; otherwise 0.

int junos_kcom_rtb_get_all kcom_rtb_handler_ptr  func,
u_int8_t  af,
void *  user_info
 

Retrieves all RTBs for the given family.

The user-supplied function should free the message passed to it, by calling junos_kcom_msg_free() before it returns.

Parameters:
[in] func User-supplied function. This function is called for each RTB found
[in] af Address family.
[in] user_info User parameter. The user_handler is called with this parameter as an argument.
Returns:
  • KCOM_INVALID_OP The Kernel Communication Library has not been initialized, or func is NULL.
  • KCOM_INVAL_PARAM The parameters to the function is not valid.
  • KCOM_LIB_ERR There was an error gettting RTB information, refer to errno.
  • KCOM_OK The operation completed without any errors.

int junos_kcom_shutdown void   ) 
 

Closes the JUNOS Kernel Communication Library.

This function closes the synchronous and asynchronous connection between the daemon and the kernel.

Returns:
KCOM_OK indicating success; otherwise a failure code.


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:23:49 2010 for libjunos-sdk by Doxygen 1.4.5