starter: Allow %any also for protocol in left|rightprotoport
authorTobias Brunner <tobias@strongswan.org>
Wed, 12 Sep 2012 13:31:02 +0000 (15:31 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 12 Sep 2012 14:53:45 +0000 (16:53 +0200)
src/starter/confread.c

index f30f218..6544b1c 100644 (file)
@@ -268,22 +268,28 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
                        port = sep + 1;
                }
 
-               proto = getprotobyname(value);
-               if (proto)
+               if (streq(value, "%any"))
                {
-                       end->protocol = proto->p_proto;
+                       end->protocol = 0;
                }
                else
                {
-                       p = strtol(value, &endptr, 0);
-                       if ((*value && *endptr) || p < 0 || p > 0xff)
+                       proto = getprotobyname(value);
+                       if (proto)
                        {
-                               DBG1(DBG_APP, "# bad protocol: %s=%s", name, value);
-                               goto err;
+                               end->protocol = proto->p_proto;
+                       }
+                       else
+                       {
+                               p = strtol(value, &endptr, 0);
+                               if ((*value && *endptr) || p < 0 || p > 0xff)
+                               {
+                                       DBG1(DBG_APP, "# bad protocol: %s=%s", name, value);
+                                       goto err;
+                               }
+                               end->protocol = (u_int8_t)p;
                        }
-                       end->protocol = (u_int8_t)p;
                }
-
                if (streq(port, "%any"))
                {
                        end->port = 0;