summaryrefslogtreecommitdiff
path: root/scanner/ip_matcher/IntervalIndex/IPMaskIndex.h
blob: b7b28901dc910ba560af6a064f6bb126e61b8e16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 *
 * Copyright (c) 2008-2016
 * String Algorithms Research Group
 * Institute of Information Engineering, Chinese Academy of Sciences (IIE-CAS)
 * National Engineering Laboratory for Information Security Technologies (NELIST)
 * All rights reserved
 *
 * Written by: LIU YANBING    ([email protected])
 * Last modification: 2016-05-31
 *
 * This code is the exclusive and proprietary property of IIE-CAS and NELIST. 
 * Usage for direct or indirect commercial advantage is not allowed without 
 * written permission from the authors.
 *
 */

/* ��������IP�ֶΣ�����Ϊ����IP����8-bit�����IP */

#ifndef H_IPMASK_INDEX_CPP_H
#define H_IPMASK_INDEX_CPP_H

#include "IntervalIndex.h"
#include "SuccinctHash.h"
#include <vector>
using namespace std;

bool is_8bit_ipmask(const vector<unsigned int>& a, const vector<unsigned int>& b);

class CIPMaskIndex : public CIntervalIndex
{
public:
	CIPMaskIndex();

	virtual ~CIPMaskIndex();

	virtual long long PreProcessing(const std::vector<unsigned int>& a, const std::vector<unsigned int>& b);

	virtual int Find(unsigned int key, unsigned int * result, unsigned int size);

private:
	bool                m_is_single;
	unsigned char       m_bitmap[1U<<21];
	unsigned int        m_L[(1U<<24)+1];
	unsigned int *      m_values;
	CSuccinctHash *     m_ip_hash;
};

#endif