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 32 #ifndef _BSNMP_TEXT_CONV_H_ 33 #define _BSNMP_TEXT_CONV_H_ 34 35 /* Variable display length string. */ 36 #define SNMP_VAR_STRSZ -1 37 38 /* 39 * 11 bytes - octets that represent DateAndTime Textual convention 40 * and the size of string used to display that. 41 */ 42 #define SNMP_DATETIME_OCTETS 11 43 #define SNMP_DATETIME_STRSZ 32 44 45 /* 46 * 6 bytes - octets that represent PhysAddress Textual convention 47 * and the size of string used to display that. 48 */ 49 #define SNMP_PHYSADDR_OCTETS 6 50 #define SNMP_PHYSADDR_STRSZ 19 51 52 /* NTPTimeStamp. */ 53 #define SNMP_NTP_TS_OCTETS 8 54 #define SNMP_NTP_TS_STRSZ 10 55 56 /* BridgeId. */ 57 #define SNMP_BRIDGEID_OCTETS 8 58 #define SNMP_BRIDGEID_STRSZ 25 59 #define SNMP_MAX_BRIDGE_PRIORITY 65535 60 61 /* BridgePortId. */ 62 #define SNMP_BPORT_OCTETS 2 63 #define SNMP_BPORT_STRSZ 7 64 #define SNMP_MAX_BPORT_PRIORITY 255 65 66 /* InetAddress. */ 67 #define SNMP_INADDRS_STRSZ INET6_ADDRSTRLEN 68 69 enum snmp_tc { 70 SNMP_STRING = 0, 71 SNMP_DISPLAYSTRING = 1, 72 SNMP_DATEANDTIME = 2, 73 SNMP_PHYSADDR = 3, 74 SNMP_ATMESI = 4, 75 SNMP_NTP_TIMESTAMP = 5, 76 SNMP_MACADDRESS = 6, 77 SNMP_BRIDGE_ID = 7, 78 SNMP_BPORT_ID = 8, 79 SNMP_INETADDRESS = 9, 80 SNMP_TC_OWN = 10, 81 SNMP_UNKNOWN, /* keep last */ 82 }; 83 84 typedef char * (*snmp_oct2tc_f) (uint32_t len, char *octs, char *buf); 85 typedef char * (*snmp_tc2oid_f) (char *str, struct asn_oid *oid); 86 typedef int32_t (*snmp_tc2oct_f) (struct snmp_value *value, char *string); 87 88 enum snmp_tc snmp_get_tc(char *str); 89 char *snmp_oct2tc(enum snmp_tc tc, uint32_t len, char *octets); 90 char *snmp_tc2oid(enum snmp_tc tc, char *str, struct asn_oid *oid); 91 int32_t snmp_tc2oct(enum snmp_tc tc, struct snmp_value *value, char *string); 92 93 #endif /* _BSNMP_TEXT_CONV_H_ */ 94