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