📄 dot11miblib.c
字号:
that this memory will be freed by the consumer (i.e. SNMP engine once the data has been processed */ pMem = SNMP_memory_alloc(MAXSIZE_dot11DesiredSSID); /* Make sure that we allocated the block successfully */ if (pMem == NULL) { status = GEN_ERR; break; } /* Now copy the Desired SSID data to the dynamic SNMP storage block */ bcopy(dssid, (char*)pMem, MAXSIZE_dot11DesiredSSID); /* Send a signal to the SNMP engine that the data has been received from the driver successfully */ getproc_got_string(pktp, /* Packet pointer */ vbp, /* Var binding */ min(strlen((char*)dssid), MAXSIZE_dot11DesiredSSID), pMem, /* Data */ SNMP_DYNAMIC_RELEASE, /* Release later */ VT_STRING); /* String type data */ } else { /* Driver ioctl call failed */ getproc_got_empty(pktp, vbp); } } break; case LEAF_dot11OperationalRateSet: { DOT11_RATES rateSet; /* Get the Operation rates from the driver */ ioctlStatus = END_IOCTL(pEnd, WIOCGSUPPTXRATE, &rateSet); /* Make sure the call succeeded */ if (ioctlStatus == OK) { OCTET_T *pMem; /* Pointer for dynamic storage alloc */ /* Allocate block of memory from the SNMP engine. Note that this memory will be freed by the consumer (i.e. SNMP engine once the data has been processed */ pMem = SNMP_memory_alloc(rateSet.length); /* Make sure that we allocated the block successfully */ if (pMem == NULL) { status = GEN_ERR; break; } /* Now copy the rates data to the dynamic SNMP storage block */ bcopy((char *)rateSet.rates, (char*)pMem, rateSet.length); /* Send a signal to the SNMP engine that the data has been received from the driver successfully */ getproc_got_string(pktp, /* Packet pointer */ vbp, /* Var binding */ rateSet.length, /* Size of table */ pMem, /* Data */ SNMP_DYNAMIC_RELEASE, /* Release later */ VT_STRING); /* Data type */ } else { /* Driver ioctl call failed */ getproc_got_empty(pktp, vbp); } } case LEAF_dot11DesiredBSSType: { /* Get the Current Power Management mode from the driver */ ioctlStatus = END_IOCTL(pEnd, WIOCGDOT11MODE, &dot11Data); /* Make sure previous call succeeded */ if (ioctlStatus == OK) { INT32 status = OK; /* Convert the data to conform to the MIB decription */ switch(dot11Data) { case DOT11_MODE_ESS: dot11Data = VAL_dot11DesiredBSSType_infrastructure; break; case DOT11_MODE_IBSS: dot11Data = VAL_dot11DesiredBSSType_independent; break; case DOT11_MODE_AP: case DOT11_MODE_NONE: default: status = ERROR; break; } /* Now send the data to the SNMP engine */ if (status == OK) { getproc_got_int32(pktp, /* Packet pointer */ vbp, /* Var binding */ (INT_32_T)dot11Data); /* Data */ } else { /* Driver Ioctl call failed */ getproc_got_empty(pktp, vbp); } } else { /* Driver Ioctl call failed */ getproc_got_empty(pktp, vbp); } } break; case LEAF_dot11BeaconPeriod: { /* Get the Current Power Management mode from the driver */ ioctlStatus = END_IOCTL(pEnd, WIOCGBEACONRATE, &dot11Data); /* Make sure previous call succeeded */ if (ioctlStatus == OK) { /* Now send the data to the SNMP engine */ getproc_got_int32(pktp, /* Packet pointer */ vbp, /* Var binding */ (INT_32_T)dot11Data); /* Data */ } else if (ioctlStatus == EINVAL) { /* Not supported by driver in the current mode */ dot11RequestNotSupported(pktp, vbp); } else { /* Driver Ioctl call failed */ getproc_got_empty(pktp, vbp); } } break; case LEAF_dot11DisassociateReason: case LEAF_dot11DisassociateStation: case LEAF_dot11DeauthenticateReason: case LEAF_dot11DeauthenticateStation: case LEAF_dot11AuthenticateFailStatus: case LEAF_dot11AuthenticateFailStation: case LEAF_dot11MediumOccupancyLimit: case LEAF_dot11CFPollable: case LEAF_dot11CFPPeriod: case LEAF_dot11CFPMaxDuration: case LEAF_dot11AuthenticationResponseTimeOut: case LEAF_dot11DTIMPeriod: case LEAF_dot11AssociationResponseTimeOut: /* Not supported by driver */ dot11RequestNotSupported(pktp, vbp); break; default: /* SNMP error */ status = GEN_ERR; break; } /* Return the status of the call to the SNMP engine */ return(status); }/***************************************************************************** dot11StationConfigEntryGet - SNMP "get" function for StationConfigEntry** This is the standard WM SNMP get method for the StationConfigEntry. It is* called when a "get" query is received by the SNMP agent for this branch.* The leaf number (last part of OID) is contained in <lastmatch> and the * requested instance is specified in <tcount> and <tlist>* * RETURNS: VOID** ERRNO: N/A** NOMANUAL*/VOID dot11StationConfigEntryGet ( OIDC_T lastmatch, /* Last matching part of OID - the LEAF name */ int tcount, /* Number of elements in interface (table) list */ OIDC_T *tlist, /* List of interface (table) elements */ SNMP_PKT_T *pktp, /* Pointer to raw SNMP packet */ VB_T *vbp /* Pointer to varbind structure */ ) { INT32 error; END_OBJ *pEnd; /* We're only expecting one index variable */ if (tcount != 1) { getproc_nosuchins(pktp, vbp); return; } /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance(pktp, vbp, tcount, tlist); /* use the instance (tcount and tlist) to look up the entry in the * table. This lookup routine will probably have to be changed to * suit your system. */ if ((pEnd = dot11EndObjGet((int)tlist[0])) == NULL) { for ( ; vbp != NULL; vbp = vbp->vb_link) { getproc_nosuchins(pktp, vbp); } } else { /* retrieve all the values from the same data structure */ for ( ; vbp != NULL; vbp = vbp->vb_link) { if ((error = dot11StationConfigEntry_get_value( vbp->vb_ml.ml_last_match, pktp, vbp, pEnd)) != NO_ERROR) { getproc_error(pktp, vbp, error); } } } }/***************************************************************************** dot11StationConfigEntryNext - SNMP "next" function for StationConfigEntry** This is the standard "next" function for StationConfigEntry. This is called* when a MIB client issues a "next" command, typically when walking a tree* or when doing index discovery. This will return the instance number of the * next instance, if there is one, or call next_proc_no_next if not. The * MIB agent is responsible for determining the "next" leaf if there is no* more instances of the current one.* * RETURNS: VOID** ERRNO: N/A** NOMANUAL*/VOID dot11StationConfigEntryNext ( OIDC_T lastmatch, /* Last matching part of OID - the LEAF name */ int tcount, /* Number of elements in interface (table) list */ OIDC_T *tlist, /* List of interface (table) elements */ SNMP_PKT_T *pktp, /* Pointer to raw SNMP packet */ VB_T *vbp /* Pointer to varbind structure */ ) { END_OBJ *pEnd; INT32 error; OIDC_T next; group_by_getproc_and_instance(pktp, vbp, tcount, tlist); if (tcount == 0) { /* If the instance count is zero, then we're trying to find the first instance. */ next = 1; } else if (tcount == 1) { /* If the instance length is one, then we're doing a simple next */ next = tlist[0] + 1; } else { /* If the instance count is greater than 1 then somebody's trying to add extra dimensions to this table */ for ( ; vbp ; vbp = vbp->vb_link ) { nextproc_error(pktp, vbp, NO_SUCH_NAME); } return; } /* Determine if the specified instance exists. */ if ((pEnd = dot11EndObjGet((int)next)) == NULL) { for ( ; vbp ; vbp = vbp->vb_link ) nextproc_no_next(pktp, vbp); return; } /* Now that we've verified the instance exists, get the value of that instance, and tell the agent what the next OID is */ for ( ; vbp ; vbp = vbp->vb_link) { if ((error = dot11StationConfigEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, pEnd)) == NO_ERROR) { nextproc_next_instance(pktp, vbp, 1, &next); } else { nextproc_error(pktp, vbp, error); } } }/***************************************************************************** dot11StationConfigEntryTest - SNMP "test" function for StationConfigEntry** The "test" routine is executed before the "set" routine when acting on* a SNMP set request. Its purpose is to evaluate whether the SNMP "set" is* valid - checking the leaf, the instance and the value for that leaf. If it* returns successfully then the "set" routine is called. If not, a failure is* sent back to the SNMP client.* * RETURNS: VOID** ERRNO: N/A** NOMANUAL*/VOID dot11StationConfigEntryTest ( OIDC_T lastmatch, /* Last matching part of OID - the LEAF name */ int tcount, /* Number of elements in interface (table) list */ OIDC_T *tlist, /* List of interface (table) elements */ SNMP_PKT_T *pktp, /* Pointer to raw SNMP packet */ VB_T *vbp /* Pointer to varbind structure */ ) { END_OBJ *pEnd; VB_T *group_vbp; /* This is a one-dimensional table */ if (tcount != 1) { testproc_error(pktp, vbp, NO_SUCH_NAME); return; } /* Get the pointer to device data for this instance */ if ((pEnd = dot11EndObjGet(tlist[0])) == NULL) { testproc_error(pktp, vbp, NO_SUCH_NAME); return; } /* stash the looked up information here for the setproc */ vbp->vb_priv = (VOID*)pEnd; /* find all the varbinds that share the same getproc and instance and * group them together. */ group_by_getproc_and_instance(pktp, vbp, tcount, tlist); /* now check each varbind */ for (group_vbp = vbp; group_vbp != NULL; group_vbp = group_vbp->vb_link) { switch (group_vbp->vb_ml.ml_last_match) { case LEAF_dot11PowerManagementMode: switch (VB_GET_INT32(group_vbp)) { case VAL_dot11PowerManagementMode_active: case VAL_dot11PowerManagementMode_powersave: break; default: testproc_error(pktp, group_vbp, WRONG_VALUE); continue; } testproc_good(pktp, group_vbp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -