mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
correctly renamed DTLS ID search functions
This commit is contained in:
@@ -734,7 +734,7 @@ int sfd = -1;
|
||||
now = time(0);
|
||||
|
||||
if (match_ip_only == 0) {
|
||||
proc_to_send = proc_search_sid(s, session_id, session_id_size);
|
||||
proc_to_send = proc_search_dtls_id(s, session_id, session_id_size);
|
||||
} else {
|
||||
proc_to_send = proc_search_ip(s, &cli_addr, cli_addr_size);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ struct cookie_entry_db_st {
|
||||
|
||||
struct proc_hash_db_st {
|
||||
struct htable *db_ip;
|
||||
struct htable *db_sid;
|
||||
struct htable *db_dtls_id;
|
||||
unsigned total;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ struct find_ip_st {
|
||||
unsigned found_ips;
|
||||
};
|
||||
|
||||
struct find_sid_st {
|
||||
const uint8_t *sid;
|
||||
unsigned sid_size;
|
||||
struct find_dtls_id_st {
|
||||
const uint8_t *dtls_id;
|
||||
unsigned dtls_id_size;
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ const struct proc_st * proc = _p;
|
||||
SA_IN_SIZE(proc->remote_addr_len), 0);
|
||||
}
|
||||
|
||||
static size_t rehash_sid(const void* _p, void* unused)
|
||||
static size_t rehash_dtls_id(const void* _p, void* unused)
|
||||
{
|
||||
const struct proc_st * proc = _p;
|
||||
|
||||
@@ -54,17 +54,17 @@ const struct proc_st * proc = _p;
|
||||
void proc_table_init(main_server_st *s)
|
||||
{
|
||||
s->proc_table.db_ip = talloc(s, struct htable);
|
||||
s->proc_table.db_sid = talloc(s, struct htable);
|
||||
s->proc_table.db_dtls_id = talloc(s, struct htable);
|
||||
htable_init(s->proc_table.db_ip, rehash_ip, NULL);
|
||||
htable_init(s->proc_table.db_sid, rehash_sid, NULL);
|
||||
htable_init(s->proc_table.db_dtls_id, rehash_dtls_id, NULL);
|
||||
s->proc_table.total = 0;
|
||||
}
|
||||
|
||||
void proc_table_deinit(main_server_st *s)
|
||||
{
|
||||
htable_clear(s->proc_table.db_ip);
|
||||
htable_clear(s->proc_table.db_sid);
|
||||
talloc_free(s->proc_table.db_sid);
|
||||
htable_clear(s->proc_table.db_dtls_id);
|
||||
talloc_free(s->proc_table.db_dtls_id);
|
||||
talloc_free(s->proc_table.db_ip);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ void proc_table_add(main_server_st *s, struct proc_st *proc)
|
||||
return;
|
||||
}
|
||||
|
||||
if (htable_add(s->proc_table.db_sid, rehash_sid(proc, NULL), proc) == 0) {
|
||||
if (htable_add(s->proc_table.db_dtls_id, rehash_dtls_id(proc, NULL), proc) == 0) {
|
||||
htable_del(s->proc_table.db_ip, ip_hash, proc);
|
||||
return;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ void proc_table_add(main_server_st *s, struct proc_st *proc)
|
||||
void proc_table_del(main_server_st *s, struct proc_st *proc)
|
||||
{
|
||||
htable_del(s->proc_table.db_ip, rehash_ip(proc, NULL), proc);
|
||||
htable_del(s->proc_table.db_sid, rehash_sid(proc, NULL), proc);
|
||||
htable_del(s->proc_table.db_dtls_id, rehash_dtls_id(proc, NULL), proc);
|
||||
}
|
||||
|
||||
static bool local_ip_cmp(const void* _c1, void* _c2)
|
||||
@@ -131,30 +131,30 @@ struct proc_st *proc_search_ip(struct main_server_st *s,
|
||||
return proc;
|
||||
}
|
||||
|
||||
static bool sid_cmp(const void* _c1, void* _c2)
|
||||
static bool dtls_id_cmp(const void* _c1, void* _c2)
|
||||
{
|
||||
const struct proc_st* c1 = _c1;
|
||||
struct find_sid_st* c2 = _c2;
|
||||
struct find_dtls_id_st* c2 = _c2;
|
||||
|
||||
if (c1->dtls_session_id_size != c2->sid_size)
|
||||
if (c1->dtls_session_id_size != c2->dtls_id_size)
|
||||
return 0;
|
||||
|
||||
if (memcmp(c1->dtls_session_id,
|
||||
c2->sid,
|
||||
c2->dtls_id,
|
||||
c1->dtls_session_id_size) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
struct proc_st *proc_search_sid(struct main_server_st *s,
|
||||
struct proc_st *proc_search_dtls_id(struct main_server_st *s,
|
||||
const uint8_t *id, unsigned id_size)
|
||||
{
|
||||
struct find_sid_st fsid;
|
||||
struct find_dtls_id_st fdtls_id;
|
||||
|
||||
fsid.sid = id;
|
||||
fsid.sid_size = id_size;
|
||||
fdtls_id.dtls_id = id;
|
||||
fdtls_id.dtls_id_size = id_size;
|
||||
|
||||
return htable_get(s->proc_table.db_sid, hash_any(id, id_size, 0), sid_cmp, &fsid);
|
||||
return htable_get(s->proc_table.db_dtls_id, hash_any(id, id_size, 0), dtls_id_cmp, &fdtls_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
struct proc_st *proc_search_ip(struct main_server_st *s,
|
||||
struct sockaddr_storage *sockaddr,
|
||||
unsigned sockaddr_size);
|
||||
struct proc_st *proc_search_sid(struct main_server_st *s, const uint8_t *id, unsigned id_size);
|
||||
struct proc_st *proc_search_dtls_id(struct main_server_st *s, const uint8_t *id, unsigned id_size);
|
||||
|
||||
void proc_table_init(main_server_st *s);
|
||||
void proc_table_deinit(main_server_st *s);
|
||||
|
||||
Reference in New Issue
Block a user