Print this page
3168 pfmod commands could be more useful

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/pfmod.c
          +++ new/usr/src/uts/common/io/pfmod.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   26  /*
  29   27   * STREAMS Packet Filter Module
  30   28   *
  31   29   * This module applies a filter to messages arriving on its read
  32   30   * queue, passing on messages that the filter accepts adn discarding
  33   31   * the others.  It supports ioctls for setting the filter.
  34   32   *
  35   33   * On the write side, the module simply passes everything through
  36   34   * unchanged.
  37   35   *
↓ open down ↓ 10 lines elided ↑ open up ↑
  48   46  #include <sys/time.h>
  49   47  #include <sys/stropts.h>
  50   48  #include <sys/stream.h>
  51   49  #include <sys/conf.h>
  52   50  #include <sys/ddi.h>
  53   51  #include <sys/sunddi.h>
  54   52  #include <sys/kmem.h>
  55   53  #include <sys/strsun.h>
  56   54  #include <sys/pfmod.h>
  57   55  #include <sys/modctl.h>
       56 +#include <netinet/in.h>
  58   57  
  59   58  /*
  60   59   * Expanded version of the Packetfilt structure that includes
  61   60   * some additional fields that aid filter execution efficiency.
  62   61   */
  63   62  struct epacketfilt {
  64   63          struct Pf_ext_packetfilt        pf;
  65   64  #define pf_Priority     pf.Pf_Priority
  66   65  #define pf_FilterLen    pf.Pf_FilterLen
  67   66  #define pf_Filter       pf.Pf_Filter
↓ open down ↓ 234 lines elided ↑ open up ↑
 302  301                   * These assignments are distasteful, but necessary,
 303  302                   * since the packet filter wants to work in terms of
 304  303                   * shorts.  Odd bytes at the end of header or data can't
 305  304                   * participate in the filtering operation.
 306  305                   */
 307  306                  pd.pd_hdr = (ushort_t *)mp->b_rptr;
 308  307                  pd.pd_hdrlen = (mp->b_wptr - mp->b_rptr) / sizeof (ushort_t);
 309  308                  if (mbp) {
 310  309                          pd.pd_body = (ushort_t *)mbp->b_rptr;
 311  310                          pd.pd_bodylen = (mbp->b_wptr - mbp->b_rptr) /
 312      -                                                        sizeof (ushort_t);
      311 +                            sizeof (ushort_t);
 313  312                  } else {
 314  313                          pd.pd_body = NULL;
 315  314                          pd.pd_bodylen = 0;
 316  315                  }
 317  316  
 318  317                  /*
 319  318                   * Apply the filter.
 320  319                   */
 321  320                  if (FilterPacket(&pd, pfp))
 322  321                          putnext(rq, mpp);
↓ open down ↓ 104 lines elided ↑ open up ↑
 427  426                          case ENF_BRFL:
 428  427                                  /* Skip over the literal. */
 429  428                                  fwp++;
 430  429                                  break;
 431  430  
 432  431                          case ENF_PUSHZERO:
 433  432                          case ENF_PUSHONE:
 434  433                          case ENF_PUSHFFFF:
 435  434                          case ENF_PUSHFF00:
 436  435                          case ENF_PUSH00FF:
      436 +                        case ENF_PUSHFF00_N:
      437 +                        case ENF_PUSH00FF_N:
 437  438                          case ENF_NOPUSH:
 438  439                          case ENF_POP:
 439  440                                  break;
 440  441                          }
 441  442                  }
 442  443  
 443  444                  /*
 444  445                   * Convert word offset to length in bytes.
 445  446                   */
 446  447                  pfp->pf_PByteLen = (maxoff + maxoffreg + 1) * sizeof (ushort_t);
↓ open down ↓ 92 lines elided ↑ open up ↑
 539  540                  break;
 540  541          case ENF_PUSHFFFF:
 541  542                  *--sp = 0xffff;
 542  543                  break;
 543  544          case ENF_PUSHFF00:
 544  545                  *--sp = 0xff00;
 545  546                  break;
 546  547          case ENF_PUSH00FF:
 547  548                  *--sp = 0x00ff;
 548  549                  break;
      550 +        case ENF_PUSHFF00_N:
      551 +                *--sp = htons(0xff00);
      552 +                break;
      553 +        case ENF_PUSH00FF_N:
      554 +                *--sp = htons(0x00ff);
      555 +                break;
 549  556          case ENF_LOAD_OFFSET:
 550  557                  offreg = *fp++;
 551  558                  break;
 552  559          case ENF_BRTR:
 553  560                  if (*sp != 0)
 554  561                          fp += *fp;
 555  562                  else
 556  563                          fp++;
 557  564                  if (fp >= fpe) {
 558  565                          enprintf(("BRTR: fp>=fpe\n"));
↓ open down ↓ 105 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX