1216295Ssyrinx/*- 2216295Ssyrinx * Copyright (c) 2006 The FreeBSD Project 3216295Ssyrinx * All rights reserved. 4216295Ssyrinx * 5216295Ssyrinx * Author: Shteryana Shopova <syrinx@FreeBSD.org> 6216295Ssyrinx * 7216295Ssyrinx * Redistribution of this software and documentation and use in source and 8216295Ssyrinx * binary forms, with or without modification, are permitted provided that 9216295Ssyrinx * the following conditions are met: 10216295Ssyrinx * 11216295Ssyrinx * 1. Redistributions of source code or documentation must retain the above 12216295Ssyrinx * copyright notice, this list of conditions and the following disclaimer. 13216295Ssyrinx * 2. Redistributions in binary form must reproduce the above copyright 14216295Ssyrinx * notice, this list of conditions and the following disclaimer in the 15216295Ssyrinx * documentation and/or other materials provided with the distribution. 16216295Ssyrinx * 17216295Ssyrinx * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18216295Ssyrinx * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19216295Ssyrinx * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20216295Ssyrinx * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21216295Ssyrinx * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22216295Ssyrinx * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23216295Ssyrinx * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24216295Ssyrinx * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25216295Ssyrinx * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26216295Ssyrinx * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27216295Ssyrinx * SUCH DAMAGE. 28216295Ssyrinx * 29216295Ssyrinx * Textual conventions for snmp 30216295Ssyrinx * 31216295Ssyrinx * $FreeBSD: releng/10.2/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.h 216295 2010-12-08 14:30:25Z syrinx $ 32216295Ssyrinx */ 33216295Ssyrinx 34216295Ssyrinx#ifndef _BSNMP_TEXT_CONV_H_ 35216295Ssyrinx#define _BSNMP_TEXT_CONV_H_ 36216295Ssyrinx 37216295Ssyrinx/* Variable display length string. */ 38216295Ssyrinx#define SNMP_VAR_STRSZ -1 39216295Ssyrinx 40216295Ssyrinx/* 41216295Ssyrinx * 11 bytes - octets that represent DateAndTime Textual convention 42216295Ssyrinx * and the size of string used to diplay that. 43216295Ssyrinx */ 44216295Ssyrinx#define SNMP_DATETIME_OCTETS 11 45216295Ssyrinx#define SNMP_DATETIME_STRSZ 32 46216295Ssyrinx 47216295Ssyrinx/* 48216295Ssyrinx * 6 bytes - octets that represent PhysAddress Textual convention 49216295Ssyrinx * and the size of string used to diplay that. 50216295Ssyrinx */ 51216295Ssyrinx#define SNMP_PHYSADDR_OCTETS 6 52216295Ssyrinx#define SNMP_PHYSADDR_STRSZ 19 53216295Ssyrinx 54216295Ssyrinx/* NTPTimeStamp. */ 55216295Ssyrinx#define SNMP_NTP_TS_OCTETS 8 56216295Ssyrinx#define SNMP_NTP_TS_STRSZ 10 57216295Ssyrinx 58216295Ssyrinx/* BridgeId. */ 59216295Ssyrinx#define SNMP_BRIDGEID_OCTETS 8 60216295Ssyrinx#define SNMP_BRIDGEID_STRSZ 25 61216295Ssyrinx#define SNMP_MAX_BRIDGE_PRIORITY 65535 62216295Ssyrinx 63216295Ssyrinx/* BridgePortId. */ 64216295Ssyrinx#define SNMP_BPORT_OCTETS 2 65216295Ssyrinx#define SNMP_BPORT_STRSZ 7 66216295Ssyrinx#define SNMP_MAX_BPORT_PRIORITY 255 67216295Ssyrinx 68216295Ssyrinx/* InetAddress. */ 69216295Ssyrinx#define SNMP_INADDRS_STRSZ INET6_ADDRSTRLEN 70216295Ssyrinx 71216295Ssyrinxenum snmp_tc { 72216295Ssyrinx SNMP_STRING = 0, 73216295Ssyrinx SNMP_DISPLAYSTRING = 1, 74216295Ssyrinx SNMP_DATEANDTIME = 2, 75216295Ssyrinx SNMP_PHYSADDR = 3, 76216295Ssyrinx SNMP_ATMESI = 4, 77216295Ssyrinx SNMP_NTP_TIMESTAMP = 5, 78216295Ssyrinx SNMP_MACADDRESS = 6, 79216295Ssyrinx SNMP_BRIDGE_ID = 7, 80216295Ssyrinx SNMP_BPORT_ID = 8, 81216295Ssyrinx SNMP_INETADDRESS = 9, 82216295Ssyrinx SNMP_TC_OWN = 10, 83216295Ssyrinx SNMP_UNKNOWN, /* keep last */ 84216295Ssyrinx}; 85216295Ssyrinx 86216295Ssyrinxtypedef char * (*snmp_oct2tc_f) (uint32_t len, char *octs, char *buf); 87216295Ssyrinxtypedef char * (*snmp_tc2oid_f) (char *str, struct asn_oid *oid); 88216295Ssyrinxtypedef int32_t (*snmp_tc2oct_f) (struct snmp_value *value, char *string); 89216295Ssyrinx 90216295Ssyrinxenum snmp_tc snmp_get_tc(char *str); 91216295Ssyrinxchar *snmp_oct2tc(enum snmp_tc tc, uint32_t len, char *octets); 92216295Ssyrinxchar *snmp_tc2oid(enum snmp_tc tc, char *str, struct asn_oid *oid); 93216295Ssyrinxint32_t snmp_tc2oct(enum snmp_tc tc, struct snmp_value *value, char *string); 94216295Ssyrinx 95216295Ssyrinx#endif /* _BSNMP_TEXT_CONV_H_ */ 96