trap.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 <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <syslog.h>
#include <string.h>
#include <netdb.h>
#include <nlist.h>
#include "snmp_msg.h"
#include "impl.h"
#include "trace.h"
#include "snmp.h"
#include "pdu.h"
#include "request.h"
#include "trap.h"
#include "error.h"
/***** GLOBAL VARIABLES *****/
char *trap_community = NULL;
/***** LOCAL TYPES *****/
typedef struct _Trap_Destinator {
struct _Trap_Destinator *next_trap_destinator;
char *name;
/***** LOCAL VARIABLES *****/
/********************************************************************/
{
error_label[0] = '\0';
if(enterprise == NULL)
{
return -1;
}
if(default_enterprise == NULL)
{
return -1;
}
return 0;
}
/********************************************************************/
int trap_send(IPAddress *ip_address, Oid *enterprise, int generic, int specific, SNMP_variable *variables, char *error_label)
{
static int my_ip_address_initialized = False;
static IPAddress my_ip_address;
struct sockaddr_in me;
int sd;
error_label[0] = '\0';
if(my_ip_address_initialized == False)
{
{
return -1;
}
}
{
return -1;
}
/* version, community */
if(trap_community == NULL)
{
}
else
{
}
{
return -1;
}
/* type */
/* enterprise */
if(enterprise == NULL)
{
{
}
else
{
enterprise = &sun_oid;
}
}
{
return -1;
}
/* agent_addr */
/* generic, specific */
/* time_stamp */
/* first_variable */
while(variables)
{
if(new_variable == NULL)
{
return -1;
}
if(last_variable)
{
}
else
{
}
}
/* sd */
if(sd < 0)
{
return -1;
}
{
return -1;
}
/* address */
{
return -1;
}
return 0;
}
/**********************************************************************/
{
static int my_ip_address_initialized = False;
static IPAddress my_ip_address;
struct sockaddr_in me;
int sd;
error_label[0] = '\0';
if (!i_flag) {
if(my_ip_address_initialized == False)
{
{
return -1;
}
}
}
{
return -1;
}
/* version, community */
{
}
else
{
}
{
return -1;
}
/* type */
/* enterprise */
if(enterprise == NULL)
{
{
}
else
{
enterprise = &sun_oid;
}
}
{
return -1;
}
/* agent_addr */
if (!i_flag) {
}
else {
}
/* generic, specific */
/* time_stamp */
if (time_stamp == -1U)
else
/* first_variable */
while(variables)
{
if(new_variable == NULL)
{
return -1;
}
if(last_variable)
{
}
else
{
}
}
/* sd */
if(sd < 0)
{
return -1;
}
{
return -1;
}
/* address */
if (trap_port == -1)
else
/* LINTED */
{
return -1;
}
return 0;
}
/**********************************************************************/
char *community,
int i_flag,
int generic,
int specific,
int trap_port,
char *error_label)
{
}
/********************************************************************/
/*
* returns 0 if OK
* 1 if error
* -1 if fatal error
*/
{
Trap_Destinator *d;
error_label[0] = '\0';
{
return -1;
}
{
return 1;
}
/* check if this trap destinator does not already exist */
for(d = first_trap_destinator; d; d = d->next_trap_destinator)
{
{
name);
return 1;
}
}
/* allocate, initialize and link the new trap destinator */
{
return -1;
}
{
return -1;
}
return 0;
}
/********************************************************************/
void delete_trap_destinator_list()
{
while(first_trap_destinator)
{
{
}
}
}
/********************************************************************/
void trace_trap_destinators()
{
Trap_Destinator *d;
trace("TRAP RECIPIENTS:\n");
trace("-----------------\n");
for(d = first_trap_destinator; d; d = d->next_trap_destinator)
{
trace("%-30s %-20s\n",
d->name,
inet_ntoa(d->ip_address));
}
trace("\n");
}
/********************************************************************/
/* ARGSUSED */
{
Trap_Destinator *d;
error_label[0] = '\0';
for(d = first_trap_destinator; d; d = d->next_trap_destinator)
{
if(trap_send_with_more_para(&(d->ip_address), my_ip_addr, NULL, 0,enterprise, generic, specific, SNMP_TRAP_PORT,time_stamp,variables, error_label))
{
return -1;
}
}
return 0;
}
int trap_send_to_all_destinators(Oid *enterprise, int generic, int specific, SNMP_variable *variables, char *error_label)
{
Trap_Destinator *d;
error_label[0] = '\0';
for(d = first_trap_destinator; d; d = d->next_trap_destinator)
{
{
return -1;
}
}
return 0;
}