2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
//#include <iwlib.h>
|
|
|
|
|
|
|
|
#include "capwap/sock.h"
|
|
|
|
#include "capwap/conn.h"
|
|
|
|
#include "capwap/dtls.h"
|
|
|
|
#include "capwap/avltree.h"
|
|
|
|
#include "capwap/cw_log.h"
|
|
|
|
#include "capwap/capwap.h"
|
|
|
|
#include "capwap/cw_util.h"
|
|
|
|
#include "capwap/wtpinfo.h"
|
|
|
|
|
|
|
|
#include "wtp.h"
|
|
|
|
#include "wtp_conf.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wtpinfo wtpinfo;
|
|
|
|
|
|
|
|
//int conf_rids[2];
|
|
|
|
//int conf_rids_len[2];
|
|
|
|
|
|
|
|
//int responses = 0;
|
|
|
|
|
|
|
|
struct avltree * aclist =0;
|
|
|
|
|
|
|
|
|
|
|
|
extern struct wpa_driver_ops *wpa_drivers[];
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <ifaddrs.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
//struct sockaddr conf_preferred_ac;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void * drv_priv[2];
|
|
|
|
static void * drv_glob[2];
|
|
|
|
|
|
|
|
const char * interfaces[]={
|
|
|
|
"wlan0",
|
|
|
|
"wlan1-1"
|
|
|
|
};
|
|
|
|
|
|
|
|
/*static int drv_init()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
wtp_main();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#include <openssl/ssl.h>
|
|
|
|
|
|
|
|
int do_connect(void *priv,void *data)
|
|
|
|
{
|
|
|
|
ACIP * ip = (ACIP*)data;
|
|
|
|
// char str[100];
|
|
|
|
// sock_addrtostr((struct sockaddr*)&ip->ip,str,100);
|
|
|
|
|
|
|
|
sock_setport(&ip->ip,atoi(conf_control_port));
|
|
|
|
// printf("Would connect to %s\n",str);
|
|
|
|
|
2014-07-19 13:26:45 +02:00
|
|
|
int rc;
|
|
|
|
rc = join(&ip->ip);
|
2014-07-11 22:12:11 +02:00
|
|
|
if (!rc)
|
|
|
|
return 1;
|
|
|
|
|
2014-07-19 13:26:45 +02:00
|
|
|
|
|
|
|
rc = configure();
|
|
|
|
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
run (get_conn());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int wtp_main(const char *ad)
|
|
|
|
{
|
2014-07-22 07:11:57 +02:00
|
|
|
|
|
|
|
wtpconf_preinit();
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
if (!read_config("wtp.conf")){
|
|
|
|
return 1;
|
|
|
|
}
|
2014-07-22 07:11:57 +02:00
|
|
|
|
|
|
|
wtpconf_init();
|
|
|
|
|
|
|
|
cw_log_debug_level=2; //conf_debug_level;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#ifdef WITH_DTLS
|
|
|
|
dtls_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//drv_init();
|
|
|
|
|
|
|
|
|
|
|
|
while (1){
|
|
|
|
ACIPLIST * aciplist=0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
cw_log_debug0("Entering discovery state");
|
|
|
|
|
|
|
|
do {
|
|
|
|
for (i=0; i<conf_ac_list_len; i++){
|
|
|
|
if ((aciplist = do_discovery(conf_ac_list[i])))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}while (!aciplist);
|
|
|
|
|
|
|
|
cw_log_debug0("Entering join state");
|
|
|
|
if (!aciplist){
|
|
|
|
cw_log_debug0("Don't got any discovery response");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
aciplist_foreach(aciplist,do_connect,0);
|
|
|
|
|
|
|
|
aciplist_destroy(aciplist);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|