2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2018-03-12 11:22:06 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
\
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
#include "cw/ktv.h"
|
2016-03-03 19:51:42 +01:00
|
|
|
#include "cw/dbg.h"
|
2018-03-12 11:22:06 +01:00
|
|
|
#include "cw/log.h"
|
|
|
|
#include "cw/msgset.h"
|
2016-03-11 18:16:13 +01:00
|
|
|
|
2018-03-12 18:01:40 +01:00
|
|
|
|
|
|
|
#include "wtp.h"
|
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
struct bootcfg{
|
|
|
|
const char * modname;
|
|
|
|
const char * modpath;
|
|
|
|
const char * cfgfilename;
|
|
|
|
};
|
2016-03-11 18:16:13 +01:00
|
|
|
|
2018-03-12 18:01:40 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
|
2016-03-11 18:16:13 +01:00
|
|
|
{
|
2018-03-12 11:22:06 +01:00
|
|
|
int c;
|
|
|
|
opterr = 1;
|
|
|
|
|
|
|
|
bootcfg->modname = "cisco";
|
|
|
|
bootcfg->cfgfilename = "config.ktv";
|
|
|
|
|
|
|
|
while ( (c = getopt (argc, argv, "p:d:vc:m:h")) != -1) {
|
2016-03-11 18:16:13 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
switch (c) {
|
|
|
|
case 'v':
|
|
|
|
printf("WFAT version 0.0.1\n");
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
break;
|
|
|
|
case 'd':{
|
|
|
|
int b = cw_strlist_get_id(cw_dbg_strings, optarg);
|
|
|
|
if (b==-1){
|
|
|
|
fprintf(stderr,"Invalid debug option: %s\n",optarg);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
cw_dbg_set_level(b, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'm':
|
|
|
|
bootcfg->modname = optarg;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
cw_mod_set_path(optarg);
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
bootcfg->cfgfilename = optarg;
|
|
|
|
case '?':
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
default:
|
|
|
|
case 'h':
|
|
|
|
printf("%s: -vcmh\n",argv[0]);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
break;
|
|
|
|
}
|
2016-03-11 18:16:13 +01:00
|
|
|
}
|
2018-03-12 11:22:06 +01:00
|
|
|
return 0;
|
2016-03-11 18:16:13 +01:00
|
|
|
}
|
|
|
|
|
2015-04-14 07:42:23 +02:00
|
|
|
|
2018-03-15 20:07:17 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
int main (int argc, char **argv)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
2018-03-12 11:22:06 +01:00
|
|
|
struct bootcfg bootcfg;
|
|
|
|
struct cw_Mod * mod;
|
|
|
|
struct cw_MsgSet * msgset;
|
2018-03-12 18:01:40 +01:00
|
|
|
struct conn * conn;
|
2018-03-15 20:07:17 +01:00
|
|
|
FILE * file;
|
2018-03-12 11:22:06 +01:00
|
|
|
|
|
|
|
parse_args(argc,argv, &bootcfg);
|
|
|
|
|
2016-03-11 18:16:13 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
msgset = cw_msgset_create();
|
|
|
|
if (msgset==NULL){
|
|
|
|
cw_log(LOG_ERR, "Error creating msgset: %s", strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
2016-03-02 19:27:54 +01:00
|
|
|
}
|
2018-03-12 11:22:06 +01:00
|
|
|
mod = cw_mod_load(bootcfg.modname);
|
|
|
|
if (mod == NULL){
|
|
|
|
exit (EXIT_FAILURE);
|
2016-03-09 09:09:28 +01:00
|
|
|
}
|
2018-03-12 11:22:06 +01:00
|
|
|
|
2018-03-12 18:01:40 +01:00
|
|
|
/* Build a message set from our loaded modules */
|
2018-03-12 11:22:06 +01:00
|
|
|
mod->register_messages(msgset, CW_MOD_MODE_CAPWAP);
|
|
|
|
mod->register_messages(msgset, CW_MOD_MODE_BINDINGS);
|
2015-04-26 23:52:11 +02:00
|
|
|
|
2018-03-12 18:01:40 +01:00
|
|
|
/* create a connection object */
|
|
|
|
conn = conn_create_noq(-1, NULL);
|
|
|
|
if (conn==NULL){
|
|
|
|
cw_log(LOG_ERR, "Connot create conn: %s", strerror(errno));
|
2018-03-12 11:22:06 +01:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2018-03-12 18:01:40 +01:00
|
|
|
conn->detected = 1;
|
|
|
|
conn->dtls_verify_peer=0;
|
|
|
|
conn->dtls_mtu = 12000;
|
|
|
|
conn->msgset=msgset;
|
|
|
|
conn->local_cfg = cw_ktv_create();
|
2018-03-15 20:07:17 +01:00
|
|
|
|
|
|
|
file = fopen(bootcfg.cfgfilename,"r");
|
|
|
|
if (file == NULL){
|
|
|
|
cw_log(LOG_ERR,"Cant open file '%s':%s", strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
cw_ktv_read_file(file,conn->local_cfg,msgset->types_tree);
|
2015-04-26 15:48:40 +02:00
|
|
|
|
2018-03-15 20:07:17 +01:00
|
|
|
cw_run_discovery(conn, "255.255.255.255",NULL);
|
2016-03-31 19:23:51 +02:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
return (EXIT_SUCCESS);
|
2018-03-12 18:01:40 +01:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|