srt_get.c,v

来自「TCP-IP红宝书源代码」· C,V 代码 · 共 102 行

C,V
102
字号
head	1.1;
access;
symbols;
locks
	dls:1.1; strict;
comment	@ * @;


1.1
date	97.09.21.19.29.17;	author dls;	state Dist;
branches;
next	;


desc
@@


1.1
log
@pre-3e code
@
text
@/* srt_get.c - srt_get */

#include <conf.h>
#include <kernel.h>
#include <network.h>

#ifdef	SNMP

#include <snmp.h>
#include <mib.h>
#include <asn1.h>

/*------------------------------------------------------------------------
 * srt_get - perform a get on a variable in the Routing Table
 *------------------------------------------------------------------------
 */
int srt_get(bindl, numifaces)
struct snbentry	*bindl;
int		numifaces;
{
	struct	route *rtp;
	int	rtl, field;

	if (srt_match(bindl, &rtp, &rtl, &field) == SYSERR)
		return SERR_NO_SUCH;
	switch(field) {
	case 1:		/* ipRouteDest */
		SVTYPE(bindl) = ASN1_IPADDR;
		blkcopy(SVIPADDR(bindl), rtp->rt_net, IP_ALEN);
		return SNMP_OK;
	case 2:		/* ipRouteIfIndex */
		SVTYPE(bindl) = ASN1_INT;
		SVINT(bindl) = rtp->rt_ifnum;
		return SNMP_OK;
	case 3:		/* ipRouteMetric1 */
		SVTYPE(bindl) = ASN1_INT;
		SVINT(bindl) = rtp->rt_metric;
		return SNMP_OK;
	case 4:		/* ipRouteMetric2 */
	case 5:		/* ipRouteMetric3 */
	case 6:		/* ipRouteMetric4 */
		SVTYPE(bindl) = ASN1_INT;
		SVINT(bindl) = -1;
		return SNMP_OK;
	case 7:		/* ipRouteNextHop */
		SVTYPE(bindl) = ASN1_IPADDR;
		blkcopy(SVIPADDR(bindl), rtp->rt_gw, IP_ALEN);
		return SNMP_OK;
	case 8:		/* ipRouteType */
		SVTYPE(bindl) = ASN1_INT;
		if (rtp->rt_metric)
		    SVINT(bindl) = 4;	/* remote */
		else
		    SVINT(bindl) = 3;	/* direct */
		return SNMP_OK;
	case 9:		/* ipRouteProto */
		SVTYPE(bindl) = ASN1_INT;
		SVINT(bindl) = 1;		/* other */
		return SNMP_OK;
	case 10:		/* ipRouteAge */
		SVTYPE(bindl) = ASN1_INT;
		SVINT(bindl) = rtp->rt_ttl;
		return SNMP_OK;
	case 11:		/* ipRouteMask */
		SVTYPE(bindl) = ASN1_IPADDR;
		blkcopy(SVIPADDR(bindl), rtp->rt_mask, IP_ALEN);
		return SNMP_OK;
	case 12:		/* ipRouteMetric5 */
		SVTYPE(bindl) = ASN1_INT;
		SVINT(bindl) = -1;
		return SNMP_OK;
	default:
		break;
	}
	return SERR_NO_SUCH;
}
#endif	/* SNMP */
@

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?