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>

@@ -3,26 +3,29 @@
  *
  * See the IPFILTER.LICENCE file for details on licencing.
  *
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright 2019 Joyent, Inc.
  */
 
 #include <ctype.h>
 #include "ipf.h"
 #ifdef  IPFILTER_SCAN
 # include "netinet/ip_scan.h"
 #endif
 #include <sys/ioctl.h>
 #include <syslog.h>
+#include <uuid/uuid.h>
 #ifdef  TEST_LEXER
 # define        NO_YACC
 union   {
         int             num;
         char            *str;
         struct in_addr  ipa;
         i6addr_t        ip6;
+        uuid_t          uuid;
 } yylval;
 #endif
 #include "lexer.h"
 #include "y.tab.h"
 

@@ -453,10 +456,43 @@
                 yypos = start;
                 c = oc;
         }
 #endif
 
+        /*
+         * UUID: 2426e38c-9f63-c0b8-cfd5-9aaeaf992d42 or uppercase
+         */
+        if (isbuilding == 0 && (ishex(c) || c == '-')) {
+                char uuidbuf[UUID_PRINTABLE_STRING_LENGTH], *s, oc;
+                int start;
+
+                start = yypos;
+                s = uuidbuf;
+                oc = c;
+
+                /*
+                 * Don't worry about exact position of hexdigits and hyphens
+                 * because uuid_parse() will provide the sanity check.
+                 */
+                do {
+                        *s++ = c;
+                        c = yygetc(1);
+                } while ((ishex(c) || c == '-') &&
+                    (s - uuidbuf < sizeof (uuidbuf)));
+                yyunputc(c);
+                *s = '\0';
+
+                if (uuid_parse(uuidbuf, yylval.uuid) == 0) {
+                        rval = YY_UUID;
+                        yyexpectaddr = 0;
+                        goto done;
+                }
+                yypos = start;
+                c = oc;
+        }
+
+
         if (c == ':') {
                 if (isbuilding == 1) {
                         yyunputc(c);
                         goto done;
                 }