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