snoip.c,v

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

C,V
80
字号
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
@/* snoip.c - sip2ocpy, so2ipcpy, soipequ */

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

#ifdef	SNMP

#include <snmp.h>

/*---------------------------------------------------------------------
 * sip2ocpy - copy an IP address into the object id structure
 *---------------------------------------------------------------------
 */
sip2ocpy(oidp, pip)
u_short *oidp;
IPaddr pip;     
{
	int 	i;
	
	for (i = 0; i < IP_ALEN; i++)
	    *oidp++ = ((u_short) ((char *)&pip)[i]) & 0xff;
}

/*---------------------------------------------------------------------
 * so2ipcpy - copy 4 sub-object ids into an IP address array
 *---------------------------------------------------------------------
 */
so2ipcpy(pip, oidp)
IPaddr pip;     
u_short *oidp;
{
	int 	i;
	
	for (i = 0; i < IP_ALEN; i++)
	    pip[i] = (u_char) oidp[i] & 0xff;
}

/*---------------------------------------------------------------------
 * soipequ - test equality between an object id and an IP address
 *---------------------------------------------------------------------
 */
soipequ(oidp, pip, len)
u_short *oidp;
IPaddr pip;
int len;
{
	int 	i;
	
	for (i = 0; i < len; i++) 
	    if ((u_char) pip[i] != (u_char) oidp[i]) 
		return(FALSE);
	return(TRUE);
}
#endif	/* SNMP */
@

⌨️ 快捷键说明

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