snb2a.c,v

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

C,V
72
字号
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
@/* snb2a.c - snb2a */

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

#ifdef	 SNMP

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

extern u_char snmpbuff[];

/*------------------------------------------------------------------------
 * snb2a - convert the list of bindings from internal form into ASN.1
 *------------------------------------------------------------------------
 */
int snb2a(rqdp)
struct req_desc	*rqdp;
{
	register u_char *bp;
	int		len;
	struct snbentry	*bl;
	u_char		*ap;

	for (bl = rqdp->bindlf; bl; bl = bl->sb_next) {
		bp = snmpbuff;	/* used for temporary working space */
		*bp++ = ASN1_OBJID;
		bp += a1writeoid(bp, &bl->sb_oid);
		bp += a1writeval(bl, bp);
		/*
		 * We need to allocate bytes in sb_a1str but can't do it
		 * until we know how many bytes it takes to write the
		 * length of the binding,  so we write that length into
		 * snmpbuff at the end of the binding. Then we can alloc
		 * space, and transfer the data.
		 */
		len = a1writelen(bp, bp - snmpbuff);
		bl->sb_a1slen = bp - snmpbuff + len + 1;
		ap = bl->sb_a1str = (u_char *) getmem(bl->sb_a1slen);
		*ap++ = ASN1_SEQ;
		blkcopy(ap, bp, len);  /* write in the length spec.	*/
		ap += len;
		blkcopy(ap, snmpbuff, bp - snmpbuff);
	}
}
#endif	/* SNMP */
@

⌨️ 快捷键说明

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