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