TS-2338 Remove IPRange.cc and .h, and SocksParser.cc

Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f7a55288
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f7a55288
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f7a55288

Branch: refs/heads/5.0.x
Commit: f7a5528881d1b2c5da35a1f319254525db367937
Parents: ca12e94
Author: Leif Hedstrom <[email protected]>
Authored: Sun Nov 10 16:44:25 2013 -0700
Committer: Leif Hedstrom <[email protected]>
Committed: Tue Nov 12 15:54:51 2013 -0700

----------------------------------------------------------------------
 mgmt/preparse/IPRange.cc     | 203 --------------------------------------
 mgmt/preparse/IPRange.h      |  69 -------------
 mgmt/preparse/Makefile.am    |   1 -
 mgmt/preparse/SocksParser.cc |  24 -----
 4 files changed, 297 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f7a55288/mgmt/preparse/IPRange.cc
----------------------------------------------------------------------
diff --git a/mgmt/preparse/IPRange.cc b/mgmt/preparse/IPRange.cc
deleted file mode 100644
index 58bb2ad..0000000
--- a/mgmt/preparse/IPRange.cc
+++ /dev/null
@@ -1,203 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @section license License
-
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- */
-
-/****************************************************************************
-
-  IPRange.cc
-
-  This file an IPRange object that reads a range of IPS, and does
-  matching of a given IP address against those ranges.
- ****************************************************************************/
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdio.h>
-#include "ink_assert.h"
-#include "IPRange.h"
-
-#define TEST(_x)
-
-// #define TEST(_x) _x
-
-#define ERR_STRING_LEN 100
-
-// Returns 0 if successful, 1 if failed
-int
-read_an_ip(char *line, unsigned int *ip, int *i, int n)
-{
-  int k;
-  char s[17];
-  while ((*i) < n && isspace(line[(*i)]))
-    (*i)++;
-  if (*i == n) {
-    TEST(printf("Socks Configuration (read_an_ip1): Invalid Syntax in line 
%s\n", line);
-      );
-    return 1;
-  }
-  for (k = 0; k < 17 && (isdigit(line[(*i)]) || (line[(*i)] == '.')); k++, 
(*i)++) {
-    s[k] = line[(*i)];
-  }
-  if (k == 17) {
-    TEST(printf("Socks Configuration (read_an_ip2): Invalid Syntax in line %s, 
k %d\n", line, k);
-      );
-    return 1;
-  }
-  s[k] = '\0';
-  k++;
-  TEST(printf("IP address read %s\n", s);
-    );
-  *ip = inet_addr(s);
-  if (*ip == (unsigned int) -1) {
-    TEST(printf("Socks Configuration: Illegal IP address read %s, %u\n", s, 
*ip);
-      );
-    return 1;
-  }
-  return 0;
-}
-
-// Returns 0 if successful, error string otherwise
-char *
-IPRange::read_table_from_file(int fd, const char *identifier_str, bool localip)
-{
-  int i, j, n, rc, s, line_no;
-  char c, line[MAXLINESIZE];
-  bool end_of_file;
-  unsigned int ip;
-  char first_string[MAXLINESIZE];
-
-  // First hardcode 127.0.0.1 into the table
-  ips[0] = ntohl(inet_addr("127.0.0.1"));
-  n_ips++;
-
-  line_no = 0;
-  end_of_file = false;
-  do {
-    line_no++;
-    n = 0;
-    while (((s = read(fd, &c, 1)) == 1) && (c != '\n') && n < MAXLINESIZE - 1)
-      line[n++] = c;
-    if (s <= 0)
-      c = EOF;                  // mimic behavior of getc on EOF
-    // append null
-    line[n] = '\0';
-    if (c == (char)EOF)
-      end_of_file = true;
-    // first_string has the same length as line, so here we disable coverity 
check
-    // coverity[secure_coding]
-    rc = sscanf(line, "%s", first_string);
-    if ((rc <= 0) || strcmp(first_string, identifier_str))
-      continue;
-    i = 0;
-    while (i < n && isspace(line[i]))
-      i++;
-    ink_assert(i != n);
-    j = 0;
-    while (!isspace(line[i])) {
-      first_string[j] = line[i];
-      i++;
-      j++;
-    }
-    first_string[j] = '\0';
-    ink_assert(!strcmp(first_string, identifier_str));
-    // Now look for IP address
-    while (true) {
-      while (i < n && isspace(line[i]))
-        i++;
-      if (i == n)
-        break;
-      if (read_an_ip(line, &ip, &i, n) == 1) {
-        char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
-        snprintf(error_str, ERR_STRING_LEN, "Incorrect Syntax in Socks 
Configuration at Line %d", line_no);
-        return error_str;
-      }
-      while (i < n && isspace(line[i]))
-        i++;
-      if (i == n || line[i] == ',') {
-        // You have read an IP address. Enter it in the table
-        ips[(n_ips)++] = ntohl(ip);
-        if (i == n)
-          break;
-        else
-          i++;
-      } else if (line[i] == '-') {
-        // What you have just read is the start of the range,
-        // Now, read the end of the IP range
-        i++;
-        ip_ranges_start[(n_ip_ranges)] = ntohl(ip);
-        if (read_an_ip(line, &ip, &i, n) == 1) {
-          char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
-          snprintf(error_str, ERR_STRING_LEN, "Incorrect Syntax in Socks 
Configuration at Line %d", line_no);
-          return error_str;
-        }
-        ip_ranges_finish[(n_ip_ranges)++] = ntohl(ip);
-        while (i < n && isspace(line[i]))
-          i++;
-        if (i == n)
-          break;
-        if (line[i] != ',') {
-          TEST(printf("Socks Configuration (read_table_from_file1):Invalid 
Syntax in line %s\n", (char *) line);
-            );
-          char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
-          snprintf(error_str, ERR_STRING_LEN, "Incorrect Syntax in Socks 
Configuration at Line %d", line_no);
-          return error_str;
-        }
-        i++;
-      } else {
-        TEST(printf("Socks Configuration (read_table_from_file2):Invalid 
Syntax in line %s\n", (char *) line);
-          );
-        char *error_str = (char *)ats_malloc(ERR_STRING_LEN);
-        snprintf(error_str, ERR_STRING_LEN, "Incorrect Syntax in Socks 
Configuration at Line %d", line_no);
-        return error_str;
-      }
-    }
-  } while (!end_of_file);
-  TEST(printf("Socks Conf File Read\n");
-    );
-  return 0;
-}
-
-bool
-IPRange::match(unsigned int ip)
-{
-  int i;
-  ip = ntohl(ip);
-  for (i = 0; i < n_ip_ranges; i++) {
-    if (ip_ranges_start[i] <= ip && ip <= ip_ranges_finish[i]) {
-      TEST(printf("Match found in the table for %u\n", ip);
-        );
-      return true;
-    }
-  }
-  for (i = 0; i < n_ips; i++) {
-    if (ips[i] == ip) {
-      TEST(printf("Match found in the table for %u\n", ip);
-        );
-      return true;
-    }
-  }
-  TEST(printf("No Match found in the table for %u\n", ip);
-    );
-  return false;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f7a55288/mgmt/preparse/IPRange.h
----------------------------------------------------------------------
diff --git a/mgmt/preparse/IPRange.h b/mgmt/preparse/IPRange.h
deleted file mode 100644
index 74174bc..0000000
--- a/mgmt/preparse/IPRange.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/** @file
-
-  Matching of a given IP addr against ranges of addrs
-
-  @section license License
-
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- */
-
-#ifndef _IPRange_h_
-#define _IPRange_h_
-
-#include "libts.h"
-
-#define MAX_IP 400
-#define MAX_IP_RANGES 400
-#define MAXLINESIZE 400
-
-struct IPRange
-{
-public:
-
-  /** @return true if ip matches, false otherwise. */
-  bool match(unsigned int ip);
-
-  /**
-    @return 0 for successful read, error string (malloc'ed) otherwise,
-      identifier_str is the string that is used to select the relevant
-      lines.
-
-  */
-  char *read_table_from_file(int fd, const char *identifier_str, bool localip 
= true);
-    IPRange():n_ips(0), n_ip_ranges(0)
-  {
-
-    for (int i = 0; i < MAX_IP; i++)
-    {
-      ips[i] = 0;
-    }
-
-    for (int i = 0; i < MAX_IP_RANGES; i++) {
-      ip_ranges_start[i] = 0;
-      ip_ranges_finish[i] = 0;
-    }
-
-
-  }
-
-private:
-  int n_ips, n_ip_ranges;
-  unsigned int ips[MAX_IP];
-  unsigned int ip_ranges_start[MAX_IP_RANGES];
-  unsigned int ip_ranges_finish[MAX_IP_RANGES];
-};
-#endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f7a55288/mgmt/preparse/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/preparse/Makefile.am b/mgmt/preparse/Makefile.am
index 53055dd..346129c 100644
--- a/mgmt/preparse/Makefile.am
+++ b/mgmt/preparse/Makefile.am
@@ -27,5 +27,4 @@ noinst_LIBRARIES = libpreparse.a
 libpreparse_a_SOURCES = \
   IPRange.h \
   RemapReadConfig.cc \
-  SocksParser.cc \
   StoreReadConfig.cc

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f7a55288/mgmt/preparse/SocksParser.cc
----------------------------------------------------------------------
diff --git a/mgmt/preparse/SocksParser.cc b/mgmt/preparse/SocksParser.cc
deleted file mode 100644
index 065e1c1..0000000
--- a/mgmt/preparse/SocksParser.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-/** @file
-
-  Veriy syntax of socks.config
-
-  @section license License
-
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- */
-
-#include "IPRange.h"

Reply via email to