📄 ospf_mib_stub.c
字号:
*/ rc = ospf_envoy_buildSetReq( tcount, tlist, pktp, vbp, pEnvoyReq, &request, reqType, ospfMapiArea_OID_OFFSET ); if ( rc == ERROR ) { ospf_envoy_setGenError( pktp, vbp, reqType ); return; } /* send the request to OSPF MIB API for processing */ rc = ospfMapiSetArea( &request, reqType ); if ( rc == ERROR ) { for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link ) { group_vbp->vb_priv = NULL; if ( reqType == MAPI_TEST ) testproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error)); else { /* tell envoy to start the undo operation. Envoy should call the * undo routine immediately once the setproc_error indicates * the set process has failed. */ group_vbp->undoproc = ospfEnvoy_undo; /* our undo routine */ /* issue a fake undo request to mib api so that it can reset its * internal transaction counters. */ ospfMapiSetArea( &request, MAPI_UNDO ); setproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error)); } } /* tell MIB API we have completed the transaction */ ospfMapiSetArea( &request, MAPI_COMPLETE ); ospf_envoy_clearBuffer( pEnvoyReq ); return; } if ( reqType == MAPI_TEST ) { /* stash the looked up information here for the setproc. Although Envoy * provide vb_priv in each varbind, only stash it to the first varbind. * MIB API only allow one cookie per request, and we only need one anyhow */ vbp->vb_priv = (void *)request.pReqCookie; } /* tell MIB API we have completed the transaction */ if ( reqType == MAPI_COMMIT ) ospfMapiSetArea( &request, MAPI_COMPLETE ); /* make the varbind as done and check for any exception in varbinds */ ospf_envoy_markVarbind( vbp, pktp, &request, reqType ); ospf_envoy_clearBuffer( pEnvoyReq ); return;}/***************************************************************************************** ospfEnvoy_getStub - generic get routine for ospfStubTable** This is the generic get routine for ospfStubTable. It query the mib api for the table* row in which the requested object instances can be found. The behavior of the mib api* is based on request type, either GET or GET_NEXT. If it is a GET_NEXT request, the* smallest instance that is larger than the given tcount/tlist will be returned.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_getStub( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ mApiRequest_t request; STATUS rc; if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* build the MIB API request message */ memset( (char *)&request, 0, sizeof(mApiRequest_t) ); rc = ospf_envoy_buildGetReq( tcount, tlist, vbp, pEnvoyReq, &request, ospfMapiStub_OID_OFFSET ); if ( rc == ERROR ) { ospf_envoy_clearBuffer( pEnvoyReq ); ospf_envoy_setGenError( pktp, vbp, reqType ); return; } /* send the request to MIB API */ rc = ospfMapiGetStub( &request, reqType ); if ( rc == ERROR ) { ospf_envoy_clearBuffer( pEnvoyReq ); ospf_envoy_processGetRespError( pktp, vbp, reqType, request.error ); return; } /* retrieve all the values from the request structure */ ospf_envoy_processGetResp( vbp, pktp, pEnvoyReq, &request, reqType, ospfMapiStub_OID_OFFSET ); return;}/**************************************************************************************** ospfEnvoy_setStub - generic set function for ospfStubTable** This routine is a generic set function for ospfStubTable. It invokes by testproc and* setproc to test and set objects in varbinds.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_setStub( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ mApiRequest_t request; VB_T *group_vbp; STATUS rc; if ( tcount != ospfStubAreaEntry_INST_LEN ) { ospf_envoy_setNoSuchNameError( pktp, vbp, reqType ); return; } if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* use the data provided by the varbinds directly. This eliminates the need * to copy the data from varbinds to locally allocated buffer. */ rc = ospf_envoy_buildSetReq( tcount, tlist, pktp, vbp, pEnvoyReq, &request, reqType, ospfMapiStub_OID_OFFSET ); if ( rc == ERROR ) { ospf_envoy_setGenError( pktp, vbp, reqType ); return; } /* send the request to OSPF MIB API for processing */ rc = ospfMapiSetStub( &request, reqType ); if ( rc == ERROR ) { for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link ) { group_vbp->vb_priv = NULL; if ( reqType == MAPI_TEST ) testproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error)); else { /* tell envoy to start the undo operation. Envoy should call the * undo routine immediately once the setproc_error indicates * the set process has failed. */ group_vbp->undoproc = ospfEnvoy_undo; /* our undo routine */ /* issue a fake undo request to mib api so that it can reset its * internal transaction counters. */ ospfMapiSetStub( &request, MAPI_UNDO ); setproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error)); } } /* tell MIB API we have completed the transaction */ ospfMapiSetStub( &request, MAPI_COMPLETE ); return; } if ( reqType == MAPI_TEST ) { /* stash the looked up information here for the setproc. Although Envoy * provide vb_priv in each varbind, only stash it to the first varbind. * MIB API only allow one cookie per request, and we only need one anyhow */ vbp->vb_priv = (void *)request.pReqCookie; } /* tell MIB API we have completed the transaction */ if ( reqType == MAPI_COMMIT ) ospfMapiSetStub( &request, MAPI_COMPLETE ); /* make the varbind as done and check for any exception in varbinds */ ospf_envoy_markVarbind( vbp, pktp, &request, reqType ); ospf_envoy_clearBuffer( pEnvoyReq ); return;}/***************************************************************************************** ospfEnvoy_getHost - generic get routine for ospfHostTable** This is the generic get routine for ospfHostTable. It query the mib api for the table* row in which the requested object instances can be found. The behavior of the mib api* is based on request type, either GET or GET_NEXT. If it is a GET_NEXT request, the* smallest instance that is larger than the given tcount/tlist will be returned.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_getHost( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ mApiRequest_t request; STATUS rc; if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* build the MIB API request message */ memset( (char *)&request, 0, sizeof(mApiRequest_t) ); rc = ospf_envoy_buildGetReq( tcount, tlist, vbp, pEnvoyReq, &request, ospfMapiHost_OID_OFFSET ); if ( rc == ERROR ) { ospf_envoy_clearBuffer( pEnvoyReq ); ospf_envoy_setGenError( pktp, vbp, reqType ); return; } /* send the request to MIB API */ rc = ospfMapiGetHost( &request, reqType ); if ( rc == ERROR ) { ospf_envoy_clearBuffer( pEnvoyReq ); ospf_envoy_processGetRespError( pktp, vbp, reqType, request.error ); return; } /* retrieve all the values from the request structure */ ospf_envoy_processGetResp( vbp, pktp, pEnvoyReq, &request, reqType, ospfMapiHost_OID_OFFSET ); return;}/**************************************************************************************** ospfEnvoy_setHost - generic set function for ospfHostTable** This routine is a generic set function for ospfHostTable. It invokes by testproc and* setproc to test and set objects in varbinds.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_setHost( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ mApiRequest_t request; VB_T *group_vbp; STATUS rc; if ( tcount != ospfHostEntry_INST_LEN ) { ospf_envoy_setNoSuchNameError( pktp, vbp, reqType ); return; } if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* use the data provided by the varbinds directly. This eliminates the need * to copy the data from varbinds to locally allocated buffer. */ rc = ospf_envoy_buildSetReq( tcount, tlist, pktp, vbp, pEnvoyReq, &request, reqType, ospfMapiHost_OID_OFFSET ); if ( rc == ERROR ) { ospf_envoy_setGenError( pktp, vbp, reqType ); return; } /* send the request to OSPF MIB API for processing */ rc = ospfMapiSetHost( &request, reqType ); if ( rc == ERROR ) { for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link ) { group_vbp->vb_priv = NULL; if ( reqType == MAPI_TEST ) testproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error)); else { /* tell envoy to start the undo operation. Envoy should call the * undo routine immediately once the setproc_error indicates * the set process has failed. */ group_vbp->undoproc = ospfEnvoy_undo; /* our undo routine */ /* issue a fake undo request to mib api so that it can reset its * internal transaction counters. */ ospfMapiSetHost( &request, MAPI_UNDO ); setproc_error( pktp, group_vbp, mApi2EnvoyErrorGet( request.error)); } } /* tell MIB API we have completed the transaction */ ospfMapiSetHost( &request, MAPI_COMPLETE ); return; } if ( reqType == MAPI_TEST ) { /* stash the looked up information here for the setproc. Although Envoy * provide vb_priv in each varbind, only stash it to the first varbind. * MIB API only allow one cookie per request, and we only need one anyhow */ vbp->vb_priv = (void *)request.pReqCookie; } /* tell MIB API we have completed the transaction */ if ( reqType == MAPI_COMMIT ) ospfMapiSetHost( &request, MAPI_COMPLETE ); /* make the varbind as done and check for any exception in varbinds */ ospf_envoy_markVarbind( vbp, pktp, &request, reqType ); ospf_envoy_clearBuffer( pEnvoyReq ); return;}/***************************************************************************************** ospfEnvoy_getLsdb - generic get routine for ospfLsdbTable** This is the generic get routine for ospfLsdbTable. It query the mib api for the row of* table in which the requested object instances can be found. The behavior of the mib api* is based on request type, either GET or GET_NEXT. If it is a GET_NEXT request, the* smallest instance that is larger than the given tcount/tlist will be returned.** RETURNS: N/A** NOMANUAL*/LOCAL void ospfEnvoy_getLsdb( int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp, mApiReqType_t reqType ){ OIDC_T inst_oid[ospfLsdbEntry_INST_LEN]; mApiRequest_t request; mApiObject_t object; VB_T *group_vbp; STATUS rc; unsigned inst_len; if ( ospfEnvoy_init_check( pktp, vbp, reqType ) == ERROR ) return; /* the ospfEnvoy_build_getRequest() expects the buffer for the octet string to
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -