📄 iptables.c
字号:
/****************************************************************************NAME: ip_routetable_nextPURPOSE: Locate the "next" object in the ip routing tablePARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This identifies the particular "attribute" we want in the table. The following values give an example: 1 - ipRouteDest 2 - ipRouteIfIndex 3 - ipRouteMetric1 4 - ipRouteMetric2 5 - ipRouteMetric3 6 - ipRouteMetric4 7 - ipRouteNextHop 8 - ipRouteType 9 - ipRouteProto 10 - ipRouteAge int Number of components in the yet unused part of the object identifier OIDC_T * Yet unused part of the object identifier OIDC_T * Start of an area in which the object instance part of the name of the "next" object should be constructed. char * User's cookie, passed unchanged from the LEAF macro in the mib.cRETURNS: int >0 indicates how many object identifiers have been placed in the result list. 0 if there is no "next" in the tableThis routing's job is to use the target object instance, representedby variables tcount and tlist, to ascertain whether there is a "next"entry in the table. If there is, the object instance of that elementis constructed in the return list area (rlist) and the number of elementsreturned. If there is no "next" a zero is returned.It is possible that the target object instance may be empty (i.e.tcount == 0) or incomplete (i.e. tcount < sizeof(normal object instance)).If tcount == 0, the first object in the table should be returned.The term "object instance" refers to that portion of an object identifierused by SNMP to identify a particular instance of a tabular variable.****************************************************************************//*ARGSUSED*//*lint -e715 */int ip_routetable_next(OIDC_T last_match, /* Last component matched */ int tcount, OIDC_T *tlist, OIDC_T *rlist, char *cookie){return 0;}/*lint +e715 *//****************************************************************************NAME: ip_routetable_getintPURPOSE: Obtain an Integer type parameter from the ip routing table. The integer parameters in this table (and their lastmatch value) are: 2 - ipRouteIfIndex 3 - ipRouteMetric1 4 - ipRouteMetric2 5 - ipRouteMetric3 6 - ipRouteMetric4 8 - ipRouteType 9 - ipRouteProto 10 - ipRouteAge PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier char * User's cookie, passed unchanged from the LEAF macro in the mib.cRETURNS: INT_32_T The value of the parameter.****************************************************************************//*ARGSUSED*//*lint -e715 */INT_32_T ip_routetable_getint(OIDC_T last_match, int tcount, OIDC_T *tlist, char *cookie){switch(last_match) { case 2: /* ipRouteIfIndex */ case 3: /* ipRouteMetric1 */ case 4: /* ipRouteMetric2 */ case 5: /* ipRouteMetric3 */ case 6: /* ipRouteMetric4 */ case 8: /* ipRouteType */ case 9: /* ipRouteProto */ case 10: /* ipRouteAge */ return (INT_32_T)*((int *)cookie); /* TEMPORARY */ }return 0;}/*lint +e715 *//****************************************************************************NAME: ip_routetable_getipaddrPURPOSE: Obtain an IpAddress type parameter from the ip routing table. The IpAddress parameters in this table (and their lastmatch value) are: 1 - ipRouteDest 7 - ipRouteNextHop PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier char * User's cookie, passed unchanged from the LEAF macro in the mib.cRETURNS: OCTET_T * Pointer to a 4 byte long area in which the IP routing is found. The routing bytes must be in standard network order.****************************************************************************//*ARGSUSED*//*lint -e715 */OCTET_T * ip_routetable_getipaddr(OIDC_T last_match, int tcount, OIDC_T *tlist, char *cookie){switch(last_match) { case 1: /* ipRouteDest */ case 7: /* ipRouteNextHop */ return (OCTET_T *)cookie; /* TEMPORARY */ }return (OCTET_T *)cookie;}/*lint +e715 *//****************************************************************************NAME: ip_routetable_setintPURPOSE: Alter an Integer type parameter within the ip routing table. The integer parameters in this table (and their lastmatch value) are: 2 - ipRouteIfIndex 3 - ipRouteMetric1 4 - ipRouteMetric2 5 - ipRouteMetric3 6 - ipRouteMetric4 8 - ipRouteType 9 - ipRouteProto 10 - ipRouteAge PARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier char * User's cookie, passed unchanged from the LEAF macro in the mib.c INT_32_T New value to be set.RETURNS: None -- void procedure.****************************************************************************//*ARGSUSED*//*lint -e715 */void ip_routetable_setint(OIDC_T last_match, int tcount, OIDC_T *tlist, char *cookie, INT_32_T value){switch(last_match) { case 2: /* ipRouteIfIndex */ case 3: /* ipRouteMetric1 */ case 4: /* ipRouteMetric2 */ case 5: /* ipRouteMetric3 */ case 6: /* ipRouteMetric4 */ case 8: /* ipRouteType */ case 10: /* ipRouteAge */ /* ***>>> DO SOMETHING <<<*** */ ; }}/*lint +e715 *//****************************************************************************NAME: ip_routetable_setipaddrPURPOSE: Alter an IpAddress type parameter within the ip routing table. The IpAddress parameters in this table (and their lastmatch value) are: 1 - ipRouteDest 7 - ipRouteNextHopPARAMETERS: OIDC_T Last component of the object id leading to the leaf node in the MIB. This is usually the identifier for the particular attribute in the table. int Number of components in the unused part of the object identifier OIDC_T * Unused part of the object identifier char * User's cookie, passed unchanged from the LEAF macro in the mib.c char * Pointer to the new value to be assigned. int Length of the new value at the above pointer.RETURNS: None -- void procedure.****************************************************************************//*ARGSUSED*//*lint -e715 */void ip_routetable_setipaddr(OIDC_T last_match, int tcount, OIDC_T *tlist, char *cookie, char *value, int length){if (length != 4) return; /* wrong length */switch(last_match) { case 1: /* ipRouteDest */ case 7: /* ipRouteNextHop */ /* ***>>> DO SOMETHING <<<*** */ ; }}void ip_addrtable_test_async(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){/* There must be exactly 4 unused component */if (tcount != 4) testproc_error(pktp, vbp, NO_CREATION);else testproc_good(pktp, vbp);}void ip_routetable_test_async(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){/* There must be exactly 4 unused component */if (tcount != 4) testproc_error(pktp, vbp, NO_CREATION);else testproc_good(pktp, vbp);}void ip_addrtable_get_async(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){/* There must be exactly 4 unused component */if (tcount != 4) { getproc_nosuchins(pktp, vbp); return; }switch(lastmatch) { case 2: /* ipadentifindex */ case 4: /* ipadentbcastaddr */ getproc_got_int32(pktp, vbp, *(INT_32_T *)(VB_TO_COOKIE(vbp))); break; case 1: /* ipadentaddr */ case 3: /* ipadentnetmask */ getproc_got_ip_address(pktp, vbp, *(UINT_32_T *)(VB_TO_COOKIE(vbp))); break; }}void ip_routetable_get_async(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){/* There must be exactly 4 unused component */if (tcount != 4) { getproc_nosuchins(pktp, vbp); return; }switch(lastmatch) { case 2: /* iprouteindex */ case 3: /* iproutemetric1 */ case 4: /* iproutemetric2 */ case 5: /* iproutemetric3 */ case 6: /* iproutemetric4 */ case 8: /* iproutetype */ case 9: /* iprouteproto */ case 10: /* iprouteage */ getproc_got_int32(pktp, vbp, *(INT_32_T *)(VB_TO_COOKIE(vbp))); break; case 1: /* iproutedest */ case 7: /* iproutenexthop */ getproc_got_ip_address(pktp, vbp, *(UINT_32_T *)(VB_TO_COOKIE(vbp))); break; }}/*lint +e715 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -