access.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 2005 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 <string.h>
#include "impl.h"
#include "error.h"
#include "trace.h"
#include "asn1.h"
#include "snmp.h"
#include "trap.h"
#include "agent_msg.h"
#include "access.h"
#define WILD_CARD_HOST_NAME "*"
#define WILD_CARD_ADDRESS 0
#define MAX_BUF_SIZE 256
/***** STATIC VARIABLES *****/
void init_manager_set ()
{
}
{
first_manager = mgr;
}
{
return first_manager;
}
/***********************************************************/
/*
* returns 0 if OK
* 1 if error
* -1 if fatal error
*/
{
Manager *m;
error_label[0] = '\0';
{
return NULL;
}
/* skip the ip adx for wild-card host */
/* try to find the IP address from the name */
{
return NULL;
}
}
/* checking for dup is on the wild-card host name */
/* check if this manager does not already exist */
for(m = first_manager; m; m = m->next_manager)
{
{
return m;
}
}
}else{
for(m = first_manager; m; m = m->next_manager)
{
{
return m;
}
}
}
/* allocate, initialize and link the new manager */
{
return NULL;
}
{
return NULL;
}
/* ip adx for wild-card host should be zero */
}else{
}
first_manager = new;
return new;
}
/***********************************************************/
/*
* returns a pointer to the manager if the request succeeds,
* otherwise returns NULL
*/
{
Manager *m;
{
error("BUG: is_valid_manager(): address is NULL");
return NULL;
}
if(first_manager == NULL)
{
return NULL;
}
for(m = first_manager; m; m = m->next_manager)
{
{
*mngr = m;
return m;
}
}
/* check for wild-card host */
for(m = first_manager; m; m = m->next_manager)
{
*mngr = m;
return m;
}
}
return m;
}
/***********************************************************/
void delete_manager_list()
{
while(first_manager)
{
if(first_manager->name)
{
}
}
}
{
while(mngr)
{
{
}
}
}
{
}
}
{
while(group)
{
{
}
}
}
{
while(slot)
{
{
}
}
}
void delete_efilter_list()
{
while(first_efilter)
{
if(first_efilter->name)
{
}
}
}
/***********************************************************/
void trace_managers()
{
Manager *m;
trace("MANAGERS:\n");
trace("---------\n");
for(m = first_manager; m; m = m->next_manager)
{
trace("%-30s %-20s\n",
m->name,
}
trace("\n");
}
/***********************************************************/
/*
* returns 0 if OK
* 1 if error
* -1 if fatal error
*/
{
int ret;
Community *c;
error_label[0] = '\0';
{
return -1;
}
if(name[0] == '\0')
{
return -1;
}
{
return -1;
}
for(c = first_community; c; c = c->next_community)
{
if(ret > 0)
{
break;
}
else
if(ret == 0)
{
return 1;
}
last = c;
}
{
return -1;
}
{
return -1;
}
if(last)
{
}
else
{
}
new->next_community = c;
return 0;
}
{
{
return ap->access_type;
}
return -1;
}
/***********************************************************/
/* returns True or False */
{
int access_type;
{
error("BUG: is_valid_community(): name is NULL");
return False;
}
if( (type != GETNEXT_REQ_MSG )
&& (type != GET_REQ_MSG)
&& (type != SET_REQ_MSG) )
{
return False;
}
return False;
}
if(type != SET_REQ_MSG)
{
return True;
}
else
{
if(access_type == READ_WRITE)
{
return True;
}
else
{
return False;
}
}
}
/***********************************************************/
void delete_community_list()
{
while(first_community)
{
if(first_community->name)
{
}
}
}
/***********************************************************/
{
}
{
Community *c;
trace("\tCOMMUNITIES(");
switch(ap->access_type)
{
case READ_ONLY:
break;
case READ_WRITE:
break;
}
trace("): ");
trace("\n");
}
void trace_communities(Community *c)
{
}
/***********************************************************/
{
while(comm)
{
{
}
}
}
{
}
}
{
}
}
{
}
{
}
{
return;
while(mgr)
{
while (as) {
}
}
}
{
}else{
}
}
{
else{
}
}
{
EFilter *m;
error_label[0] = '\0';
{
return NULL;
}
for(m = first_efilter; m; m = m->next_efilter)
{
{
return m;
}
}
/* allocate, initialize and link the new efilter */
{
return NULL;
}
{
return NULL;
}
first_efilter = new;
return new;
}
{
TrapSlot *m;
if(num < 0)
{
return NULL;
}
{
{
return m;
}
}
/* allocate, initialize and link the new efilter */
{
return NULL;
}
return new;
}
{
}else{
}
}
{
/* find the trap slot in the filter */
/* create subgroup, attach submember to subgroup */
/* insert subgroup into the trap slot */
int idx;
error("malloc() failed");
}
/* The efilter list may contain duplicate entries because
the agent ACL file may be read several times. This seems
to be necessary to mantain other functionality in the ACL
such as specifying managers. The following hack makes sure
the trap is sent to each host only by not allowing duplicate
members in an efilter.
*/
}else { /* at least one sub_group exists */
} else /* don't add duplicate */
}
}
}
{
Manager *m;
for(m=mngr;m;m=m->next_manager){
trace("\t\t%s %s\n",
m->name,
inet_ntoa(m->ip_address));
}
}
{
}
{
}
{
}
void trace_filter()
{
trace("#EFILTER:\n");
{
}
trace("\n");
}
/**** Enterprise related functions *****/
void trace_name_oid_pair()
{
trace("NAME_OID_PAIR:\n");
trace("\n");
}
{
}
return NULL;
}
{
char *str;
/* first " for name */
str++;
/* second " for name */
*str = '\0';
str++;
/* first " for oid_str*/
str++;
/* second " for oid_str*/
*str = '\0';
error("calloc failed");
return NULL;
}
return(NULL);
}
return np;
}
{
char inbuf[MAX_BUF_SIZE];
}
}
void load_enterprise_oid(char* filename)
{
char inbuf[MAX_BUF_SIZE];
return;
}
/* insert np */
}
}
/* insert a couple of extra name-oid pairs:
sun, snmp
*/
}
{
{
}
return NULL;
}
{
return NULL;
}
{
int trap_num;
else
}
}
}
}