/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef SNMP_DEBUG
/*
* Debug routines
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <thread.h>
#include <synch.h>
#include <ctype.h>
#include "asn1.h"
#include "pdu.h"
#include "snmplib.h"
#include "debug.h"
/*
* Buffer and line limits
*/
/*
* Debug flags
*/
/*
* Formatting aids
*/
/*
* All debug vars are protected by a single lock
*/
/*
* Key-to-string
*/
typedef struct {
int key;
char *str;
{ SNMP_MSG_GET, "SNMP_MSG_GET" },
{ SNMP_MSG_GETNEXT, "SNMP_MSG_GETNEXT" },
{ SNMP_MSG_RESPONSE, "SNMP_MSG_RESPONSE" },
{ SNMP_MSG_SET, "SNMP_MSG_SET" },
{ SNMP_MSG_TRAP, "SNMP_MSG_TRAP" },
{ SNMP_MSG_GETBULK, "SNMP_MSG_GETBULK" },
{ SNMP_MSG_INFORM, "SNMP_MSG_INFORM" },
{ SNMP_MSG_TRAP2, "SNMP_MSG_TRAP2" },
{ SNMP_MSG_REPORT, "SNMP_MSG_REPORT" }
};
{ ASN_BOOLEAN, "ASN_BOOLEAN" },
{ ASN_INTEGER, "ASN_INTEGER" },
{ ASN_BIT_STR, "ASN_BIT_STR" },
{ ASN_OCTET_STR, "ASN_OCTET_STR" },
{ ASN_NULL, "ASN_NULL" },
{ ASN_OBJECT_ID, "ASN_OBJECT_ID" },
{ ASN_SEQUENCE, "ASN_SEQUENCE" }
};
{ SNMP_DASN_SEQUENCE, "ASN SEQUENCE" },
{ SNMP_DASN_LENGTH, "ASN LENGTH" },
{ SNMP_DASN_INT, "ASN INT" },
{ SNMP_DASN_OCTET_STR, "ASN OCTET STR" },
{ SNMP_DASN_OID, "ASN OBJECT ID" },
{ SNMP_DASN_NULL, "ASN NULL" }
};
static char *debug_tags[] = {
"SNMP Command Request",
"Null Var",
"Response Var",
"Request PDU",
"Response PDU",
"Request Packet",
"Response Packet",
"WRITE",
"IOCTL",
"READ",
"SENDTO",
"RECVFROM"
};
/*
* Helpers
*/
static char *snmp_cmdstr_lookup(int cmd);
static char *snmp_vtypestr_lookup(int vtype);
static char *snmp_asnencoding_lookup(int asnkey);
static void snmp_log_append(char *bufp);
static void snmp_dbuf_realloc(void);
void
snmp_debug_init(void)
{
(void) mutex_lock(&snmp_dbuf_lock);
snmp_debug_flag = 0; /* really tragic */
(void) mutex_unlock(&snmp_dbuf_lock);
}
void
{
char *cmdstr;
int i;
return;
(void) mutex_lock(&snmp_dbuf_lock);
if ((snmp_debug_flag & SNMP_DEBUG_CMD) == 0) {
(void) mutex_unlock(&snmp_dbuf_lock);
return;
}
snmp_log_append("\n");
}
} else {
}
for (i = 0; i < n_oids; i++) {
}
(void) mutex_unlock(&snmp_dbuf_lock);
}
void
{
char *vts;
return;
(void) mutex_lock(&snmp_dbuf_lock);
if ((snmp_debug_flag & SNMP_DEBUG_VAR) == 0) {
(void) mutex_unlock(&snmp_dbuf_lock);
return;
}
snmp_log_append("\n");
}
} else {
}
(void) mutex_unlock(&snmp_dbuf_lock);
}
void
{
char *cmdstr;
return;
(void) mutex_lock(&snmp_dbuf_lock);
if ((snmp_debug_flag & SNMP_DEBUG_PDU) == 0) {
(void) mutex_unlock(&snmp_dbuf_lock);
return;
}
snmp_log_append("\n");
}
} else {
}
} else {
}
snmp_log_append("\n");
(void) mutex_unlock(&snmp_dbuf_lock);
}
void
{
char *p, *asnstr;
int i, len;
return;
(void) mutex_lock(&snmp_dbuf_lock);
if ((snmp_debug_flag & SNMP_DEBUG_ASN) == 0) {
(void) mutex_unlock(&snmp_dbuf_lock);
return;
}
} else {
}
for (i = 0; i < nrows; i++) {
"%02x %02x %02x %02x %02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x\n",
pkt += 16;
}
for (i = 0; i < nrem; i++) {
p += 3;
len -= 3;
}
(void) mutex_unlock(&snmp_dbuf_lock);
}
void
{
char *bufp;
int i, len;
return;
(void) mutex_lock(&snmp_dbuf_lock);
if ((snmp_debug_flag & SNMP_DEBUG_PKT) == 0) {
(void) mutex_unlock(&snmp_dbuf_lock);
return;
}
snmp_log_append("\n");
SNMP_DPKT_INDENT, ' ',
}
for (i = 0; i < nrows; i++) {
"%02x %02x %02x %02x %02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x "
"%s\n",
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15],
ascii);
p += 16;
}
for (i = 0; i < 16; i++) {
if (i < nrem)
else
bufp += 3;
len -= 3;
}
(void) mutex_unlock(&snmp_dbuf_lock);
}
void
{
(void) mutex_lock(&snmp_dbuf_lock);
if ((snmp_debug_flag & SNMP_DEBUG_IO) == 0) {
(void) mutex_unlock(&snmp_dbuf_lock);
return;
}
snmp_log_append("\n");
} else {
}
(void) mutex_unlock(&snmp_dbuf_lock);
}
static char *
{
int i;
for (i = 0; i < nelem; i++) {
}
return (NULL);
}
static char *
{
int i;
for (i = 0; i < nelem; i++) {
return (snmp_vartypes[i].str);
}
return (NULL);
}
static char *
{
int i;
for (i = 0; i < nelem; i++) {
return (snmp_asnencodings[i].str);
}
return (NULL);
}
static void
{
int i;
if (nchars > SNMP_NCHARS_IN_A_ROW)
for (i = 0; i < nchars; i++)
}
static void
{
int len;
snmp_dbuf_curp += len;
}
static void
snmp_dbuf_realloc(void)
{
char *p;
return;
}
if (snmp_dbuf) {
}
snmp_dbuf = p;
}
#endif