Print this page
OS-7667 IPFilter needs to keep and report state for cloud firewall logging
Portions contributed by: Mike Gerdts <mike.gerdts@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ipf/tools/lexer.c
          +++ new/usr/src/cmd/ipf/tools/lexer.c
   1    1  /*
   2    2   * Copyright (C) 2002-2008 by Darren Reed.
   3    3   *
   4    4   * See the IPFILTER.LICENCE file for details on licencing.
   5    5   *
   6    6   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
   7    7   * Use is subject to license terms.
        8 + * Copyright 2019 Joyent, Inc.
   8    9   */
   9   10  
  10   11  #include <ctype.h>
  11   12  #include "ipf.h"
  12   13  #ifdef  IPFILTER_SCAN
  13   14  # include "netinet/ip_scan.h"
  14   15  #endif
  15   16  #include <sys/ioctl.h>
  16   17  #include <syslog.h>
       18 +#include <uuid/uuid.h>
  17   19  #ifdef  TEST_LEXER
  18   20  # define        NO_YACC
  19   21  union   {
  20   22          int             num;
  21   23          char            *str;
  22   24          struct in_addr  ipa;
  23   25          i6addr_t        ip6;
       26 +        uuid_t          uuid;
  24   27  } yylval;
  25   28  #endif
  26   29  #include "lexer.h"
  27   30  #include "y.tab.h"
  28   31  
  29   32  FILE *yyin;
  30   33  
  31   34  #define ishex(c)        (ISDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || \
  32   35                           ((c) >= 'A' && (c) <= 'F'))
  33   36  #define TOOLONG         -3
↓ open down ↓ 414 lines elided ↑ open up ↑
 448  451                  if (inet_pton(AF_INET6, ipv6buf, &yylval.ip6) == 1) {
 449  452                          rval = YY_IPV6;
 450  453                          yyexpectaddr = 0;
 451  454                          goto done;
 452  455                  }
 453  456                  yypos = start;
 454  457                  c = oc;
 455  458          }
 456  459  #endif
 457  460  
      461 +        /*
      462 +         * UUID: 2426e38c-9f63-c0b8-cfd5-9aaeaf992d42 or uppercase
      463 +         */
      464 +        if (isbuilding == 0 && (ishex(c) || c == '-')) {
      465 +                char uuidbuf[UUID_PRINTABLE_STRING_LENGTH], *s, oc;
      466 +                int start;
      467 +
      468 +                start = yypos;
      469 +                s = uuidbuf;
      470 +                oc = c;
      471 +
      472 +                /*
      473 +                 * Don't worry about exact position of hexdigits and hyphens
      474 +                 * because uuid_parse() will provide the sanity check.
      475 +                 */
      476 +                do {
      477 +                        *s++ = c;
      478 +                        c = yygetc(1);
      479 +                } while ((ishex(c) || c == '-') &&
      480 +                    (s - uuidbuf < sizeof (uuidbuf)));
      481 +                yyunputc(c);
      482 +                *s = '\0';
      483 +
      484 +                if (uuid_parse(uuidbuf, yylval.uuid) == 0) {
      485 +                        rval = YY_UUID;
      486 +                        yyexpectaddr = 0;
      487 +                        goto done;
      488 +                }
      489 +                yypos = start;
      490 +                c = oc;
      491 +        }
      492 +
      493 +
 458  494          if (c == ':') {
 459  495                  if (isbuilding == 1) {
 460  496                          yyunputc(c);
 461  497                          goto done;
 462  498                  }
 463  499                  rval = ':';
 464  500                  goto done;
 465  501          }
 466  502  
 467  503          if (isbuilding == 0 && c == '0') {
↓ open down ↓ 210 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX