xref: /onnv-gate/usr/src/cmd/agents/snmp/snmplib/pdu.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright (c) 1998 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate  * All rights reserved.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #ifndef _PDU_H_
30*0Sstevel@tonic-gate #define _PDU_H_
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/types.h>
33*0Sstevel@tonic-gate #include "impl.h"
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate /***** GLOBAL TYPES *****/
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate typedef struct _SNMP_value {
39*0Sstevel@tonic-gate 	union {
40*0Sstevel@tonic-gate 		Integer integer;
41*0Sstevel@tonic-gate 		String string;
42*0Sstevel@tonic-gate 		Oid oid;
43*0Sstevel@tonic-gate 	} val;
44*0Sstevel@tonic-gate } SNMP_value;
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate #define v_integer val.integer
47*0Sstevel@tonic-gate #define v_string val.string
48*0Sstevel@tonic-gate #define v_oid val.oid
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate typedef struct _SNMP_variable {
52*0Sstevel@tonic-gate 	struct _SNMP_variable *next_variable;/* NULL for last variable */
53*0Sstevel@tonic-gate 	Oid		name;		/* Object identifier of variable */
54*0Sstevel@tonic-gate 	u_char		type;		/* ASN.1 type of variable */
55*0Sstevel@tonic-gate 	union {				/* value of variable */
56*0Sstevel@tonic-gate 		int32_t	*integer;
57*0Sstevel@tonic-gate 		u_char	*string;
58*0Sstevel@tonic-gate 		Subid	*objid;
59*0Sstevel@tonic-gate 	} val;
60*0Sstevel@tonic-gate 	int		val_len;	/* size of the buffer val in bytes */
61*0Sstevel@tonic-gate } SNMP_variable;
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate typedef struct _SNMP_pdu {
65*0Sstevel@tonic-gate 	int version;
66*0Sstevel@tonic-gate 	char *community;
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate 	int	type;			/* Type of this PDU */
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate 	uint32_t	request_id;		/* Request id */
71*0Sstevel@tonic-gate 	uint32_t	error_status;		/* Error status */
72*0Sstevel@tonic-gate 	uint32_t	error_index;		/* Error index */
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate 	/* Trap information */
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate 	Oid	enterprise;		/* System Object Identifier */
78*0Sstevel@tonic-gate 	IPAddress ip_agent_addr;	/* Address of object generating trap */
79*0Sstevel@tonic-gate 	int	generic;		/* Generic trap */
80*0Sstevel@tonic-gate 	int	specific;		/* Specific trap */
81*0Sstevel@tonic-gate 	uint32_t	time_stamp;		/* Time stamp */
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate 	SNMP_variable *first_variable;
84*0Sstevel@tonic-gate } SNMP_pdu;
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate /***** GLOBAL FUNCTIONS *****/
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate extern SNMP_variable *snmp_pdu_append_null_variable(SNMP_pdu *pdu, Oid *name, char *error_label);
90*0Sstevel@tonic-gate extern SNMP_variable *snmp_pdu_append_typed_variable(SNMP_pdu *pdu, Oid *name,
91*0Sstevel@tonic-gate 	u_char type, SNMP_value *value, char *error_label);
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate extern SNMP_pdu *snmp_pdu_receive(int sd, Address *address, char *error_label);
95*0Sstevel@tonic-gate extern int snmp_pdu_send(int sd, Address *address, SNMP_pdu *pdu, char *error_label);
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate extern void snmp_pdu_free(SNMP_pdu *pdu);
98*0Sstevel@tonic-gate extern void snmp_variable_free(SNMP_variable *variable);
99*0Sstevel@tonic-gate extern void snmp_variable_list_free(SNMP_variable *variable_list);
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate extern SNMP_pdu *snmp_pdu_new(char *error_label);
103*0Sstevel@tonic-gate extern SNMP_variable *snmp_variable_new(char *error_label);
104*0Sstevel@tonic-gate extern SNMP_variable *snmp_typed_variable_new(Oid *name, u_char type, SNMP_value *value, char *error_label);
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate extern SNMP_variable *snmp_typed_variable_append(SNMP_variable *list, Oid *name, u_char type, SNMP_value *value, char *error_label);
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate extern SNMP_pdu *snmp_pdu_dup(SNMP_pdu *pdu, char *error_label);
109*0Sstevel@tonic-gate extern SNMP_variable *snmp_variable_dup(SNMP_variable *variable, char *error_label);
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate extern SNMP_variable *ssa_append_integer_variable(SNMP_variable *list, Oid *oid,int num, char *error_label, u_char asn1_type);
112*0Sstevel@tonic-gate extern SNMP_variable *ssa_append_string_variable(SNMP_variable *list, Oid *oid, String str, char *error_label);
113*0Sstevel@tonic-gate extern SNMP_variable *ssa_append_oid_variable(SNMP_variable *list, Oid *oid, Oid name, char *error_label);
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate 
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate extern void trace_snmp_pdu(SNMP_pdu *pdu);
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate #endif
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate 
124*0Sstevel@tonic-gate 
125