10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*3820Spd155743 * Common Development and Distribution License (the "License"). 6*3820Spd155743 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*3820Spd155743 * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate * 21*3820Spd155743 */ 22*3820Spd155743 23*3820Spd155743 /* 24*3820Spd155743 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 250Sstevel@tonic-gate * Use is subject to license terms. 260Sstevel@tonic-gate */ 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * HISTORY 300Sstevel@tonic-gate * 5-28-96 Jerry Yeung Three phase set protocol(ThreePhase) 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifndef _SESSION_H_ 340Sstevel@tonic-gate #define _SESSION_H_ 350Sstevel@tonic-gate 360Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 370Sstevel@tonic-gate 380Sstevel@tonic-gate typedef enum _Phase { PHASE_1=1, PHASE_2, PHASE_3} Phase; 390Sstevel@tonic-gate 400Sstevel@tonic-gate 410Sstevel@tonic-gate /***** GLOBAL CONSTANTS *****/ 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* states of a request */ 440Sstevel@tonic-gate #define REQUEST_STARTED 1 450Sstevel@tonic-gate #define REQUEST_COMPLETED 2 460Sstevel@tonic-gate 470Sstevel@tonic-gate 480Sstevel@tonic-gate /***** GLOBAL TYPES *****/ 490Sstevel@tonic-gate 500Sstevel@tonic-gate typedef struct _Agent_List { 510Sstevel@tonic-gate struct _Agent_List *next; 520Sstevel@tonic-gate struct _Agent *agent; 530Sstevel@tonic-gate } Agent_List; 540Sstevel@tonic-gate 550Sstevel@tonic-gate 560Sstevel@tonic-gate typedef struct _Request { 570Sstevel@tonic-gate struct _Request *next_request; 580Sstevel@tonic-gate 590Sstevel@tonic-gate struct _Session *session; 600Sstevel@tonic-gate struct _Subtree *subtree; /* associated subtree */ 610Sstevel@tonic-gate Agent_List *visited_agent_list; /* list of the agents visited so far */ 620Sstevel@tonic-gate 630Sstevel@tonic-gate u_long request_id; 640Sstevel@tonic-gate 650Sstevel@tonic-gate SNMP_pdu *pdu; /* SNMP request */ 660Sstevel@tonic-gate 670Sstevel@tonic-gate u_long flags; /* cf below */ 680Sstevel@tonic-gate 690Sstevel@tonic-gate int state; /* STARTED or COMPLETED */ 700Sstevel@tonic-gate SNMP_pdu *response; /* response of the agent to the pdu */ 710Sstevel@tonic-gate 720Sstevel@tonic-gate struct timeval time; /* time when the pdu was sent */ 730Sstevel@tonic-gate struct timeval expire; /* time when the Request will timeout */ 740Sstevel@tonic-gate } Request; 750Sstevel@tonic-gate 760Sstevel@tonic-gate 770Sstevel@tonic-gate typedef struct _Session { 780Sstevel@tonic-gate struct _Session *next_session; 790Sstevel@tonic-gate 800Sstevel@tonic-gate u_long session_id; 810Sstevel@tonic-gate 820Sstevel@tonic-gate Address address; /* the address of the SNMP application */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate SNMP_pdu *pdu; /* the "original" SNMP request */ 850Sstevel@tonic-gate 860Sstevel@tonic-gate int n_variables; /* number of variables in the */ 870Sstevel@tonic-gate /* "original" SNMP request */ 880Sstevel@tonic-gate 890Sstevel@tonic-gate u_long o_flags; /* cf below */ 900Sstevel@tonic-gate u_long i_flags; /* cf below */ 910Sstevel@tonic-gate 920Sstevel@tonic-gate struct _Request *first_request; /* the request list of the session */ 930Sstevel@tonic-gate 940Sstevel@tonic-gate } Session; 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* Three Phase */ 970Sstevel@tonic-gate typedef struct _Three_Phase { 980Sstevel@tonic-gate SNMP_pdu *origin_pdu; 990Sstevel@tonic-gate SNMP_pdu *cur_pdu; 1000Sstevel@tonic-gate Phase state; 1010Sstevel@tonic-gate SNMP_variable *variable; 1020Sstevel@tonic-gate Session* session; 1030Sstevel@tonic-gate } Three_Phase; 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* explanation for the flags: */ 1080Sstevel@tonic-gate /* -------------------------- */ 1090Sstevel@tonic-gate /* */ 1100Sstevel@tonic-gate /* Each bit in a flags corresponds to a variable */ 1110Sstevel@tonic-gate /* in the "original" SNMP request. */ 1120Sstevel@tonic-gate /* For example, the o_flag 0x7 in the Session means */ 1130Sstevel@tonic-gate /* that the "original" SNMP request contains 3 */ 1140Sstevel@tonic-gate /* variables, the flags 0x5 of the Request 0 means that */ 1150Sstevel@tonic-gate /* this Request handles the 1st and the 3rd */ 1160Sstevel@tonic-gate /* variable of the "original" SNMP request, the flags */ 1170Sstevel@tonic-gate /* 0x2 of the Request 1 means that this Request */ 1180Sstevel@tonic-gate /* handles the 2nd variable of the "original" SNMP */ 1190Sstevel@tonic-gate /* request. When a Request is completed, its flags */ 1200Sstevel@tonic-gate /* are ORed with the i_flags of its Session, so as soon */ 1210Sstevel@tonic-gate /* as o_flags == i_flags, we known that all the Requests*/ 1220Sstevel@tonic-gate /* are completed and we start to compute the response */ 1230Sstevel@tonic-gate /* of the "original" SNMP request. */ 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate /***** GLOBAL FUNCTIONS *****/ 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate extern void trace_sessions(); 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate /* session_list_delete() will delete the whole session list */ 1310Sstevel@tonic-gate extern void session_list_delete(); 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate extern void session_dispatch(); 1340Sstevel@tonic-gate extern void session_read(); 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate extern void session_select_info(struct timeval *tv); 1370Sstevel@tonic-gate extern void session_timeout(); 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate extern int any_outstanding_session(); 1400Sstevel@tonic-gate 141*3820Spd155743 extern void session_close(Session *session); 142*3820Spd155743 extern void session_free(Session *session); 143*3820Spd155743 extern void request_list_free(Request *request_list); 144*3820Spd155743 extern void request_free(Request *request); 1450Sstevel@tonic-gate 146*3820Spd155743 #endif /* _SESSION_H_ */ 1470Sstevel@tonic-gate 148