📄 oid2ip.c
字号:
/* oid2ip.c - oid2ip.c routines *//* * Copyright 2000-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//* * Copyright 1991-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. *//* * $Log: oid2ip.c,v $ * Revision 1.2 2001/11/06 21:20:18 josh * revised new path hacking * * Revision 1.1.1.1 2001/11/05 17:47:39 tneale * Tornado shuffle * * Revision 9.2 2001/01/19 22:21:56 paul * Update copyright. * * Revision 9.1 2000/03/17 00:17:39 meister * Update copyright message * * Revision 9.0 1998/10/16 22:09:28 sar * Update version stamp to match release * * Revision 8.2 1998/06/05 18:52:54 sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 8.1 1998/02/25 04:49:49 sra * Update copyrights. * * Revision 8.0 1997/11/18 00:56:10 sar * Updated revision to 8.0 * * Revision 7.2 1997/03/20 06:50:14 sra * DFARS-safe copyright text. Zap! * * Revision 7.1 1997/02/25 10:49:26 sra * Update copyright notice, dust under the bed. * * Revision 7.0 1996/03/15 22:21:24 sar * Updated revision to 7.0 and copyright to 96 * * Revision 6.1 1996/01/05 19:02:18 sar * Removed no_pp style definitions as well as unnecessary include files * * Revision 6.0 1995/05/31 21:50:50 sra * Release 6.0. * * Revision 5.0 1994/05/16 15:29:57 sar * Updated revision to 5.0 and copyright to 1994 * * Revision 4.0 1993/06/24 15:58:43 sar * Updated rev to 4.0 and copyright to 93 * * Revision 3.0 1992/04/03 15:32:31 dab * Release 3.0 * * Revision 1.5 92/03/30 18:42:07 dab * checked in with -k by dab at 92.04.03.15.31.34. * * Revision 1.5 92/03/30 18:42:07 dab * Changed arguments so oid_to_ip() could return an error if the instance * wasn't legal for an IP address. * * Revision 1.4 92/02/05 16:58:19 dab * Added cast on assignment from OIDC_T to OCTET_T. * * Revision 1.3 91/11/03 09:52:42 dab * Forgot to increment a loop variable. * * Revision 1.2 91/10/30 20:38:40 dab * Directly include asn1conf.h and snmpdefs.h. * * Revision 1.1 91/10/30 18:12:45 dab * Initial revision * * *//* [clearcase]modification history-------------------01d,12may05,job fix apigen comments01c,18apr05,job update copyright notices01b,16feb05,job apigen for documented APIs01a,24nov03,job update copyright information*//*DESCRIPTIONThis library contains oid2ip.c routines.INCLUDE FILES: snmp.h*/#include <wrn/wm/snmp/engine/asn1conf.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/localio.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/decode.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/auxfuncs.h>/********************************************************************************* oid_to_ip - convert the encoded IP address in an object identifier* SYNOPSIS** \cs* int oid_to_ip* ( * int count, * OIDC_T * object_id, * UINT_32_T * addr * )* \ce** DESCRIPTION** This routine converts the encoded IP address in the instance part of an * object identifier into an IP address.** PARAMETERS* \is* \i <count>* Specify the number of octets in the object identifier occupied by IP address. * This value is usually 4. If it is less than 4, this routine zero-fills the * rest of the IP address.* \i <*object_id>* Specify an object ID.* \i <*addr>* Specify an IP Address.* \ie** RETURNS: If successful, this routine returns 0 and puts the IP address in * <*addr>. Otherwise, it returns 1.** ERRNO: N/A** SEE ALSO: ip_to_llist(), ip_to_rlist()*/int oid_to_ip(int tcount, OIDC_T *tlist, UINT_32_T *addr){ union { UINT_32_T laddr; OCTET_T baddr[4]; } ip_address; int i; ip_address.laddr = 0; if (tcount > 4) tcount = 4; for (i = 0; tcount; tcount--, i++) { if (*tlist > 255) return 1; /* not a legal component for an IP address */ ip_address.baddr[i] = (OCTET_T)*tlist++; } *addr = ip_address.laddr; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -