2014-07-11 22:12:11 +02:00
|
|
|
/*
|
|
|
|
This file is part of actube.
|
|
|
|
|
|
|
|
actube is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
libcapwap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2018-04-02 10:11:25 +02:00
|
|
|
/*#define MAX_WTPS 200*/
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "wtplist.h"
|
2016-03-03 20:46:20 +01:00
|
|
|
#include "cw/conn.h"
|
|
|
|
#include "cw/sock.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include "conf.h"
|
2016-03-03 20:46:20 +01:00
|
|
|
#include "cw/log.h"
|
2016-04-10 16:04:58 +02:00
|
|
|
#include "cw/connlist.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
static struct connlist * connlist;
|
|
|
|
|
|
|
|
|
|
|
|
int wtplist_init()
|
|
|
|
{
|
|
|
|
|
2018-04-02 01:39:08 +02:00
|
|
|
connlist = connlist_create(0,0);
|
2014-07-11 22:12:11 +02:00
|
|
|
if (!connlist)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wtplist_lock()
|
|
|
|
{
|
|
|
|
connlist_lock(connlist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void wtplist_unlock()
|
|
|
|
{
|
|
|
|
connlist_unlock(connlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wtplist_destroy()
|
|
|
|
{
|
|
|
|
connlist_destroy(connlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wtpman * wtplist_get(const struct sockaddr * addr)
|
|
|
|
{
|
|
|
|
|
2022-08-09 22:35:47 +02:00
|
|
|
struct cw_Conn * conn = connlist_get(connlist,addr);
|
2014-07-11 22:12:11 +02:00
|
|
|
if (!conn)
|
|
|
|
return 0;
|
|
|
|
return conn->data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-05-10 22:40:51 +02:00
|
|
|
struct wtpman * wtplist_get_by_session_id(bstr16_t *session_id)
|
2016-04-10 16:04:58 +02:00
|
|
|
{
|
2022-08-09 22:35:47 +02:00
|
|
|
struct cw_Conn search;
|
|
|
|
struct cw_Conn * conn;
|
2018-04-02 10:11:25 +02:00
|
|
|
|
2018-05-10 22:40:51 +02:00
|
|
|
search.session_id = session_id;
|
|
|
|
/*memcpy (search.session_id, session_id,16);*/
|
2016-04-10 16:04:58 +02:00
|
|
|
|
2018-04-02 10:11:25 +02:00
|
|
|
conn = connlist_get_by_session_id(connlist,&search);
|
2018-05-10 22:40:51 +02:00
|
|
|
if (conn == NULL)
|
|
|
|
return NULL;
|
2016-04-10 16:04:58 +02:00
|
|
|
return conn->data;
|
|
|
|
}
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
struct wtpman * wtplist_add(struct wtpman * wtpman)
|
|
|
|
{
|
|
|
|
wtpman->conn->data=wtpman;
|
2014-08-23 12:05:17 +02:00
|
|
|
return (struct wtpman*)connlist_add(connlist,wtpman->conn);
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wtplist_remove(struct wtpman * wtpman)
|
|
|
|
{
|
|
|
|
connlist_remove(connlist,wtpman->conn);
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
2018-05-04 13:37:53 +02:00
|
|
|
|
|
|
|
struct connlist * wtplist_get_connlist(void)
|
|
|
|
{
|
|
|
|
return connlist;
|
|
|
|
}
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|