⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oid2str.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* oid2str.c - oid2str.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 1998 Integrated Systems, Inc. *  All rights reserved. *//* * $Log: oid2str.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:30  sar * Update version stamp to match release * * Revision 1.7  1998/09/04 15:11:06  sar * Added some casts to try and keep the msc compiler happy and not * complaining about signed/unsigned mismatches. * * Revision 1.6  1998/07/20 02:02:34  sar * Added a check to see if the subid is > 0xff in which case we * return an error * * Revision 1.5  1998/07/01 01:41:02  sar * make sure we have some subids before trying to read one * * Revision 1.4  1998/06/19 20:18:51  sar * Make all files include asn1conf.h and snmp.h to make sure we get the * common code * * Revision 1.3  1998/06/05 18:52:55  sra * "#include <foo.h>" => "#include <envoy/h/foo.h>". * * Revision 1.2  1998/05/23 20:32:06  sar * Correct copyright statement * * Revision 1.1  1998/05/22 19:48:33  sar * Routines for translating from an object id to a string and back. * *//* [clearcase]modification history-------------------01e,12may05,job  fix apigen comments01d,18apr05,job  update copyright notices01c,04mar05,job  apigen update01b,16feb05,job  apigen for documented APIs01a,24nov03,job  update copyright information*//*DESCRIPTIONThis library contains oid2str.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/snmp.h>#include <wrn/wm/snmp/engine/auxfuncs.h>/********************************************************************************* oid_to_string - convert part of an object ID into a string* SYNOPSIS** \cs* int oid_to_string*     ( *     int          tcount, *     OIDC_T    *  tlist, *     ALENGTH_T *  blen, *     bits8_t   *  buffp, *     int          iflag *     )* \ce** DESCRIPTION** This routine converts part of an object ID into a string reducing each sub ID * to a byte in the string.** PARAMETERS* \is* \i <tcount>* Specify the length of the object ID pointed to by <tlist>.* \i <*tlist>* Specify the object identifier.* \i <blen>* On input, specifies the amount of space available in the buffer pointed to by * <buffp>. On output, it specifies the amount of space used by this string.* \i <*buffp>* Point to the string to be converted.* \i <iflag>* When zero (0), set <tcount> to the length of the string. Otherwise, the * length is the first sub ID.* \ie** RETURNS: If successful, this routine returns 0 and updates the value of * <blen>. If the required length exceeds the supplied buffer the routine, this * routine returns 1 and updates the value of <blen>. If the string length is * greater than <tcount> or a sub ID is larger than a byte (0xFF), this routine * returns -1.** ERRNO: N/A** SEE ALSO: string_to_oid()*/int  oid_to_string(int        tcount,		OIDC_T    *tlist,		ALENGTH_T *blen,		bits8_t   *buffp,		int        iflag){int temp_tcount;/* work out the length of the string and if necessary adjust the tlist ptr */if (iflag)    temp_tcount = tcount;else {    if ((tcount < 1) || (tlist[0] >= (OIDC_T)tcount))        return(-1);    temp_tcount = (int)tlist[0];    tlist++;    }if ((bits32_t)temp_tcount > (bits32_t)(*blen)) {    *blen = temp_tcount;    return(1);    }for(*blen = temp_tcount; temp_tcount; temp_tcount--, buffp++, tlist++) {    if (*tlist > 0xff)        return(-1);    *buffp = (bits8_t)((*tlist) & 0xff);    }return(0);}/********************************************************************************* string_to_oid - convert a string to an object ID* SYNOPSIS** \cs* int string_to_oid *     ( *     ALENGTH_T    blen, *     bits8_t   *  buffp, *     int          tcount, *     OIDC_T    *  tlist, *     int          iflag *     )* \ce** DESCRIPTION** This routine converts a string to an object ID. It converts each byte in the * string to a single sub ID in the object ID.** PARAMETERS* \is* \i <blen>* Specify the length in bytes of the string pointed to by <buffp>.* \i <*buffp>* Point to the string to be converted.* \i <tcount>* Specify number of components available in the object Id pointed to by * <tlist>.* \i <*tlist>* Specify the object identifier.* \i <iflag>* Insert the length as the first sub ID of the instance when set to 0.* \ie** RETURNS: If successful, this routine returns 0. If <blen> is greater than * <tcount>, it is an error and this routine returns -1.** ERRNO: N/A** SEE ALSO: oid_to_string()*/int  string_to_oid(ALENGTH_T  blen,		bits8_t   *buffp,		int        tcount,		OIDC_T    *tlist,		int        iflag){if (iflag == 0) {    if ((bits32_t)tcount < (bits32_t)(blen + 1))        return(-1);    *tlist = blen;    tlist++;    }else {    if ((bits32_t)tcount < (bits32_t)blen)        return(-1);    }for(; blen; blen--, buffp++, tlist++)    *tlist = *buffp;return(0);}

⌨️ 快捷键说明

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