Work in progrsss.

FossilOrigin-Name: efb7fb1dc204a4d673f899994eb72005a6cdead3dff43ecab63f1ed4ca8e61ba
This commit is contained in:
7u83@mail.ru
2014-09-14 20:46:14 +00:00
parent 8677fe1a1e
commit 4f7def25f2
16 changed files with 214 additions and 61 deletions

View File

@ -1,3 +1,5 @@
include ../WtpConfig.mak
ifndef CC
CC=gcc
endif
@ -38,14 +40,17 @@ CFLAGS += -O2 -Wall -g
#endif
LDFLAGS += -L../../src/capwap/$(ARCH)
LDFLAGS += -L/usr/local/lib
#LDFLAGS += -L/usr/local/lib
LDFLAGS += -luci
#LDFLAGS += -L../capwap
LDFLAGS += $(XLIB)
#LDFLAGS += -lpthread
#LDFLAGS += -lrt
LIBS+=-lcapwap
#LIBS+=-liw
LIBS+=-liw
LIBS+=-lnl-tiny
LIBS+=-lssl
LIBS+=-lcrypto
#LIBS+=-lrt
@ -55,11 +60,20 @@ else
LIBS+=-lconfuse
endif
#HA_FILES += ../contrib/hostap/src/drivers/driver_nl80211.o
CFLAGS += -I../src
CFLAGS += -I../src/utils
HA_INCS += -I$(INCLUDE_DIR)/libnl-tiny
HA_INCS += -I../contrib/hostap/src/utils
HA_INCS += -I../contrib/hostap/src
CFLAGS += $(HA_INCS)
#CFLAGS += -I../src
#CFLAGS += -I../src/utils
CFLAGS += -I../../src
CFLAGS += -I/usr/local/include
#CFLAGS += -I/usr/local/include
@ -75,6 +89,7 @@ OBJS += wtp_main.o
#OBJS += wtp_conf.o
OBJS += discovery.o
OBJS += wtp_interface.o
OBJS += wtpdrv.o
@ -84,6 +99,11 @@ OBJS += sulking.o
OBJS += configure.o
OBJS += $(CONFOBJS)
OBJS += nlt_attrnames.o
#OBJS += $(HA_FILES)
ALL=wtp
all: $(ALL)

View File

@ -82,12 +82,7 @@ int read_config(const char * filename){
const char *str;
str = uci_lookup_option_string(ctx,section,"name");
printf("Option string: %s\n",str);
conf_wtpname = strdup(str);
return 1;

View File

@ -19,6 +19,8 @@
#include "capwap/sock.h"
#include "capwap/cw_log.h"
char * conf_primary_if=0;
char * conf_wtpname=0;
@ -78,7 +80,7 @@ int wtpconf_primary_if()
return 0;
};
cw_log_debug0("Primary interfac: %s, mac address: %s.",
cw_dbg(DBG_CW_INFO, "Primary interface: %s, mac address: %s.",
conf_primary_if,
sock_hwaddr2str(conf_macaddress,conf_macaddress_len)
);
@ -100,7 +102,7 @@ int wtpconf_name()
if (!conf_wtpname)
return 0;
cw_log_debug0("Using self assigned wtp name: %s",conf_wtpname);
cw_dbg(DBG_CW_INFO,"Using self assigned wtp name: %s",conf_wtpname);
return 1;
}
@ -112,8 +114,9 @@ int wtpconf_name()
char * default_ac_list[] = {
"255.255.255.255",
"224.0.1.140",
"192.168.0.255",
// "255.255.255.255",
// "224.0.1.140",
};
int wtpconf_ac_list()

View File

@ -31,26 +31,26 @@ struct wtpinfo * get_wtpinfo()
wtpinfo->model_no="WNDR 3700";
wtpinfo->bootloader_version="1.0";
wtpinfo->bootloader_vendor_id=12345;
wtpinfo->bootloader_version="";
wtpinfo->bootloader_vendor_id=890;
wtpinfo->hardware_version="2.5";
wtpinfo->hardware_vendor_id=909090;
wtpinfo->hardware_version="\0\0";
wtpinfo->hardware_vendor_id=890;
wtpinfo->software_version="2.0";
wtpinfo->software_vendor_id=11591;
wtpinfo->software_version="2.23(UJA.6)";
wtpinfo->software_vendor_id=890;
wtpinfo->macaddress=conf_macaddress;
wtpinfo->macaddress_len=conf_macaddress_len;
wtpinfo->mac_type=1;
wtpinfo->mac_type=0;
wtpinfo->session_id = malloc(8);
wtpinfo->session_id_len = cw_rand(wtpinfo->session_id,8);
wtpinfo->frame_tunnel_mode=0;
wtpinfo->frame_tunnel_mode=1;
return wtpinfo;
}

View File

@ -19,7 +19,6 @@
struct wtpinfo wtpinfo;
//int conf_rids[2];
@ -58,6 +57,8 @@ const char * interfaces[]={
int main()
{
gr();
exit(0);
wtp_main();
}
@ -92,15 +93,19 @@ int do_connect(void *priv,void *data)
int wtp_main(const char *ad)
{
cw_dbg_opt_level = DBG_DTLS | DBG_CW_INFO | DBG_ALL;
wtpconf_preinit();
if (!read_config("wtp.conf")){
if (!read_config("./wtpconf")){
return 1;
}
wtpconf_init();
// cw_log_debug_level=6; //conf_debug_level;
conf_dtls_psk="Tube";
@ -110,7 +115,6 @@ int wtp_main(const char *ad)
// conf_sslkeypass="7u83";
cw_dbg_opt_level = DBG_DTLS;
#ifdef WITH_DTLS
dtls_init();
@ -123,7 +127,7 @@ int wtp_main(const char *ad)
ACIPLIST * aciplist=0;
int i;
cw_log_debug0("Entering discovery state");
cw_dbg(DBG_CW_INFO,"Entering discovery state");
do {
for (i=0; i<conf_ac_list_len; i++){

View File

@ -1,4 +1,5 @@
#include "wtpdrv.h"
#include "nlt.h"
wpa_printf()
@ -68,7 +69,7 @@ static int nlCallback(struct nl_msg *msg, void *arg)
struct nlattr *nla;
nla_for_each_attr(nla,head,alen,rem){
printf("ATR Type: %d\n",nla->nla_type);
printf("ATR Type: %d - %s\n",nla->nla_type,nlt_get_attrname(nla->nla_type));
}
@ -98,6 +99,72 @@ static int nlCallback(struct nl_msg *msg, void *arg)
}
void make_if(struct nl_sock * sk)
{
/* allocate a message */
struct nl_msg *msg = nlmsg_alloc();
if (!msg)
return;
/* init message */
genlmsg_put(msg, 0, NL_AUTO_SEQ, family_id, 0, 0,
NL80211_CMD_NEW_INTERFACE, 0);
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, 0);
NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE,NL80211_IFTYPE_AP);
NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME,"wulan0");
int ret = nl_send_auto_complete(sk, msg);
printf("IF Send ret %d\n",ret);
int nlr = nl_recvmsgs_default(sk);
printf("NLR = %d\n",nlr);
nla_put_failure:
nlmsg_free(msg);
return 1;
}
void start_ap(struct nl_sock * sk)
{
/* allocate a message */
struct nl_msg *msg = nlmsg_alloc();
if (!msg)
return;
/* init message */
genlmsg_put(msg, 0, NL_AUTO_SEQ, family_id, 0, 0,
NL80211_CMD_START_AP, 0);
printf("Set bi\n");
NLA_PUT_U16(msg, NL80211_ATTR_BEACON_INTERVAL, 500);
printf("Sot biu\n");
const char *ssid = "HelloWorld";
NLA_PUT(msg,NL80211_ATTR_SSID,strlen(ssid),ssid);
// nla_put(msg,NL80211_ATTR_SSID,ssid,strlen(ssid));
printf("Sot ssid\n");
int ret = nl_send_auto_complete(sk, msg);
printf("AP IF Send ret %d\n",ret);
int nlr = nl_recvmsgs_default(sk);
printf("AP NLR = %d\n",nlr);
nla_put_failure:
printf("Bau\n");
nlmsg_free(msg);
return 1;
}
void gr()
{
@ -113,6 +180,19 @@ void gr()
nl_socket_modify_cb(sk, NL_CB_VALID, NL_CB_CUSTOM, nlCallback,
NULL);
printf("Mak If\n");
make_if(sk);
printf("made if\n");
start_ap(sk);
sleep(100);
return;
//allocate a message
struct nl_msg *msg = nlmsg_alloc();