📄 dot11miblib.c
字号:
/* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance(pktp, vbp, tcount, tlist); /* This entry has two indices */ if (tcount == 0) { /* If there's no indices specified, then we need the first element */ next_inst[0] = 1; next_inst[1] = 1; } else if ((tcount == 1) || (tcount == 2)) { next_inst[0] = tlist[0]; if (tcount == 1) { /* If only one index was specified, set the second to zero */ next_inst[1] = 0; } else { next_inst[1] = tlist[1]; } /* Increment the algorithm. If it's too big, then take it back to OS, and increment the ifnumber */ next_inst[1] ++; if (next_inst[1] > VAL_dot11AuthenticationAlgorithm_sharedKey) { next_inst[1] = VAL_dot11AuthenticationAlgorithm_openSystem; next_inst[0] ++; } /* In case the ifindex was zero */ if (next_inst[0] == 0) { next_inst[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_inst[0])) == 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 = dot11AuthenticationAlgorithmsEntry_get_value (vbp->vb_ml.ml_last_match, pktp, vbp, next_inst[1], pEnd)) == NO_ERROR) { nextproc_next_instance(pktp, vbp, dot11AuthenticationAlgorithmsEntry_INSTANCE_LEN, next_inst); } else { nextproc_error(pktp, vbp, error); } } }/***************************************************************************** dot11AuthenticationAlgorithmsEntryTest - SNMP "test" function for * AuthenticationAlgorithmsEntry** 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 dot11AuthenticationAlgorithmsEntryTest ( 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 two-dimensional table */ if (tcount != 2) { 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_dot11AuthenticationAlgorithmsEnable: switch (VB_GET_INT32(group_vbp)) { case VAL_dot11AuthenticationAlgorithmsEnable_true: case VAL_dot11AuthenticationAlgorithmsEnable_false: break; default: testproc_error(pktp, group_vbp, WRONG_VALUE); continue; } testproc_good(pktp, group_vbp); break; default: testproc_error(pktp, group_vbp, GEN_ERR); return; } } }/***************************************************************************** dot11AuthenticationAlgorithmsEntrySet - SNMP "set" function for * Authentication Algorithms Entry** After the "test" routine has been called as a result of a SNMP "set" command,* the SNMP agent calls this routine. The actual changes to the device occur* here.* * RETURNS: VOID** ERRNO: N/A** NOMANUAL*/VOID dot11AuthenticationAlgorithmsEntrySet ( 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 */ ) { /* Retrieve the value of pEnd we saved in the test routine */ END_OBJ *pEnd = vbp->vb_priv; UINT16 authAlg; UINT16 cardMode; INT32 op; /* If we got a valid pEnd, then we don't need to do validation and lookup, since the testproc had to be called first */ if (pEnd == NULL) { if (tcount != 2) { 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; } } for ( ; vbp != NULL; vbp = vbp->vb_link) { switch (vbp->vb_ml.ml_last_match) { case LEAF_dot11AuthenticationAlgorithmsEnable: /* Get the authentication algorithms currently enabled */ if (END_IOCTL(pEnd, WIOCSAUTHTYPE, &authAlg) != OK) { setproc_error(pktp, vbp, COMMIT_FAILED); } op = VB_GET_INT32(vbp); if (op == MDOT11_TRUE) { if (END_IOCTL(pEnd, WIOCGDOT11MODE, &cardMode) != OK) { setproc_error(pktp, vbp, COMMIT_FAILED); } if (cardMode == DOT11_MODE_ESS) { /* An enable operation is being performed. If this is a STA, then we must ensure that both algs are not being set */ authAlg = tlist[1]; } else { /* APs are allowed to have both authentication algs so just OR in the one we want enabled */ authAlg |= tlist[1]; } } else /* DISABLE operation */ { /* To disable, enabling the other one gives the desired behaviour for all cases */ authAlg &= (~tlist[1]) & 0x3; } if (END_IOCTL(pEnd, WIOCSAUTHTYPE, &authAlg) == OK) { setproc_good(pktp, vbp); } else { setproc_error(pktp, vbp, COMMIT_FAILED); } break; default: setproc_error(pktp, vbp, GEN_ERR); return; } } }/***************************************************************************** dot11WEPDefaultKeysEntry_get_value - Returns the value of the WEP key* * This function is specified by the ieee802dot11 MIB to return the values of* the currently set WEP keys. Due to security concerns an API was never * provided into the driver to retrieve this information; for these same* reasons this MIB call will only return 00s.* * RETURNS: GEN_ERR, or NO_ERROR** ERRNO: N/A** NOMANUAL*/static int dot11WEPDefaultKeysEntry_get_value ( OIDC_T lastmatch, /* Last matching part of OID - the LEAF name */ SNMP_PKT_T *pktp, /* Pointer to raw SNMP packet */ VB_T *vbp, /* Pointer to varbind structure */ int keyNum, /* Key number requested */ END_OBJ *pEnd /* Instance-specific device data */ ) { static OCTET_T buffer[SIZE_dot11WEPDefaultKeyValue + 1]; bfill((char*)&buffer, SIZE_dot11WEPDefaultKeyValue + 1, 0); switch(lastmatch) { case LEAF_dot11WEPDefaultKeyValue: getproc_got_string(pktp, vbp, SIZE_dot11WEPDefaultKeyValue, (OCTET_T*)buffer, 0, VT_STRING); break; default: return(GEN_ERR); } return(NO_ERROR); }/***************************************************************************** dot11WEPDefaultKeysEntryGet - SNMP "get" function for WEPDefaultKeysEntry* * This is the standard WM SNMP get method for WEPDefaultKeysEntry. 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: GEN_ERR, or NO_ERROR** ERRNO: N/A** NOMANUAL*/VOID dot11WEPDefaultKeysEntryGet ( 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; /* This entry has two indices */ if (tcount != 2) { 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); } return; } /* retrieve all the values from the same instance */ for ( ; vbp != NULL; vbp = vbp->vb_link) { if ((error = dot11WEPDefaultKeysEntry_get_value( vbp->vb_ml.ml_last_match, pktp, vbp, tlist[1], pEnd)) != NO_ERROR) getproc_error(pktp, vbp, error); } }/***************************************************************************** dot11WEPDefaultKeyEntryNext - SNMP "next" function for WEPDefaultKeyEntry** This is the standard "next" function for WEPDefaultKeyEntry. 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 dot11WEPDefaultKeysEntryNext (
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -