1 /*- 2 * Copyright (c) 2006 The FreeBSD Project 3 * All rights reserved. 4 * 5 * Author: Shteryana Shopova <syrinx@FreeBSD.org> 6 * 7 * Redistribution of this software and documentation and use in source and 8 * binary forms, with or without modification, are permitted provided that 9 * the following conditions are met: 10 * 11 * 1. Redistributions of source code or documentation must retain the above 12 * copyright notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * Textual conventions for snmp 30 * 31 * $FreeBSD$ 32 */ 33 34 #ifndef _BSNMP_TEXT_CONV_H_ 35 #define _BSNMP_TEXT_CONV_H_ 36 37 /* Variable display length string. */ 38 #define SNMP_VAR_STRSZ -1 39 40 /* 41 * 11 bytes - octets that represent DateAndTime Textual convention 42 * and the size of string used to diplay that. 43 */ 44 #define SNMP_DATETIME_OCTETS 11 45 #define SNMP_DATETIME_STRSZ 32 46 47 /* 48 * 6 bytes - octets that represent PhysAddress Textual convention 49 * and the size of string used to diplay that. 50 */ 51 #define SNMP_PHYSADDR_OCTETS 6 52 #define SNMP_PHYSADDR_STRSZ 19 53 54 /* NTPTimeStamp. */ 55 #define SNMP_NTP_TS_OCTETS 8 56 #define SNMP_NTP_TS_STRSZ 10 57 58 /* BridgeId. */ 59 #define SNMP_BRIDGEID_OCTETS 8 60 #define SNMP_BRIDGEID_STRSZ 25 61 #define SNMP_MAX_BRIDGE_PRIORITY 65535 62 63 /* BridgePortId. */ 64 #define SNMP_BPORT_OCTETS 2 65 #define SNMP_BPORT_STRSZ 7 66 #define SNMP_MAX_BPORT_PRIORITY 255 67 68 /* InetAddress. */ 69 #define SNMP_INADDRS_STRSZ INET6_ADDRSTRLEN 70 71 enum snmp_tc { 72 SNMP_STRING = 0, 73 SNMP_DISPLAYSTRING = 1, 74 SNMP_DATEANDTIME = 2, 75 SNMP_PHYSADDR = 3, 76 SNMP_ATMESI = 4, 77 SNMP_NTP_TIMESTAMP = 5, 78 SNMP_MACADDRESS = 6, 79 SNMP_BRIDGE_ID = 7, 80 SNMP_BPORT_ID = 8, 81 SNMP_INETADDRESS = 9, 82 SNMP_TC_OWN = 10, 83 SNMP_UNKNOWN, /* keep last */ 84 }; 85 86 typedef char * (*snmp_oct2tc_f) (uint32_t len, char *octs, char *buf); 87 typedef char * (*snmp_tc2oid_f) (char *str, struct asn_oid *oid); 88 typedef int32_t (*snmp_tc2oct_f) (struct snmp_value *value, char *string); 89 90 enum snmp_tc snmp_get_tc(char *str); 91 char *snmp_oct2tc(enum snmp_tc tc, uint32_t len, char *octets); 92 char *snmp_tc2oid(enum snmp_tc tc, char *str, struct asn_oid *oid); 93 int32_t snmp_tc2oct(enum snmp_tc tc, struct snmp_value *value, char *string); 94 95 #endif /* _BSNMP_TEXT_CONV_H_ */ 96