📄 ax_sa_cr.c
字号:
* Indicate how long the master agent waits before timing out registration and * open requests.* \i <descr_len>* Specify the length in bytes of a descriptive field (<descr>), which is passed * to the master agent to describe the subagent in an open request or the agent * capabilities when adding an agent capabilities.* \i <*descr>* Specify the descriptive string.* \i <*obj>* Specify the object ID to add or remove depending on the PDU type.* \ie** RETURNS: If successful, this routine returns 0. Otherwise, it returns one of * the following values:* \is* \i 'ENVOY_AX_ALLOCATION_FAILURE'* Unable to allocate an AgentX packet.* \i 'ENVOY_AX_BAD_SIZE'* Insufficient space requested.* \i 'ENVOY_AX_BAD_VALUE'* The packet was badly formed or <ebuffp> did not match its expected size.* \i 'ENVOY_AX_TOO_SMALL'* The string is either smaller than the minimum PDU size or does not match the * expected length.* \ie** ERRNO: N/A** SEE ALSO: envoy_ax_pkt_create_all(), envoy_ax_pkt_create_agent_caps(), * envoy_ax_pkt_create_close(), envoy_ax_pkt_create_ping(), * envoy_ax_pkt_create_registrations(), envoy_ax_pkt_create_variables(), * SNMP_memory_alloc(), SNMP_memory_free()*/int envoy_ax_pkt_create_open(EBUFFER_T * ebuffp, bits8_t version, bits8_t flags, bits32_t packet_id, bits8_t timeout, bits32_t descr_len, bits8_t * descr, OBJ_ID_T * obj){ENVOY_AX_PKT_T ax_pkt;envoy_ax_pkt_init(&ax_pkt);/* validity check the arguments */if ((version != ENVOY_AX_VERSION_1) || (flags & (ENVOY_AX_BIT_NEW_INDEX | ENVOY_AX_BIT_ANY_INDEX | ENVOY_AX_BIT_INSTANCE | ENVOY_AX_BIT_NDC))) { return(ENVOY_AX_BAD_VALUE); }ax_pkt.type = ENVOY_AX_OPEN;ax_pkt.version = version;ax_pkt.flags = flags;ax_pkt.packet_id = packet_id;ax_pkt.data.open_data.timeout = timeout;/* Note that we don't build a new copy of the object id here so we MUST NOT free it later on, we do this to avoid allocating memory and because we have control of the packet. */ax_pkt.data.open_data.sub_id.num_components = obj->num_components;ax_pkt.data.open_data.sub_id.component_list = obj->component_list;EBufferPreLoad(BFL_IS_STATIC, &ax_pkt.data.open_data.descr, descr, descr_len);return(envoy_ax_pkt_encode(&ax_pkt, 0, ebuffp, 0));}/********************************************************************************* envoy_ax_pkt_create_close - create an encoded AgentX 'CLOSE' packet* SYNOPSIS** \cs* int envoy_ax_pkt_create_close* ( * EBUFFER_T * ebuffp, * bits8_t version, * bits8_t flags, * bits32_t session_id, * bits32_t packet_id, * bits8_t close_reason* )* \ce** DESCRIPTION** This routine creates an encoded AgentX 'CLOSE' packet and places the encoded * packet in <ebuffp>.** PARAMETERS* \is* \i <*ebuffp>* Point to an <ebuffp> structure that will be filled with the encoded packet. * The <ebuffp> may be a start pointer to an offset in this <ebuffp> or a next * pointer to another <ebuffp>. If no space is provided in the <ebuffp>, it is * the responsibility of the caller to free this space. You can use * SNMP_memory_alloc(), SNMP_memory_free() to allocate space in an <ebuffp>.* \i <version>* Specify the AgentX version number. At this release, the only supported * version is 'ENVOY_AX_VERSION_1'.* \i <flags>* Specify the bits for the flag word of the packet header. This routine * supports the following flag:* \is* \i 'ENVOY_AX_BIT_BYTE_ORDER'* Select network-byte order for encoding or decoding.* \ie* \i <session_id>* Indicate to which session this packet belongs. When a subagent first opens a * session, this value is 0. Afterward, this value is the session ID supplied by * the master.* \i <packet_id>* Specify a number that allows the requester to match responses to requests.* \i <close_reason>* Specify one of the following reasons given by the subagent for closing the * connection: 'ENVOY_AX_CLOSE_OTHER', 'ENVOY_AX_CLOSE_PARSE', * 'ENVOY_AX_CLOSE_PROTO', 'ENVOY_AX_CLOSE_TIMEOUTS', 'ENVOY_AX_CLOSE_SHUTDOWN', * and 'ENVOY_AX_CLOSE_MANAGER'.* \ie** RETURNS: If successful, this routine returns 0. Otherwise, it returns one of * the following values:* \is* \i 'ENVOY_AX_ALLOCATION_FAILURE'* Unable to allocate an AgentX packet.* \i 'ENVOY_AX_BAD_SIZE'* Insufficient space requested.* \i 'ENVOY_AX_BAD_VALUE'* The packet was badly formed or <ebuffp> did not match its expected size.* \i 'ENVOY_AX_TOO_SMALL'* The string is either smaller than the minimum PDU size or does not match the * expected length.* \ie** ERRNO: N/A** SEE ALSO: envoy_ax_pkt_create_all(), envoy_ax_pkt_create_agent_caps(), * envoy_ax_pkt_create_open(), envoy_ax_pkt_create_ping(), * envoy_ax_pkt_create_registrations(), envoy_ax_pkt_create_variables(), * SNMP_memory_alloc(), SNMP_memory_free()*/int envoy_ax_pkt_create_close(EBUFFER_T * ebuffp, bits8_t version, bits8_t flags, bits32_t session_id, bits32_t packet_id, bits8_t close_reason){ENVOY_AX_PKT_T ax_pkt;envoy_ax_pkt_init(&ax_pkt);/* validity check the arguments */if ((version != ENVOY_AX_VERSION_1) || (flags & (ENVOY_AX_BIT_NEW_INDEX | ENVOY_AX_BIT_ANY_INDEX | ENVOY_AX_BIT_INSTANCE | ENVOY_AX_BIT_NDC))) { return(ENVOY_AX_BAD_VALUE); }ax_pkt.type = ENVOY_AX_CLOSE;ax_pkt.version = version;ax_pkt.flags = flags;ax_pkt.packet_id = packet_id;ax_pkt.session_id = session_id;ax_pkt.data.reason = close_reason;return(envoy_ax_pkt_encode(&ax_pkt, 0, ebuffp, 0));}/********************************************************************************* envoy_ax_pkt_create_registrations - create an encoded AgentX registration packet* SYNOPSIS** \cs* int envoy_ax_pkt_create_registrations* ( * EBUFFER_T * ebuffp, * bits8_t version, * bits8_t pdu_type, * bits8_t flags, * bits32_t packet_id, * bits32_t session_id, * bits8_t time-out, * bits8_t priority, * bits8_t range_subid, * OBJ_ID_T * obj, * OIDC_T upper_bound, * bits32_t context_len, * bits8_t * context* )* \ce** DESCRIPTION** This routine creates an encoded AgentX register or unregister packet and * places the encoded packet in <ebuffp>. Since this routine does not create a * lasting AgentX packet structure, it does not keep a pointer to <context>.** PARAMETERS* \is* \i <*ebuffp>* Point to an <ebuffp> structure that will be filled with the encoded packet. * The <ebuffp> may be a start pointer to an offset in this <ebuffp> or a next * pointer to another <ebuffp>. If no space is provided in the <ebuffp>, it is * the responsibility of the caller to free this space. You can use * SNMP_memory_alloc(), SNMP_memory_free() to allocate space in an <ebuffp>.* \i <version>* Specify the AgentX version number. At this release, the only supported * version is 'ENVOY_AX_VERSION_1'.* \i <pdu_type>* Indicate which type of message you are trying to create. This routine * supports the following types: 'ENVOY_AX_REGISTER' or 'ENVOY_AX_UNREGISTER'.* \i <flags>* Specify the bits for the flag word of the packet header. This routine * supports the following flags:* \is* \i 'ENVOY_AX_BIT_NDC'* Select a non-default context supplied by the user.* \i 'ENVOY_AX_BIT_BYTE_ORDER'* Select network-byte order for encoding or decoding.* \ie* \i <packet_id>* Specify a number that allows the requester to match responses to requests.* \i <session_id>* Indicate to which session this packet belongs. When a subagent first opens a * session, this value is 0. Afterward, this value is the session ID supplied by * the master.* \i <timeout>* Indicate how long the master agent waits before timing out registration and * open requests.* \i <priority>* Specify the requested priority to use.* \i <range_subid>* Specify the sub ID that is allowed to range.* \i <*obj>* Specify the object ID to add or remove depending on the PDU type.* \i <upper_bound>* Specify the upper bound of a sub ID range. The lower bound is given by the * object id.* \i <context_len>* Indicate the length in bytes of the context string (<context>), which is * passed to the master agent when a non-default context is used.* \i <*context>* Specify the context string.* \ie** RETURNS: If successful, this routine returns 0. Otherwise, it returns one of * the following values:* \is* \i 'ENVOY_AX_ALLOCATION_FAILURE'* Unable to allocate an AgentX packet.* \i 'ENVOY_AX_BAD_SIZE'* Insufficient space requested.* \i 'ENVOY_AX_BAD_VALUE'* The packet was badly formed or <ebuffp> did not match its expected size.* \i 'ENVOY_AX_TOO_SMALL'* The string is either smaller than the minimum PDU size or does not match the * expected length.* \ie** ERRNO: N/A** SEE ALSO: envoy_ax_pkt_create_all(), envoy_ax_pkt_create_agent_caps(), * envoy_ax_pkt_create_close(), envoy_ax_pkt_create_open(), * envoy_ax_pkt_create_ping(), envoy_ax_pkt_create_variables(), * SNMP_memory_alloc(), SNMP_memory_free()*/int envoy_ax_pkt_create_registrations(EBUFFER_T * ebuffp, bits8_t version, bits8_t pdu_type, bits8_t flags, bits32_t packet_id, bits32_t session_id, bits8_t timeout, bits8_t priority, bits8_t range_subid, OBJ_ID_T * obj, OIDC_T upper_bound, bits32_t context_len, bits8_t * context){ENVOY_AX_PKT_T ax_pkt;envoy_ax_pkt_init(&ax_pkt);/* validity check the arguments */if ((version != ENVOY_AX_VERSION_1) || (flags & (ENVOY_AX_BIT_NEW_INDEX | ENVOY_AX_BIT_ANY_INDEX ))) { return(ENVOY_AX_BAD_VALUE); }if (pdu_type == ENVOY_AX_REGISTER) { ax_pkt.type = ENVOY_AX_REGISTER; ax_pkt.data.reg_data.timeout = timeout; }else if (pdu_type == ENVOY_AX_UNREGISTER) { ax_pkt.type = ENVOY_AX_UNREGISTER; }else return(ENVOY_AX_BAD_VALUE);ax_pkt.version = version;ax_pkt.flags = flags;ax_pkt.packet_id = packet_id;ax_pkt.session_id = session_id;ax_pkt.data.reg_data.priority = priority;ax_pkt.data.reg_data.range = range_subid;ax_pkt.data.reg_data.bound = upper_bound;/* Note that we don't build a new copy of the object id here so we MUST NOT free it later on, we do this to avoid allocating memory and because we have control of the packet. */ax_pkt.data.reg_data.region.num_components = obj->num_components;ax_pkt.data.reg_data.region.component_list = obj->component_list;if (flags & ENVOY_AX_BIT_NDC) { EBufferPreLoad(BFL_IS_STATIC, &ax_pkt.context, context, context_len); }return(envoy_ax_pkt_encode(&ax_pkt, 0, ebuffp, 0));}/********************************************************************************* envoy_ax_pkt_create_ping - create an encoded AgentX 'PING' packet* SYNOPSIS** \cs* int envoy_ax_pkt_create_ping* ( * EBUFFER_T * ebuffp, * bits8_t version, * bits8_t flags, * bits32_t packet_id, * bits32_t session_id, * bits32_t context_len, * bits8_t * context* )* \ce** DESCRIPTION** This routine creates an encoded AgentX 'PING' packet and places the encoded * packet in <ebuffp>. Since this routine does not create a lasting AgentX * packet structure, it does not keep a pointer to <context>.** PARAMETERS* \is* \i <*ebuffp>* Point to an <ebuffp> structure that will be filled with the encoded packet. * The <ebuffp> may be a start pointer to an offset in this <ebuffp> or a next * pointer to another <ebuffp>. If no space is provided in the <ebuffp>, it is * the responsibility of the caller to free this space. You can use * SNMP_memory_alloc(), SNMP_memory_free() to allocate space in an <ebuffp>.* \i <version>* Specify the AgentX version number. At this release, the only supported * version is 'ENVOY_AX_VERSION_1'.* \i <flags>* Specify the bits for the flag word of the packet header. This routine * supports the following flags:* \is* \i 'ENVOY_AX_BIT_NDC'* Select a non-default context supplied by the user.* \i 'ENVOY_AX_BIT_BYTE_ORDER'* Select network-byte order for encoding or decoding.* \ie* \i <packet_id>* Specify a number that allows the requester to match responses to requests.* \i <session_id>* Indicate to which session this packet belongs. When a subagent first opens a * session, this value is 0. Afterward, this value is the session ID supplied by * the master.* \i <context_len>* Indicate the length in bytes of the context string (<context>), which is * passed to the master agent when a non-default context is used.* \i <*context>* Specify the context string.* \ie** RETURNS: If successful, this routine returns 0. Otherwise, it returns one of * the following values:* \is* \i 'ENVOY_AX_ALLOCATION_FAILURE'* Unable to allocate an AgentX packet.* \i 'ENVOY_AX_BAD_SIZE'* Insufficient space requested.* \i 'ENVOY_AX_BAD_VALUE'* The packet was badly formed or <ebuffp> did not match its expected size.* \i 'ENVOY_AX_TOO_SMALL'* The string is either smaller than the minimum PDU size or does not match the * expected length.* \ie** ERRNO: N/A** SEE ALSO: envoy_ax_pkt_create_all(), envoy_ax_pkt_create_agent_caps(), * envoy_ax_pkt_create_close(), envoy_ax_pkt_create_open(), * envoy_ax_pkt_create_registrations(), envoy_ax_pkt_create_variables(), * SNMP_memory_alloc(), SNMP_memory_free()*/int envoy_ax_pkt_create_ping(EBUFFER_T * ebuffp, bits8_t version, bits8_t flags, bits32_t packet_id, bits32_t session_id, bits32_t context_len, bits8_t * context){ENVOY_AX_PKT_T ax_pkt;envoy_ax_pkt_init(&ax_pkt);/* validity check the arguments */if ((version != ENVOY_AX_VERSION_1) || (flags & (ENVOY_AX_BIT_NEW_INDEX | ENVOY_AX_BIT_ANY_INDEX | ENVOY_AX_BIT_INSTANCE))) { return(ENVOY_AX_BAD_VALUE); }ax_pkt.type = ENVOY_AX_PING;ax_pkt.version = version;ax_pkt.flags = flags;ax_pkt.packet_id = packet_id;ax_pkt.session_id = session_id;if (flags & ENVOY_AX_BIT_NDC) { EBufferPreLoad(BFL_IS_STATIC, &ax_pkt.context, context, context_len); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -