OSDN Git Service

Initial commit from 2.1.2-1
[ultramonkey-l7/ultramonkey-l7-v2.git] / module / protocol / module_sslid_hash.cpp
1 /*
2  * @file  module_sslid_hash.cpp
3  * @brief sslid hashmap container wrapper.
4  * @brief this module provide session persistence by SSL session ID.
5  *
6  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
7  * Copyright (C) 2008  NTT COMWARE Corporation.
8  * Copyright (C) 2009  Shinya TAKEBAYASHI
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23  * 02110-1301 USA
24  *
25  **********************************************************************/
26
27 #include <list>
28 #include <string>
29 #include <tr1/unordered_map>
30 #include "l7vs_dest.h"
31 #include "module_sslid_hash.h"
32 #include "module_sslid_hash_map.h"
33
34 static CSSLIDMap idmap;
35
36 void hash_setPointer(const void *keymap, const void *keylist, unsigned int size)
37 {
38   idmap.setPointer((IDLIST *)keymap, (IDLIST *)keylist, size);
39 }
40
41
42 void hash_add(const char *key, struct l7vs_dest data)
43 {
44   idmap.add(key, data);
45 }
46
47
48 int hash_search(const char *key, struct l7vs_dest **data)
49 {
50   struct l7vs_dest *tmpdata;
51   int retval;
52   bool retval_boolean;
53
54   retval_boolean = idmap.search(key, &tmpdata);
55   
56   if (true == retval_boolean) {
57     *data = tmpdata;
58     retval = 0;
59
60   } else {
61     retval = -1;
62
63   }
64
65   return retval;
66 }
67
68
69 void hash_allocate(unsigned int size)
70 {
71   idmap.allocate(size);
72 }
73
74
75 void hash_destroy(void)
76 {
77   idmap.destroy();
78 }
79
80   
81 void *hash_getIDMAP(void)
82 {
83   return idmap.getIDMAP();
84 }
85
86
87 void *hash_getIDLIST(void)
88 {
89   return idmap.getIDLIST();
90 }
91
92
93 int hash_getLISTSIZE(void)
94 {
95   idmap.getLISTSIZE();
96 }
97
98
99 void hash_construct_sessionlist(struct l7vs_sslid_service* sslid_service)
100 {
101   idmap.construct_sessionlist(sslid_service);
102 }
103
104
105 void hash_rebuild_sessionlist(struct l7vs_sslid_service* sslid_service)
106 {
107   idmap.rebuild_sessionlist(sslid_service);
108 }