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