xref: /onnv-gate/usr/src/cmd/agents/snmp/agent/access.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  * Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
23*0Sstevel@tonic-gate  * Use is subject to license terms.
24*0Sstevel@tonic-gate  */
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*0Sstevel@tonic-gate 
28*0Sstevel@tonic-gate #include <sys/types.h>
29*0Sstevel@tonic-gate #include "impl.h"
30*0Sstevel@tonic-gate #include "pdu.h"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifndef _ACCESS_H_
33*0Sstevel@tonic-gate #define _ACCESS_H_
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #define READ_ONLY	1
36*0Sstevel@tonic-gate #define READ_WRITE	2
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate typedef struct _Community {
39*0Sstevel@tonic-gate 	struct _Community *next_community;
40*0Sstevel@tonic-gate 	char *name;
41*0Sstevel@tonic-gate 	int type;
42*0Sstevel@tonic-gate } Community;
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate typedef struct _AccessPolicy {
45*0Sstevel@tonic-gate 	Community *first_community;
46*0Sstevel@tonic-gate 	int access_type; /* one access type for all the communities */
47*0Sstevel@tonic-gate 	int count;
48*0Sstevel@tonic-gate } AccessPolicy;
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate typedef struct _AccessServer {
51*0Sstevel@tonic-gate 	struct _AccessServer *next_acc_server;
52*0Sstevel@tonic-gate 	AccessPolicy *first_acc_policy;
53*0Sstevel@tonic-gate 	int attached;
54*0Sstevel@tonic-gate } AccessServer;
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate typedef struct _Manager {
57*0Sstevel@tonic-gate 	struct _Manager *next_manager;
58*0Sstevel@tonic-gate 	char *name;
59*0Sstevel@tonic-gate 	IPAddress ip_address;
60*0Sstevel@tonic-gate 	AccessServer *first_acc_server;
61*0Sstevel@tonic-gate } Manager;
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate /****************************************************
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate --------------
66*0Sstevel@tonic-gate | Manager     |-->
67*0Sstevel@tonic-gate | xxxxxxx     |
68*0Sstevel@tonic-gate | :name       |
69*0Sstevel@tonic-gate | :ip_address |
70*0Sstevel@tonic-gate --------------
71*0Sstevel@tonic-gate    |
72*0Sstevel@tonic-gate    V
73*0Sstevel@tonic-gate ----------     --------------     -------------
74*0Sstevel@tonic-gate | Manager |-->| AccessServer |-->| AccessServer|-->
75*0Sstevel@tonic-gate ----------     --------------     -------------
76*0Sstevel@tonic-gate    |		    0
77*0Sstevel@tonic-gate 		    0 (link to shared object)
78*0Sstevel@tonic-gate    V		    V
79*0Sstevel@tonic-gate 		-------------     ---------     ---------
80*0Sstevel@tonic-gate 		|AccessPolicy|-->|Community|-->|Community|-->
81*0Sstevel@tonic-gate 		|xxxxxxxxxxxx|   |xxxxxxxxx|    ---------
82*0Sstevel@tonic-gate 		|:access_type|   |:name	   |
83*0Sstevel@tonic-gate 		-------------     ---------
84*0Sstevel@tonic-gate 1
85*0Sstevel@tonic-gate ******************************************************/
86*0Sstevel@tonic-gate typedef struct _SubMember {
87*0Sstevel@tonic-gate 	Manager *first_manager;
88*0Sstevel@tonic-gate 	char *community_string;
89*0Sstevel@tonic-gate 	int count;
90*0Sstevel@tonic-gate } SubMember;
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate typedef struct _SubGroup {
93*0Sstevel@tonic-gate 	struct _SubGroup *next_sub_group;
94*0Sstevel@tonic-gate 	SubMember *first_sub_member;
95*0Sstevel@tonic-gate } SubGroup;
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate typedef struct _TrapSlot {
98*0Sstevel@tonic-gate 	struct _TrapSlot *next_trap_slot;
99*0Sstevel@tonic-gate 	SubGroup *first_sub_group;
100*0Sstevel@tonic-gate 	int num;
101*0Sstevel@tonic-gate } TrapSlot;
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate typedef struct _EFilter {
104*0Sstevel@tonic-gate 	struct _EFilter *next_efilter;
105*0Sstevel@tonic-gate 	TrapSlot *first_trap_slot;
106*0Sstevel@tonic-gate 	Oid  *enterprise;
107*0Sstevel@tonic-gate 	char *name;
108*0Sstevel@tonic-gate 	int type; /* generic or specific */
109*0Sstevel@tonic-gate } EFilter;
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate /****************************************************
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate --------------
114*0Sstevel@tonic-gate | EFilter     |-->
115*0Sstevel@tonic-gate | xxxxxxx     |
116*0Sstevel@tonic-gate | :enterprise |
117*0Sstevel@tonic-gate --------------
118*0Sstevel@tonic-gate    | next_efilter
119*0Sstevel@tonic-gate    V
120*0Sstevel@tonic-gate ---------- first_trap_slot -----------  next_trap_slot   ---------
121*0Sstevel@tonic-gate |EFilter |--------------->| TrapSlot  |---------------->| TrapSlot|-->
122*0Sstevel@tonic-gate ----------     		  | xxxxxxxxx |  		 ---------
123*0Sstevel@tonic-gate    |		          | : num     |
124*0Sstevel@tonic-gate    V		           -----------
125*0Sstevel@tonic-gate 				| first_sub_group
126*0Sstevel@tonic-gate 				V
127*0Sstevel@tonic-gate 			------------------                ------------
128*0Sstevel@tonic-gate 			| SubGroup        |next_sub_group | SubGroup |
129*0Sstevel@tonic-gate 			| xxxxxxxxxxxxxxxx|--------------> ----------
130*0Sstevel@tonic-gate 			------------------
131*0Sstevel@tonic-gate 				0 first_sub_member
132*0Sstevel@tonic-gate 				0
133*0Sstevel@tonic-gate 				V
134*0Sstevel@tonic-gate 			    -----------------
135*0Sstevel@tonic-gate 			   | SubMember 	     |first_manager ---------
136*0Sstevel@tonic-gate 			   | xxxxxxxxxxxxxxx |------------>| Manager |
137*0Sstevel@tonic-gate 			   |:community_string|		    ---------
138*0Sstevel@tonic-gate 			    -----------------
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate ******************************************************/
141*0Sstevel@tonic-gate typedef struct _NameOidPair {
142*0Sstevel@tonic-gate   struct _NameOidPair *next;
143*0Sstevel@tonic-gate   char *name;
144*0Sstevel@tonic-gate   Oid *oid;
145*0Sstevel@tonic-gate } NameOidPair;
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate /* routines for trap */
148*0Sstevel@tonic-gate extern EFilter* efilter_add(char* name, char *error_label);
149*0Sstevel@tonic-gate extern TrapSlot* trap_slot_add(int num,EFilter *efilter,char *error_label);
150*0Sstevel@tonic-gate extern void sub_group_add_tail(TrapSlot *slot,SubGroup *group);
151*0Sstevel@tonic-gate extern void sub_member_free(SubMember *mem);
152*0Sstevel@tonic-gate extern void sub_group_list_free(SubGroup *group);
153*0Sstevel@tonic-gate extern void trap_slot_list_free(TrapSlot *slot);
154*0Sstevel@tonic-gate extern void mem_filter_join(int low,int high,SubMember *mem,EFilter *filter);
155*0Sstevel@tonic-gate extern void trace_filter();
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate extern void init_manager_set();
158*0Sstevel@tonic-gate extern Manager* get_curr_manager_set();
159*0Sstevel@tonic-gate extern Manager* manager_add(char *name, char *error_label);
160*0Sstevel@tonic-gate extern Manager* is_valid_manager(Address *address, Manager **mngr);
161*0Sstevel@tonic-gate extern void delete_manager_list();
162*0Sstevel@tonic-gate extern void manager_list_free(Manager *mngr);
163*0Sstevel@tonic-gate extern void trace_managers();
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate extern int community_add(char *name, int type, char *error_label);
166*0Sstevel@tonic-gate extern int is_valid_community(char *name, int type, Manager *mngr);
167*0Sstevel@tonic-gate extern void delete_community_list();
168*0Sstevel@tonic-gate extern void trace_communities(Community *c);
169*0Sstevel@tonic-gate extern void trace_access_server(AccessServer *as);
170*0Sstevel@tonic-gate extern void trace_access_policy(AccessPolicy *ap);
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate extern void community_attach(AccessPolicy *ap, Community *comm);
173*0Sstevel@tonic-gate extern void access_server_add_tail(Manager* mngr, AccessServer *acc_server);
174*0Sstevel@tonic-gate extern void access_server_free(AccessServer *as);
175*0Sstevel@tonic-gate extern void access_policy_list_free(AccessPolicy *ap);
176*0Sstevel@tonic-gate extern int get_access_type(Manager *mngr,char *name);
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate /* name oid pair loading */
179*0Sstevel@tonic-gate extern void trace_name_oid_pair();
180*0Sstevel@tonic-gate extern Oid *enterprise_name_to_oid(char *name);
181*0Sstevel@tonic-gate extern void load_enterprise_oid(char* filename);
182*0Sstevel@tonic-gate 
183*0Sstevel@tonic-gate extern void trap_filter_action(Oid *oid,int generic,int specific,
184*0Sstevel@tonic-gate 	uint32_t time_stamp,SNMP_variable *variables);
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate #endif
187