1/* $NetBSD: ip_log.c,v 1.14 2010/08/11 11:57:36 pgoyette Exp $ */ 2 3/* 4 * Copyright (C) 1997-2003 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 * 8 * Id: ip_log.c,v 2.75.2.25 2009/07/22 01:46:43 darrenr Exp 9 */ 10 11#include <sys/cdefs.h> 12__KERNEL_RCSID(0, "$NetBSD: ip_log.c,v 1.14 2010/08/11 11:57:36 pgoyette Exp $"); 13 14#include <sys/param.h> 15#if defined(KERNEL) || defined(_KERNEL) 16# undef KERNEL 17# undef _KERNEL 18# define KERNEL 1 19# define _KERNEL 1 20#endif 21#if defined(__NetBSD__) && (NetBSD >= 199905) && !defined(IPFILTER_LKM) && \ 22 defined(_KERNEL) 23# if (__NetBSD_Version__ < 399001400) 24# include "opt_ipfilter_log.h" 25# else 26# include "opt_ipfilter.h" 27# endif 28#endif 29#if defined(__FreeBSD__) && !defined(IPFILTER_LKM) 30# if defined(_KERNEL) 31# if defined(__FreeBSD_version) && (__FreeBSD_version >= 300000) 32# include "opt_ipfilter.h" 33# endif 34# else 35# include <osreldate.h> 36# endif 37#endif 38#ifndef SOLARIS 39# define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 40#endif 41#include <sys/errno.h> 42#include <sys/types.h> 43#include <sys/file.h> 44#ifndef _KERNEL 45# include <stdio.h> 46# include <string.h> 47# include <stdlib.h> 48# include <ctype.h> 49# define _KERNEL 50# define KERNEL 51# ifdef __OpenBSD__ 52struct file; 53# endif 54# include <sys/uio.h> 55# undef _KERNEL 56# undef KERNEL 57#endif 58#if (defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)) && \ 59 defined(_KERNEL) 60# include <sys/fcntl.h> 61# include <sys/filio.h> 62#else 63# include <sys/ioctl.h> 64#endif 65#include <sys/time.h> 66#if defined(_KERNEL) 67# include <sys/systm.h> 68# if (defined(NetBSD) && (__NetBSD_Version__ >= 104000000)) 69# include <sys/proc.h> 70# endif 71#endif /* _KERNEL */ 72#if !SOLARIS && !defined(__hpux) && !defined(linux) 73# if (defined(NetBSD) && (NetBSD > 199609)) || \ 74 (defined(OpenBSD) && (OpenBSD > 199603)) || \ 75 (defined(__FreeBSD_version) && (__FreeBSD_version >= 300000)) 76# include <sys/dirent.h> 77# else 78# include <sys/dir.h> 79# endif 80# include <sys/mbuf.h> 81# include <sys/select.h> 82# if __FreeBSD_version >= 500000 83# include <sys/selinfo.h> 84# endif 85#else 86# if !defined(__hpux) && defined(_KERNEL) 87# include <sys/filio.h> 88# include <sys/cred.h> 89# include <sys/ddi.h> 90# include <sys/sunddi.h> 91# include <sys/ksynch.h> 92# include <sys/kmem.h> 93# include <sys/mkdev.h> 94# include <sys/dditypes.h> 95# include <sys/cmn_err.h> 96# endif /* !__hpux */ 97#endif /* !SOLARIS && !__hpux */ 98#if !defined(linux) 99# include <sys/protosw.h> 100#endif 101#include <sys/socket.h> 102 103#include <net/if.h> 104#ifdef sun 105# include <net/af.h> 106#endif 107#if __FreeBSD_version >= 300000 108# include <net/if_var.h> 109#endif 110#include <netinet/in.h> 111#ifdef __sgi 112# include <sys/ddi.h> 113# ifdef IFF_DRVRLOCK /* IRIX6 */ 114# include <sys/hashing.h> 115# endif 116#endif 117#if !defined(__hpux) && !defined(linux) && \ 118 !(defined(__sgi) && !defined(IFF_DRVRLOCK)) /*IRIX<6*/ 119# include <netinet/in_var.h> 120#endif 121#include <netinet/in_systm.h> 122#include <netinet/ip.h> 123#include <netinet/tcp.h> 124#include <netinet/udp.h> 125#include <netinet/ip_icmp.h> 126#ifdef USE_INET6 127# include <netinet/icmp6.h> 128#endif 129#if !defined(linux) 130# include <netinet/ip_var.h> 131#endif 132#ifndef _KERNEL 133# include <syslog.h> 134#endif 135#include "netinet/ip_compat.h" 136#include <netinet/tcpip.h> 137#include "netinet/ip_fil.h" 138#include "netinet/ip_nat.h" 139#include "netinet/ip_frag.h" 140#include "netinet/ip_state.h" 141#include "netinet/ip_auth.h" 142#if (__FreeBSD_version >= 300000) || defined(__NetBSD__) 143# include <sys/malloc.h> 144#endif 145/* END OF INCLUDES */ 146 147#ifdef IPFILTER_LOG 148 149# if defined(IPL_SELECT) 150# include <machine/sys/user.h> 151# include <sys/kthread_iface.h> 152# define READ_COLLISION 0x001 153 154iplog_select_t iplog_ss[IPL_LOGSIZE]; 155 156extern int selwait; 157# endif /* IPL_SELECT */ 158 159# if defined(linux) && defined(_KERNEL) 160wait_queue_head_t iplh_linux[IPL_LOGSIZE]; 161# endif 162# if SOLARIS && defined(_KERNEL) 163extern kcondvar_t iplwait; 164extern struct pollhead iplpollhead[IPL_LOGSIZE]; 165# endif 166 167iplog_t **iplh[IPL_LOGSIZE], *iplt[IPL_LOGSIZE], *ipll[IPL_LOGSIZE]; 168int iplused[IPL_LOGSIZE]; 169static fr_info_t iplcrc[IPL_LOGSIZE]; 170int ipl_suppress = 1; 171int ipl_logmax = IPL_LOGMAX; 172int ipl_logall = 0; 173int ipl_log_init = 0; 174int ipl_logsize = IPFILTER_LOGSIZE; 175int ipl_magic[IPL_LOGSIZE] = { IPL_MAGIC, IPL_MAGIC_NAT, IPL_MAGIC_STATE, 176 IPL_MAGIC, IPL_MAGIC, IPL_MAGIC, 177 IPL_MAGIC, IPL_MAGIC }; 178 179 180/* ------------------------------------------------------------------------ */ 181/* Function: fr_loginit */ 182/* Returns: int - 0 == success (always returned) */ 183/* Parameters: Nil */ 184/* */ 185/* Initialise log buffers & pointers. Also iniialised the CRC to a local */ 186/* secret for use in calculating the "last log checksum". */ 187/* ------------------------------------------------------------------------ */ 188int 189fr_loginit(void) 190{ 191 int i; 192 193 for (i = IPL_LOGMAX; i >= 0; i--) { 194 iplt[i] = NULL; 195 ipll[i] = NULL; 196 iplh[i] = &iplt[i]; 197 iplused[i] = 0; 198 bzero((char *)&iplcrc[i], sizeof(iplcrc[i])); 199# ifdef IPL_SELECT 200 iplog_ss[i].read_waiter = 0; 201 iplog_ss[i].state = 0; 202# endif 203# if defined(linux) && defined(_KERNEL) 204 init_waitqueue_head(iplh_linux + i); 205# endif 206 } 207 208# if SOLARIS && defined(_KERNEL) 209 cv_init(&iplwait, "ipl condvar", CV_DRIVER, NULL); 210# endif 211 MUTEX_INIT(&ipl_mutex, "ipf log mutex"); 212 213 ipl_log_init = 1; 214 215 return 0; 216} 217 218 219/* ------------------------------------------------------------------------ */ 220/* Function: fr_logunload */ 221/* Returns: Nil */ 222/* Parameters: Nil */ 223/* */ 224/* Clean up any log data that has accumulated without being read. */ 225/* ------------------------------------------------------------------------ */ 226void 227fr_logunload(void) 228{ 229 int i; 230 231 if (ipl_log_init == 0) 232 return; 233 234 for (i = IPL_LOGMAX; i >= 0; i--) 235 (void) ipflog_clear(i); 236 237# if SOLARIS && defined(_KERNEL) 238 cv_destroy(&iplwait); 239# endif 240 MUTEX_DESTROY(&ipl_mutex); 241 242 ipl_log_init = 0; 243} 244 245 246/* ------------------------------------------------------------------------ */ 247/* Function: ipflog */ 248/* Returns: int - 0 == success, -1 == failure */ 249/* Parameters: fin(I) - pointer to packet information */ 250/* flags(I) - flags from filter rules */ 251/* */ 252/* Create a log record for a packet given that it has been triggered by a */ 253/* rule (or the default setting). Calculate the transport protocol header */ 254/* size using predetermined size of a couple of popular protocols and thus */ 255/* how much data to copy into the log, including part of the data body if */ 256/* requested. */ 257/* ------------------------------------------------------------------------ */ 258int 259ipflog(fr_info_t *fin, u_int flags) 260{ 261 register size_t hlen; 262 int types[2], mlen; 263 size_t sizes[2]; 264 void *ptrs[2]; 265 ipflog_t ipfl; 266 u_char p; 267 mb_t *m; 268# if (SOLARIS || defined(__hpux)) && defined(_KERNEL) && \ 269 !defined(_INET_IP_STACK_H) 270 qif_t *ifp; 271# else 272 struct ifnet *ifp; 273# endif /* SOLARIS || __hpux */ 274 275 m = fin->fin_m; 276 if (m == NULL) 277 return -1; 278 279 ipfl.fl_nattag.ipt_num[0] = 0; 280 ifp = fin->fin_ifp; 281 if (fin->fin_exthdr != NULL) 282 hlen = (char *)fin->fin_dp - (char *)fin->fin_ip; 283 else 284 hlen = fin->fin_hlen; 285 /* 286 * calculate header size. 287 */ 288 if (fin->fin_off == 0) { 289 p = fin->fin_fi.fi_p; 290 if (p == IPPROTO_TCP) 291 hlen += MIN(sizeof(tcphdr_t), fin->fin_dlen); 292 else if (p == IPPROTO_UDP) 293 hlen += MIN(sizeof(udphdr_t), fin->fin_dlen); 294 else if (p == IPPROTO_ICMP) { 295 struct icmp *icmp; 296 297 icmp = (struct icmp *)fin->fin_dp; 298 299 /* 300 * For ICMP, if the packet is an error packet, also 301 * include the information about the packet which 302 * caused the error. 303 */ 304 switch (icmp->icmp_type) 305 { 306 case ICMP_UNREACH : 307 case ICMP_SOURCEQUENCH : 308 case ICMP_REDIRECT : 309 case ICMP_TIMXCEED : 310 case ICMP_PARAMPROB : 311 hlen += MIN(sizeof(struct icmp) + 8, 312 fin->fin_dlen); 313 break; 314 default : 315 hlen += MIN(sizeof(struct icmp), 316 fin->fin_dlen); 317 break; 318 } 319 } 320# ifdef USE_INET6 321 else if (p == IPPROTO_ICMPV6) { 322 struct icmp6_hdr *icmp; 323 324 icmp = (struct icmp6_hdr *)fin->fin_dp; 325 326 /* 327 * For ICMPV6, if the packet is an error packet, also 328 * include the information about the packet which 329 * caused the error. 330 */ 331 if (icmp->icmp6_type < 128) { 332 hlen += MIN(sizeof(struct icmp6_hdr) + 8, 333 fin->fin_dlen); 334 } else { 335 hlen += MIN(sizeof(struct icmp6_hdr), 336 fin->fin_dlen); 337 } 338 } 339# endif 340 } 341 /* 342 * Get the interface number and name to which this packet is 343 * currently associated. 344 */ 345# if (SOLARIS || defined(__hpux)) && defined(_KERNEL) && \ 346 !defined(_INET_IP_STACK_H) 347 ipfl.fl_unit = (u_int)ifp->qf_ppa; 348 COPYIFNAME(fin->fin_v, ifp, ipfl.fl_ifname); 349# else 350# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \ 351 (defined(OpenBSD) && (OpenBSD >= 199603)) || defined(linux) || \ 352 (defined(__FreeBSD__) && (__FreeBSD_version >= 501113)) || \ 353 (SOLARIS && defined(_INET_IP_STACK_H)) 354 COPYIFNAME(fin->fin_v, ifp, ipfl.fl_ifname); 355# else 356 ipfl.fl_unit = (u_int)ifp->if_unit; 357# if defined(_KERNEL) 358 if ((ipfl.fl_ifname[0] = ifp->if_name[0])) 359 if ((ipfl.fl_ifname[1] = ifp->if_name[1])) 360 if ((ipfl.fl_ifname[2] = ifp->if_name[2])) 361 ipfl.fl_ifname[3] = ifp->if_name[3]; 362# else 363 COPYIFNAME(fin->fin_v, ifp, ipfl.fl_ifname); 364 ipfl.fl_ifname[sizeof(ipfl.fl_ifname) - 1] = '\0'; 365# endif 366# endif 367# endif /* __hpux || SOLARIS */ 368 mlen = fin->fin_plen - hlen; 369 if (!ipl_logall) { 370 mlen = (flags & FR_LOGBODY) ? MIN(mlen, 128) : 0; 371 } else if ((flags & FR_LOGBODY) == 0) { 372 mlen = 0; 373 } 374 if (mlen < 0) 375 mlen = 0; 376 ipfl.fl_plen = (u_char)mlen; 377 ipfl.fl_hlen = (u_char)hlen; 378 ipfl.fl_rule = fin->fin_rule; 379 (void) strncpy(ipfl.fl_group, fin->fin_group, FR_GROUPLEN); 380 if (fin->fin_fr != NULL) { 381 ipfl.fl_loglevel = fin->fin_fr->fr_loglevel; 382 ipfl.fl_logtag = fin->fin_fr->fr_logtag; 383 } else { 384 ipfl.fl_loglevel = 0xffff; 385 ipfl.fl_logtag = FR_NOLOGTAG; 386 } 387 if (fin->fin_nattag != NULL) 388 bcopy(fin->fin_nattag, (void *)&ipfl.fl_nattag, 389 sizeof(ipfl.fl_nattag)); 390 ipfl.fl_flags = flags; 391 ipfl.fl_dir = fin->fin_out; 392 ipfl.fl_lflags = fin->fin_flx; 393 ptrs[0] = (void *)&ipfl; 394 sizes[0] = sizeof(ipfl); 395 types[0] = 0; 396# if defined(MENTAT) && defined(_KERNEL) 397 /* 398 * Are we copied from the mblk or an aligned array ? 399 */ 400 if (fin->fin_ip == (ip_t *)m->b_rptr) { 401 ptrs[1] = m; 402 sizes[1] = hlen + mlen; 403 types[1] = 1; 404 } else { 405 ptrs[1] = fin->fin_ip; 406 sizes[1] = hlen + mlen; 407 types[1] = 0; 408 } 409# else 410 ptrs[1] = m; 411 sizes[1] = hlen + mlen; 412 types[1] = 1; 413# endif /* MENTAT */ 414 return ipllog(IPL_LOGIPF, fin, ptrs, sizes, types, 2); 415} 416 417 418/* ------------------------------------------------------------------------ */ 419/* Function: ipllog */ 420/* Returns: int - 0 == success, -1 == failure */ 421/* Parameters: dev(I) - device that owns this log record */ 422/* fin(I) - pointer to packet information */ 423/* items(I) - array of pointers to log data */ 424/* itemsz(I) - array of size of valid memory pointed to */ 425/* types(I) - type of data pointed to by items pointers */ 426/* cnt(I) - number of elements in arrays items/itemsz/types */ 427/* */ 428/* Takes an array of parameters and constructs one record to include the */ 429/* miscellaneous packet information, as well as packet data, for reading */ 430/* from the log device. */ 431/* ------------------------------------------------------------------------ */ 432int 433ipllog(int dev, fr_info_t *fin, void **items, size_t *itemsz, int *types, int cnt) 434{ 435 char *buf, *ptr; 436 iplog_t *ipl; 437 size_t len; 438 int i; 439 SPL_INT(s); 440 441 /* 442 * Get the total amount of data to be logged. 443 */ 444 for (i = 0, len = sizeof(iplog_t); i < cnt; i++) 445 len += itemsz[i]; 446 447 /* 448 * check that we have space to record this information and can 449 * allocate that much. 450 */ 451 if ((iplused[dev] + len) > ipl_logsize) 452 return -1; 453 454 KMALLOCS(buf, char *, len); 455 if (buf == NULL) 456 return -1; 457 ipl = (iplog_t *)buf; 458 ipl->ipl_magic = ipl_magic[dev]; 459 ipl->ipl_count = 1; 460 ipl->ipl_next = NULL; 461 ipl->ipl_dsize = len; 462#ifdef _KERNEL 463 GETKTIME(&ipl->ipl_sec); 464#else 465 ipl->ipl_sec = 0; 466 ipl->ipl_usec = 0; 467#endif 468 469 /* 470 * Loop through all the items to be logged, copying each one to the 471 * buffer. Use bcopy for normal data or the mb_t copyout routine. 472 */ 473 for (i = 0, ptr = buf + sizeof(*ipl); i < cnt; i++) { 474 if (types[i] == 0) { 475 memcpy(ptr, items[i], itemsz[i]); 476 } else if (types[i] == 1) { 477 COPYDATA(items[i], 0, itemsz[i], (char *)ptr); 478 } 479 ptr += itemsz[i]; 480 } 481 482 SPL_NET(s); 483 MUTEX_ENTER(&ipl_mutex); 484 /* 485 * Check to see if this log record has a CRC which matches the last 486 * record logged. If it does, just up the count on the previous one 487 * rather than create a new one. 488 */ 489 if (ipl_suppress) { 490 if ((fin != NULL) && (fin->fin_off == 0)) { 491 if ((ipll[dev] != NULL) && 492 bcmp((char *)fin, (char *)&iplcrc[dev], 493 FI_LCSIZE) == 0) { 494 ipll[dev]->ipl_count++; 495 MUTEX_EXIT(&ipl_mutex); 496 SPL_X(s); 497 KFREES(buf, len); 498 return 0; 499 } 500 bcopy((char *)fin, (char *)&iplcrc[dev], FI_LCSIZE); 501 } else 502 bzero((char *)&iplcrc[dev], FI_CSIZE); 503 } 504 505 /* 506 * advance the log pointer to the next empty record and deduct the 507 * amount of space we're going to use. 508 */ 509 ipll[dev] = ipl; 510 *iplh[dev] = ipl; 511 iplh[dev] = &ipl->ipl_next; 512 iplused[dev] += len; 513 514 /* 515 * Now that the log record has been completed and added to the queue, 516 * wake up any listeners who may want to read it. 517 */ 518# if SOLARIS && defined(_KERNEL) 519 cv_signal(&iplwait); 520 MUTEX_EXIT(&ipl_mutex); 521 pollwakeup(&iplpollhead[dev], POLLRDNORM); 522# else 523 MUTEX_EXIT(&ipl_mutex); 524 WAKEUP(iplh, dev); 525 POLLWAKEUP(dev); 526# endif 527 SPL_X(s); 528# ifdef IPL_SELECT 529 iplog_input_ready(dev); 530# endif 531 return 0; 532} 533 534 535/* ------------------------------------------------------------------------ */ 536/* Function: ipflog_read */ 537/* Returns: int - 0 == success, else error value. */ 538/* Parameters: unit(I) - device we are reading from */ 539/* uio(O) - pointer to information about where to store data */ 540/* */ 541/* Called to handle a read on an IPFilter device. Returns only complete */ 542/* log messages - will not partially copy a log record out to userland. */ 543/* */ 544/* NOTE: This function will block and wait for a signal to return data if */ 545/* there is none present. Asynchronous I/O is not implemented. */ 546/* ------------------------------------------------------------------------ */ 547int 548ipflog_read(minor_t unit, struct uio *uio) 549{ 550 size_t dlen, copied; 551 int error = 0; 552 iplog_t *ipl; 553 SPL_INT(s); 554 555 /* 556 * Sanity checks. Make sure the minor # is valid and we're copying 557 * a valid chunk of data. 558 */ 559 if (IPL_LOGMAX < unit) 560 return ENXIO; 561 if (uio->uio_resid == 0) 562 return 0; 563 if ((uio->uio_resid < sizeof(iplog_t)) || 564 (uio->uio_resid > ipl_logsize)) 565 return EINVAL; 566 567 /* 568 * Lock the log so we can snapshot the variables. Wait for a signal 569 * if the log is empty. 570 */ 571 SPL_NET(s); 572 MUTEX_ENTER(&ipl_mutex); 573 574 while (iplt[unit] == NULL) { 575# if SOLARIS && defined(_KERNEL) 576 if (!cv_wait_sig(&iplwait, &ipl_mutex.ipf_lk)) { 577 MUTEX_EXIT(&ipl_mutex); 578 return EINTR; 579 } 580# else 581# if defined(__hpux) && defined(_KERNEL) 582 lock_t *l; 583 584# ifdef IPL_SELECT 585 if (uio->uio_fpflags & (FNBLOCK|FNDELAY)) { 586 /* this is no blocking system call */ 587 MUTEX_EXIT(&ipl_mutex); 588 return 0; 589 } 590# endif 591 592 MUTEX_EXIT(&ipl_mutex); 593 l = get_sleep_lock(&iplh[unit]); 594 error = sleep(&iplh[unit], PZERO+1); 595 spinunlock(l); 596# else 597# if defined(__osf__) && defined(_KERNEL) 598 error = mpsleep(&iplh[unit], PSUSP|PCATCH, "iplread", 0, 599 &ipl_mutex, MS_LOCK_SIMPLE); 600# else 601 MUTEX_EXIT(&ipl_mutex); 602 SPL_X(s); 603 error = SLEEP(unit + iplh, "ipl sleep"); 604# endif /* __osf__ */ 605# endif /* __hpux */ 606 if (error) 607 return error; 608 SPL_NET(s); 609 MUTEX_ENTER(&ipl_mutex); 610# endif /* SOLARIS */ 611 } 612 613# if (defined(BSD) && (BSD >= 199101)) || defined(__FreeBSD__) || \ 614 defined(__osf__) 615 uio->uio_rw = UIO_READ; 616# endif 617 618 for (copied = 0; (ipl = iplt[unit]) != NULL; copied += dlen) { 619 dlen = ipl->ipl_dsize; 620 if (dlen > uio->uio_resid) 621 break; 622 /* 623 * Don't hold the mutex over the uiomove call. 624 */ 625 iplt[unit] = ipl->ipl_next; 626 iplused[unit] -= dlen; 627 MUTEX_EXIT(&ipl_mutex); 628 SPL_X(s); 629 error = UIOMOVE((void *)ipl, dlen, UIO_READ, uio); 630 if (error) { 631 SPL_NET(s); 632 MUTEX_ENTER(&ipl_mutex); 633 ipl->ipl_next = iplt[unit]; 634 iplt[unit] = ipl; 635 iplused[unit] += dlen; 636 break; 637 } 638 MUTEX_ENTER(&ipl_mutex); 639 KFREES((void *)ipl, dlen); 640 SPL_NET(s); 641 } 642 if (!iplt[unit]) { 643 iplused[unit] = 0; 644 iplh[unit] = &iplt[unit]; 645 ipll[unit] = NULL; 646 } 647 648 MUTEX_EXIT(&ipl_mutex); 649 SPL_X(s); 650 return error; 651} 652 653 654/* ------------------------------------------------------------------------ */ 655/* Function: ipflog_clear */ 656/* Returns: int - number of log bytes cleared. */ 657/* Parameters: unit(I) - device we are reading from */ 658/* */ 659/* Deletes all queued up log records for a given output device. */ 660/* ------------------------------------------------------------------------ */ 661int 662ipflog_clear(minor_t unit) 663{ 664 iplog_t *ipl; 665 int used; 666 SPL_INT(s); 667 668 SPL_NET(s); 669 MUTEX_ENTER(&ipl_mutex); 670 while ((ipl = iplt[unit]) != NULL) { 671 iplt[unit] = ipl->ipl_next; 672 KFREES((void *)ipl, ipl->ipl_dsize); 673 } 674 iplh[unit] = &iplt[unit]; 675 ipll[unit] = NULL; 676 used = iplused[unit]; 677 iplused[unit] = 0; 678 bzero((char *)&iplcrc[unit], FI_CSIZE); 679 MUTEX_EXIT(&ipl_mutex); 680 SPL_X(s); 681 return used; 682} 683 684 685/* ------------------------------------------------------------------------ */ 686/* Function: ipflog_canread */ 687/* Returns: int - 0 == no data to read, 1 = data present */ 688/* Parameters: unit(I) - device we are reading from */ 689/* */ 690/* Returns an indication of whether or not there is data present in the */ 691/* current buffer for the selected ipf device. */ 692/* ------------------------------------------------------------------------ */ 693int 694ipflog_canread(int unit) 695{ 696 return iplt[unit] != NULL; 697} 698#endif /* IPFILTER_LOG */ 699