agent.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 1997 Sun Microsystems, Inc. All Rights Reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <stdio.h>
#include "impl.h"
#include "error.h"
#include "trace.h"
#include "pdu.h"
#include "access.h"
#include "agent.h"
#include "subtree.h"
#include "session.h"
#include "sh_table.h"
/***** STATIC VARIABLES *****/
int sap_agent_id = 1;
/* the agent list */
/****************************************************************/
void trace_agents()
{
trace("AGENTS:\n");
{
trace("\t%X %-30s %-30s %8d %8d %8d %8d %X\n",
ap,
ap->first_manager);
}
trace("\n");
}
/****************************************************************/
/* We must invoke subtree_list_delete() before invoking */
/* this function because the first_agent_subtree member */
/* of the agent structures should be NULL */
void agent_list_delete()
{
while(ap)
{
agent_free(ap);
}
first_agent = NULL;
return;
}
/****************************************************************/
{
}
}
/* The fisrt_agent_subtree member of the agent */
/* structure should be NULL */
{
{
return;
}
if(ap->first_agent_subtree)
{
error("BUG: agent_free(): first_agent_subtree not NULL");
}
/* free the extra element */
return;
}
/****************************************************************/
{
{
{
return ap;
}
}
return NULL;
}
{
{
{
return ap;
}
}
return NULL;
}
/* agent_find() is used to check if we have not */
/* two SNMP agents registered on the same UDP port */
{
{
{
return ap;
}
}
return NULL;
}
{
}
}
{
{
break;
}
}else{
}
}
{
sap_agent_id--;
}
}
/*
** Maximum number of consecutive timeouts before snmpdx will purge the
** subagent from the internal tables.
*/
static int MaxFails = 5 ;
int SetFailThreshold ( int v )
{
MaxFails = v ;
return 0 ;
}
/****************************************************************/
/* destroy hanging agent when no outstanding session which
relates to the agent */
void destroy_hanging_agent()
{
int rslt ;
continue ;
/* Even if the subagent isn't responding, we need to let the
** sessions timeout and rip-down thru the normal mechanism.
*/
continue ;
/* subagent is quiesced and not talking -- check proces */
error ("Subagent died: %s PID=%d -- deleted from the agent table",
agent_destroy (ap) ;
return ; /* only kill one at a time */
}
/* subagent appears to be alive but hung and not responding */
continue ;
/* If the subagent receives a request with a bad community string
// it is obliged to discard the string and _not_ respond. This
// doesn't jive with our stateful relay model. We timeout and
// can't distinguish a hung agent from an agent that is dropping
// packets because of the "bad" community strings. Thus, before
// putting the ax to an agent we see if it's still alive.
//
// The ssa_subagent_is_alive() routine "pings" the subagent with
// a valid but innocuous request packet. Unfortunately the dummy
// we build has the community string set to "public". If the subagent
// doesn't accept "public" requests it will ignore our ping attempt.
//
// Sunil indicated that snmpdx would pre-validate incoming community
// strings and only pass requests that would be accepted by the subagent.
// This doesn't appear to work as advertised.
*/
if (ssa_subagent_is_alive (ap)) {
ap->numOfFailRequest = 0 ;
continue ;
}
return;
}
}