~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to proxy/mgmt2/web2/MgmtAllow.h

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 
 
3
  A brief file description
 
4
 
 
5
  @section license License
 
6
 
 
7
  Licensed to the Apache Software Foundation (ASF) under one
 
8
  or more contributor license agreements.  See the NOTICE file
 
9
  distributed with this work for additional information
 
10
  regarding copyright ownership.  The ASF licenses this file
 
11
  to you under the Apache License, Version 2.0 (the
 
12
  "License"); you may not use this file except in compliance
 
13
  with the License.  You may obtain a copy of the License at
 
14
 
 
15
      http://www.apache.org/licenses/LICENSE-2.0
 
16
 
 
17
  Unless required by applicable law or agreed to in writing, software
 
18
  distributed under the License is distributed on an "AS IS" BASIS,
 
19
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
20
  See the License for the specific language governing permissions and
 
21
  limitations under the License.
 
22
 */
 
23
 
 
24
/*****************************************************************************
 
25
 *
 
26
 *  MgmtAllow.h - Interface to Manager IP Access Control systtem
 
27
 *
 
28
 *
 
29
 ****************************************************************************/
 
30
 
 
31
#ifndef _MGMT_ALLOW_H_
 
32
#define _MGMT_ALLOW_H_
 
33
 
 
34
#include "IpLookup.h"
 
35
 
 
36
#include "P_RecCore.h"
 
37
 
 
38
#define PATH_NAME_MAX         511
 
39
 
 
40
// INKqa05845
 
41
#define MGMT_ALLOW 1
 
42
#define MGMT_DENY -1
 
43
class MgmtAllowRecord
 
44
{
 
45
public:
 
46
  int access;
 
47
  int line_num;
 
48
};
 
49
 
 
50
class MgmtAllow:public IpLookup
 
51
{
 
52
public:
 
53
  MgmtAllow(const char *config_var, const char *name, const char *action_val);
 
54
   ~MgmtAllow();
 
55
  int BuildTable();
 
56
  void Print();
 
57
  bool match(ip_addr_t ip);
 
58
private:
 
59
  const char *config_file_var;
 
60
  char config_file_path[PATH_NAME_MAX];
 
61
  const char *module_name;
 
62
  const char *action;
 
63
  bool err_allow_all;
 
64
};
 
65
 
 
66
extern MgmtAllow *mgmt_allow_table;
 
67
 
 
68
// INKqa05845
 
69
inline bool
 
70
MgmtAllow::match(ip_addr_t ip)
 
71
{
 
72
  if (err_allow_all == true) {
 
73
    return true;
 
74
  } else {
 
75
    MgmtAllowRecord *cur = NULL, *result = NULL;
 
76
    IpLookupState s;
 
77
    bool found;
 
78
    found = IpLookup::MatchFirst(ip, &s, (void **) &cur);
 
79
    result = cur;
 
80
    while (found) {
 
81
      if (cur->line_num < result->line_num) {
 
82
        result = cur;
 
83
      }
 
84
      found = IpLookup::MatchNext(&s, (void **) &cur);
 
85
    }
 
86
    return ((result != NULL) && (result->access == MGMT_ALLOW));
 
87
  }
 
88
}
 
89
 
 
90
#endif