1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _DEBUG_H 28 #define _DEBUG_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #ifdef SNMP_DEBUG 37 38 /* 39 * ASN Debugging keys 40 */ 41 #define SNMP_DASN_SEQUENCE 1 42 #define SNMP_DASN_LENGTH 2 43 #define SNMP_DASN_INT 3 44 #define SNMP_DASN_OCTET_STR 4 45 #define SNMP_DASN_OID 5 46 #define SNMP_DASN_NULL 6 47 48 /* 49 * Debug tags 50 */ 51 #define TAG_CMD_REQUEST 0 52 #define TAG_NULL_VAR 1 53 #define TAG_RESPONSE_VAR 2 54 #define TAG_REQUEST_PDU 3 55 #define TAG_RESPONSE_PDU 4 56 #define TAG_REQUEST_PKT 5 57 #define TAG_RESPONSE_PKT 6 58 #define TAG_WRITE 7 59 #define TAG_IOCTL 8 60 #define TAG_READ 9 61 #define TAG_SENDTO 10 62 #define TAG_RECVFROM 11 63 64 /* 65 * Debug macros 66 */ 67 #define LOGINIT() \ 68 snmp_debug_init() 69 70 #define LOGGET(tag, prefix, row) \ 71 snmp_log_cmd(tag, SNMP_MSG_GET, 1, prefix, row) 72 73 #define LOGBULK(tag, n_oids, oidstrs, row) \ 74 snmp_log_cmd(tag, SNMP_MSG_GETBULK, n_oids, oidstrs, row) 75 76 #define LOGNEXT(tag, prefix, row) \ 77 snmp_log_cmd(tag, SNMP_MSG_GETNEXT, 1, prefix, row) 78 79 #define LOGVAR(tag, vp) \ 80 snmp_log_var(tag, vp) 81 82 #define LOGPDU(tag, pdu) \ 83 snmp_log_pdu(tag, pdu) 84 85 #define LOGASNSEQ(pkt, pktsz) \ 86 snmp_log_asn(SNMP_DASN_SEQUENCE, pkt, pktsz) 87 88 #define LOGASNLENGTH(pkt, pktsz) \ 89 snmp_log_asn(SNMP_DASN_LENGTH, pkt, pktsz) 90 91 #define LOGASNINT(pkt, pktsz) \ 92 snmp_log_asn(SNMP_DASN_INT, pkt, pktsz) 93 94 #define LOGASNOCTSTR(pkt, pktsz) \ 95 snmp_log_asn(SNMP_DASN_OCTET_STR, pkt, pktsz) 96 97 #define LOGASNOID(pkt, pktsz) \ 98 snmp_log_asn(SNMP_DASN_OID, pkt, pktsz) 99 100 #define LOGASNNULL(pkt, pktsz) \ 101 snmp_log_asn(SNMP_DASN_NULL, pkt, pktsz) 102 103 #define LOGPKT(tag, pkt, sz) \ 104 snmp_log_pkt(tag, pkt, sz) 105 106 #define LOGIO(tag, a1, a2, a3) \ 107 snmp_log_io(tag, (int)a1, (uint_t)a2, (uint_t)a3) 108 109 /* 110 * Exported debug interfaces 111 */ 112 extern void snmp_debug_init(void); 113 extern void snmp_log_cmd(uint_t tag, int cmd, int n_oids, 114 char *oidstr, int row); 115 extern void snmp_log_var(uint_t tag, pdu_varlist_t *vp); 116 extern void snmp_log_pdu(uint_t tag, snmp_pdu_t *pdu); 117 extern void snmp_log_asn(int key, uchar_t *pkt, size_t pktsz); 118 extern void snmp_log_pkt(uint_t tag, uchar_t *pkt, size_t pktsz); 119 extern void snmp_log_io(uint_t tag, int a1, uint_t a2, uint_t a3); 120 121 #else /* SNMP_DEBUG */ 122 123 #define LOGINIT() 124 #define LOGGET(tag, prefix, row) 125 #define LOGBULK(tag, n_oids, oidstrs, row) 126 #define LOGNEXT(tag, prefix, row) 127 #define LOGVAR(tag, vp) 128 #define LOGPDU(tag, pdu) 129 #define LOGASNSEQ(pkt, pktsz) 130 #define LOGASNLENGTH(pkt, pktsz) 131 #define LOGASNINT(pkt, pktsz) 132 #define LOGASNOCTSTR(pkt, pktsz) 133 #define LOGASNOID(pkt, pktsz) 134 #define LOGASNNULL(pkt, pktsz) 135 #define LOGPKT(tag, pkt, sz) 136 #define LOGIO(tag, a1, a2, a3) 137 138 #endif /* SNMP_DEBUG */ 139 140 #ifdef __cplusplus 141 } 142 #endif 143 144 #endif /* _DEBUG_H */ 145