1*37e8f898Shshoexer /* $OpenBSD: log.h,v 1.25 2008/12/22 14:30:04 hshoexer Exp $ */ 27918ad0aSniklas /* $EOM: log.h,v 1.19 2000/03/30 14:27:23 ho Exp $ */ 32040585eSniklas 42040585eSniklas /* 548479d6eSniklas * Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved. 614fdbdabSho * Copyright (c) 2001, 2002, 2003 H�kan Olsson. All rights reserved. 72040585eSniklas * 82040585eSniklas * Redistribution and use in source and binary forms, with or without 92040585eSniklas * modification, are permitted provided that the following conditions 102040585eSniklas * are met: 112040585eSniklas * 1. Redistributions of source code must retain the above copyright 122040585eSniklas * notice, this list of conditions and the following disclaimer. 132040585eSniklas * 2. Redistributions in binary form must reproduce the above copyright 142040585eSniklas * notice, this list of conditions and the following disclaimer in the 152040585eSniklas * documentation and/or other materials provided with the distribution. 162040585eSniklas * 172040585eSniklas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 182040585eSniklas * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 192040585eSniklas * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 202040585eSniklas * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 212040585eSniklas * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 222040585eSniklas * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232040585eSniklas * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242040585eSniklas * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252040585eSniklas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 262040585eSniklas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272040585eSniklas */ 282040585eSniklas 292040585eSniklas /* 302040585eSniklas * This code was written under funding by Ericsson Radio Systems. 312040585eSniklas */ 322040585eSniklas 332040585eSniklas #ifndef _LOG_H_ 342040585eSniklas #define _LOG_H_ 352040585eSniklas 362040585eSniklas #include <sys/types.h> 37af729d73Sho #include <sys/socket.h> 38af729d73Sho #include <sys/uio.h> 392040585eSniklas #include <stdio.h> 402040585eSniklas 41ce261536Shshoexer extern int verbose_logging; 42ce261536Shshoexer 4348479d6eSniklas /* 4448479d6eSniklas * We cannot do the log strings dynamically sizeable as out of memory is one 4548479d6eSniklas * of the situations we need to report about. 4648479d6eSniklas */ 4748479d6eSniklas #define LOG_SIZE 200 4848479d6eSniklas 492040585eSniklas enum log_classes { 50ecf264fdSniklas LOG_MISC, LOG_TRANSPORT, LOG_MESSAGE, LOG_CRYPTO, LOG_TIMER, LOG_SYSDEP, 513e4dec8fSho LOG_SA, LOG_EXCHANGE, LOG_NEGOTIATION, LOG_POLICY, LOG_UI, LOG_ENDCLASS 522040585eSniklas }; 5348479d6eSniklas #define LOG_CLASSES_TEXT \ 5429fc3887Sho { "Misc", "Trpt", "Mesg", "Cryp", "Timr", "Sdep", "SA ", "Exch", "Negt", \ 553e4dec8fSho "Plcy", "UI " } 5648479d6eSniklas 5748479d6eSniklas /* 5848479d6eSniklas * "Class" LOG_REPORT will always be logged to the current log channel, 5948479d6eSniklas * regardless of level. 6048479d6eSniklas */ 6148479d6eSniklas #define LOG_PRINT -1 6248479d6eSniklas #define LOG_REPORT -2 632040585eSniklas 6451ca15aeSniklas #define LOG_DBG(x) log_debug x 6551ca15aeSniklas #define LOG_DBG_BUF(x) log_debug_buf x 6651ca15aeSniklas 6712f43dabShshoexer extern void log_debug(int, int, const char *,...) 68338f1400Sho __attribute__((__format__(__printf__, 3, 4))); 692040585eSniklas extern void log_debug_buf(int, int, const char *, const u_int8_t *, size_t); 702040585eSniklas extern void log_debug_cmd(int, int); 7153544c47Sho extern void log_debug_toggle(void); 7251ca15aeSniklas 73af729d73Sho #define PCAP_FILE_DEFAULT "/var/run/isakmpd.pcap" 74af729d73Sho extern void log_packet_init(char *); 75af729d73Sho extern void log_packet_iov(struct sockaddr *, struct sockaddr *, 76af729d73Sho struct iovec *, int); 77af729d73Sho extern void log_packet_restart(char *); 78af729d73Sho extern void log_packet_stop(void); 79af729d73Sho 8051ca15aeSniklas extern FILE *log_current(void); 8112f43dabShshoexer extern void log_error(const char *,...) 82338f1400Sho __attribute__((__format__(__printf__, 1, 2))); 83fb53af81Smoritz extern void log_errorx(const char *,...) 84fb53af81Smoritz __attribute__((__format__(__printf__, 1, 2))); 85338f1400Sho extern void log_fatal(const char *,...) 86*37e8f898Shshoexer __attribute__((__format__(__printf__, 1, 2))) __dead; 872c7c43b1Shshoexer extern void log_fatalx(const char *,...) 882c7c43b1Shshoexer __attribute__((__format__(__printf__, 1, 2))); 89338f1400Sho extern void log_print(const char *,...) 90338f1400Sho __attribute__((__format__(__printf__, 1, 2))); 91ce261536Shshoexer extern void log_verbose(const char *,...) 92ce261536Shshoexer __attribute__((__format__(__printf__, 1, 2))); 932040585eSniklas extern void log_to(FILE *); 94a8478dd3Sho extern void log_init(int); 954e2ad344Shshoexer extern void log_reinit(void); 962040585eSniklas 972040585eSniklas #endif /* _LOG_H_ */ 98