1 //--------------------------------------------------------------------------
2 // Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved.
3 // Copyright (C) 2005-2013 Sourcefire, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License Version 2 as published
7 // by the Free Software Foundation.  You may not use, modify or distribute
8 // this program under any other version of the GNU General Public License.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 //--------------------------------------------------------------------------
19 
20 // port_object2.h derived from sfportobject.h by Marc Noron
21 
22 #ifndef PORT_OBJECT2_H
23 #define PORT_OBJECT2_H
24 
25 #include "framework/bits.h"
26 #include "utils/sflsq.h"
27 
28 //-------------------------------------------------------------------------
29 // PortObject2 is similar to PortObject
30 //-------------------------------------------------------------------------
31 
32 namespace snort
33 {
34 class GHash;
35 }
36 
37 struct PortObject;
38 
39 struct PortObject2
40 {
41     // FIXIT-L convert char* to C++ string
42     // prefix of this struct must match first 3 items in PortObject
43     char* name;                 /* user name */
44     int id;                     /* internal tracking - compiling sets this value */
45 
46     SF_LIST* item_list;         /* list of port and port-range items */
47     snort::GHash* rule_hash;         /* hash of rule (rule-indexes) in use */
48 
49     PortBitSet* port_list;      /* for collecting ports that use this object */
50     struct RuleGroup* group;    /* RuleGroup based on rule_hash  */
51 
52     int port_cnt;               /* count of ports using this object */
53 };
54 
55 PortObject2* PortObject2New(int nrules /*guess at this */);
56 void PortObject2Free(PortObject2*);
57 void PortObject2Finalize(PortObject2*);
58 PortObject2* PortObject2Dup(PortObject&);
59 
60 typedef void (*PortObjectIterator)(int port, void*);
61 void PortObject2Iterate(PortObject2*, PortObjectIterator, void*);
62 
63 PortObject2* PortObject2AppendPortObject(PortObject2* poa, PortObject* pob);
64 PortObject2* PortObject2AppendPortObject2(PortObject2* poa, PortObject2* pob);
65 PortObject2* PortObjectAppendEx2(PortObject2* poa, PortObject* pob);
66 
67 void PortObject2PrintPorts(PortObject2* po);
68 void PortObject2Print(PortObject2* po);
69 void PortObject2PrintEx(PortObject2* po,
70     void (* print_index_map)(int index, char* buf, int bufsize) );
71 
72 #endif
73 
74