More work on modules.
FossilOrigin-Name: 0bbe4da84ffab94d8bcf71f8e153eeb1b6cd6b41d39dd3943a39d7fc291084f9
This commit is contained in:
parent
914138f2f3
commit
9785c8a25f
@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
# strict_headers
|
# strict_headers
|
||||||
#
|
#
|
||||||
# If set to 1, any malformed packets wil b thrown away.
|
# If set to on, any malformed packets wil be thrown away.
|
||||||
#
|
#
|
||||||
# Default:
|
# Default:
|
||||||
# strict_headers = on
|
# strict_headers = on
|
||||||
|
@ -215,7 +215,7 @@ int ac_run()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* broadcast sockety ipv4 only */
|
/* broadcast socket ipv4 only */
|
||||||
for (i = 0; i < conf_bcast_addrs_len; i++) {
|
for (i = 0; i < conf_bcast_addrs_len; i++) {
|
||||||
socklist_add_broadcast(conf_bcast_addrs[i], conf_control_port,
|
socklist_add_broadcast(conf_bcast_addrs[i], conf_control_port,
|
||||||
AC_PROTO_CAPWAP);
|
AC_PROTO_CAPWAP);
|
||||||
|
@ -345,6 +345,7 @@ static int init_listen_addrs()
|
|||||||
for (ifa=ifap; ifa!=0; ifa=ifa->ifa_next){
|
for (ifa=ifap; ifa!=0; ifa=ifa->ifa_next){
|
||||||
char str[100];
|
char str[100];
|
||||||
|
|
||||||
|
/** ignore loopback interfaces if configured*/
|
||||||
if(!conf_use_loopback){
|
if(!conf_use_loopback){
|
||||||
if ((ifa->ifa_flags & IFF_LOOPBACK)){
|
if ((ifa->ifa_flags & IFF_LOOPBACK)){
|
||||||
continue;
|
continue;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
static int init()
|
static int init()
|
||||||
{
|
{
|
||||||
|
// regn = cw_register_actions_cipwap_ac(&capwap_actions);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
166
src/ac/wtpman.c
166
src/ac/wtpman.c
@ -109,7 +109,7 @@ static void wtpman_run_discovery(void *arg)
|
|||||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
struct wtpman *wtpman = (struct wtpman *) arg;
|
||||||
//struct cwrmsg *cwrmsg;
|
//struct cwrmsg *cwrmsg;
|
||||||
|
|
||||||
struct conn * conn = wtpman->conn;
|
struct conn *conn = wtpman->conn;
|
||||||
|
|
||||||
|
|
||||||
//conn->config = mbag_create();
|
//conn->config = mbag_create();
|
||||||
@ -175,8 +175,7 @@ static int wtpman_establish_dtls(void *arg)
|
|||||||
wtpman->conn->dtls_key_pass = conf_sslkeypass;
|
wtpman->conn->dtls_key_pass = conf_sslkeypass;
|
||||||
wtpman->conn->dtls_verify_peer = conf_dtls_verify_peer;
|
wtpman->conn->dtls_verify_peer = conf_dtls_verify_peer;
|
||||||
cw_dbg(DBG_DTLS, "Using key file %s", wtpman->conn->dtls_key_file);
|
cw_dbg(DBG_DTLS, "Using key file %s", wtpman->conn->dtls_key_file);
|
||||||
cw_dbg(DBG_DTLS, "Using cert file %s",
|
cw_dbg(DBG_DTLS, "Using cert file %s", wtpman->conn->dtls_cert_file);
|
||||||
wtpman->conn->dtls_cert_file);
|
|
||||||
dtls_ok = 1;
|
dtls_ok = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,8 +210,8 @@ static int wtpman_establish_dtls(void *arg)
|
|||||||
|
|
||||||
cert = dtls_get_peers_cert(wtpman->conn, 0);
|
cert = dtls_get_peers_cert(wtpman->conn, 0);
|
||||||
|
|
||||||
// printf("Have Peers Cert: %p, %d\n", cert.data, cert.size);
|
// printf("Have Peers Cert: %p, %d\n", cert.data, cert.size);
|
||||||
// fwrite(cert.data, 1, cert.size, f);
|
// fwrite(cert.data, 1, cert.size, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
|
||||||
@ -222,14 +221,14 @@ static int wtpman_establish_dtls(void *arg)
|
|||||||
static int wtpman_join(void *arg, time_t timer)
|
static int wtpman_join(void *arg, time_t timer)
|
||||||
{
|
{
|
||||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
struct wtpman *wtpman = (struct wtpman *) arg;
|
||||||
struct conn * conn = wtpman->conn;
|
struct conn *conn = wtpman->conn;
|
||||||
|
|
||||||
wtpman->conn->outgoing = mbag_create();
|
wtpman->conn->outgoing = mbag_create();
|
||||||
wtpman->conn->incomming = mbag_create();
|
wtpman->conn->incomming = mbag_create();
|
||||||
conn->config=conn->incomming;
|
conn->config = conn->incomming;
|
||||||
// wtpman->conn->local = ac_config;
|
// wtpman->conn->local = ac_config;
|
||||||
|
|
||||||
mbag_set_str(conn->local,CW_ITEM_AC_NAME,conf_acname);
|
mbag_set_str(conn->local, CW_ITEM_AC_NAME, conf_acname);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -249,7 +248,7 @@ static int wtpman_join(void *arg, time_t timer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO,"Join State - %s",sock_addr2str(&conn->addr));
|
cw_dbg(DBG_INFO, "Join State - %s", sock_addr2str(&conn->addr));
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
while (!cw_timer_timeout(timer) && wtpman->conn->capwap_state == CW_STATE_JOIN) {
|
while (!cw_timer_timeout(timer) && wtpman->conn->capwap_state == CW_STATE_JOIN) {
|
||||||
@ -259,8 +258,8 @@ static int wtpman_join(void *arg, time_t timer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc != 0 ) {
|
if (rc != 0) {
|
||||||
cw_log(LOG_ERR,"Error joining WTP %s",cw_strerror(rc));
|
cw_log(LOG_ERR, "Error joining WTP %s", cw_strerror(rc));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -281,52 +280,51 @@ static int wtpman_join(void *arg, time_t timer)
|
|||||||
|
|
||||||
static void wtpman_image_data(struct wtpman *wtpman)
|
static void wtpman_image_data(struct wtpman *wtpman)
|
||||||
{
|
{
|
||||||
struct conn * conn = wtpman->conn;
|
struct conn *conn = wtpman->conn;
|
||||||
|
|
||||||
/* Image upload */
|
/* Image upload */
|
||||||
const char *filename =
|
const char *filename = mbag_get_str(conn->outgoing, CW_ITEM_IMAGE_FILENAME, NULL);
|
||||||
mbag_get_str(conn->outgoing, CW_ITEM_IMAGE_FILENAME,NULL);
|
if (!filename) {
|
||||||
if (!filename) {
|
cw_log(LOG_ERR,
|
||||||
cw_log(LOG_ERR,
|
"Can't send image to %s. No Image Filename Item found.",
|
||||||
"Can't send image to %s. No Image Filename Item found.",
|
|
||||||
sock_addr2str(&conn->addr));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cw_dbg(DBG_INFO, "Sending image file '%s' to '%s'.", filename,
|
|
||||||
sock_addr2str(&conn->addr));
|
sock_addr2str(&conn->addr));
|
||||||
FILE *infile = fopen(filename, "rb");
|
return;
|
||||||
if (infile == NULL) {
|
}
|
||||||
cw_log(LOG_ERR, "Can't open image %s: %s",
|
cw_dbg(DBG_INFO, "Sending image file '%s' to '%s'.", filename,
|
||||||
sock_addr2str(&conn->addr), strerror(errno));
|
sock_addr2str(&conn->addr));
|
||||||
return;
|
FILE *infile = fopen(filename, "rb");
|
||||||
}
|
if (infile == NULL) {
|
||||||
|
cw_log(LOG_ERR, "Can't open image %s: %s",
|
||||||
|
sock_addr2str(&conn->addr), strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CW_CLOCK_DEFINE(clk);
|
CW_CLOCK_DEFINE(clk);
|
||||||
cw_clock_start(&clk);
|
cw_clock_start(&clk);
|
||||||
|
|
||||||
mbag_item_t *eof = mbag_set_const_ptr(conn->outgoing, CW_ITEM_IMAGE_FILEHANDLE,
|
mbag_item_t *eof = mbag_set_const_ptr(conn->outgoing, CW_ITEM_IMAGE_FILEHANDLE,
|
||||||
infile);
|
infile);
|
||||||
|
|
||||||
int rc=0;
|
int rc = 0;
|
||||||
while (conn->capwap_state == CW_STATE_IMAGE_DATA && rc==0 && eof!=NULL) {
|
while (conn->capwap_state == CW_STATE_IMAGE_DATA && rc == 0 && eof != NULL) {
|
||||||
rc = cw_send_request(conn, CW_MSG_IMAGE_DATA_REQUEST);
|
rc = cw_send_request(conn, CW_MSG_IMAGE_DATA_REQUEST);
|
||||||
eof = mbag_get(conn->outgoing,CW_ITEM_IMAGE_FILEHANDLE);
|
eof = mbag_get(conn->outgoing, CW_ITEM_IMAGE_FILEHANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
cw_log(LOG_ERR,"Error sending image to %s: %s",sock_addr2str(&conn->addr),cw_strrc(rc));
|
cw_log(LOG_ERR, "Error sending image to %s: %s",
|
||||||
}
|
sock_addr2str(&conn->addr), cw_strrc(rc));
|
||||||
else {
|
} else {
|
||||||
cw_dbg(DBG_INFO,"Image '%s' sucessful sent to %s in %0.1f seconds.",
|
cw_dbg(DBG_INFO, "Image '%s' sucessful sent to %s in %0.1f seconds.",
|
||||||
filename,sock_addr2str(&conn->addr),cw_clock_stop(&clk));
|
filename, sock_addr2str(&conn->addr), cw_clock_stop(&clk));
|
||||||
conn->capwap_state=CW_STATE_NONE;
|
conn->capwap_state = CW_STATE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
wtpman_remove(wtpman);
|
wtpman_remove(wtpman);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -335,32 +333,31 @@ static void wtpman_image_data(struct wtpman *wtpman)
|
|||||||
void config_to_sql(struct conn *conn)
|
void config_to_sql(struct conn *conn)
|
||||||
{
|
{
|
||||||
// XXX for the moment we use just the IP adress as ID
|
// XXX for the moment we use just the IP adress as ID
|
||||||
char *wtp_id=sock_addr2str(&conn->addr);
|
char *wtp_id = sock_addr2str(&conn->addr);
|
||||||
|
|
||||||
MAVLITER_DEFINE(it,conn->incomming);
|
MAVLITER_DEFINE(it, conn->incomming);
|
||||||
mavliter_foreach(&it){
|
mavliter_foreach(&it) {
|
||||||
mbag_item_t * i = mavliter_get(&it);
|
mbag_item_t *i = mavliter_get(&it);
|
||||||
|
|
||||||
const struct cw_itemdef * cwi = cw_itemdef_get(conn->actions->items,i->id,NULL);
|
const struct cw_itemdef *cwi =
|
||||||
if (cwi){
|
cw_itemdef_get(conn->actions->items, i->id, NULL);
|
||||||
DBGX("ID %s,%s",i->id,cwi->id);
|
if (cwi) {
|
||||||
DBGX("Typei %s,Typecwd %s",i->type->name,cwi->type->name);
|
DBGX("ID %s,%s", i->id, cwi->id);
|
||||||
|
DBGX("Typei %s,Typecwd %s", i->type->name, cwi->type->name);
|
||||||
|
|
||||||
// printf("%s != %s ?\n",i->type->name,cwi->type->name);
|
// printf("%s != %s ?\n",i->type->name,cwi->type->name);
|
||||||
char str[256];
|
char str[256];
|
||||||
if (i->type->to_str){
|
if (i->type->to_str) {
|
||||||
i->type->to_str(i,str);
|
i->type->to_str(i, str);
|
||||||
db_put_wtp_prop(wtp_id,cwi->id,cwi->sub_id,str);
|
db_put_wtp_prop(wtp_id, cwi->id, cwi->sub_id, str);
|
||||||
}
|
} else {
|
||||||
else{
|
cw_log(LOG_ERR, "Can't converto to str");
|
||||||
cw_log(LOG_ERR,"Can't converto to str");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
// DBGX("ID %d",i->id);
|
||||||
// DBGX("ID %d",i->id);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,10 +431,10 @@ static void wtpman_run(void *arg)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
conn->capwap_state=CW_STATE_RUN;
|
conn->capwap_state = CW_STATE_RUN;
|
||||||
|
|
||||||
// XXX testing ...
|
// XXX testing ...
|
||||||
DBGX("Cofig to sql","");
|
DBGX("Cofig to sql", "");
|
||||||
config_to_sql(conn);
|
config_to_sql(conn);
|
||||||
|
|
||||||
|
|
||||||
@ -452,20 +449,20 @@ static void wtpman_run(void *arg)
|
|||||||
|
|
||||||
mavl_del_all(conn->outgoing);
|
mavl_del_all(conn->outgoing);
|
||||||
|
|
||||||
mavl_conststr_t r = db_get_update_tasks(conn,sock_addr2str(&conn->addr));
|
mavl_conststr_t r = db_get_update_tasks(conn, sock_addr2str(&conn->addr));
|
||||||
|
|
||||||
if ( !r )
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!conn->outgoing->count)
|
if (!conn->outgoing->count)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// DBGX("Have %d tasks",r->count);
|
// DBGX("Have %d tasks",r->count);
|
||||||
|
|
||||||
rc = cw_send_request(conn, CW_MSG_CONFIGURATION_UPDATE_REQUEST);
|
rc = cw_send_request(conn, CW_MSG_CONFIGURATION_UPDATE_REQUEST);
|
||||||
mavl_merge(conn->config,conn->outgoing);
|
mavl_merge(conn->config, conn->outgoing);
|
||||||
mavl_destroy(conn->outgoing);
|
mavl_destroy(conn->outgoing);
|
||||||
conn->outgoing=mbag_create();
|
conn->outgoing = mbag_create();
|
||||||
config_to_sql(conn);
|
config_to_sql(conn);
|
||||||
mavl_destroy(r);
|
mavl_destroy(r);
|
||||||
|
|
||||||
@ -500,22 +497,23 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr)
|
|||||||
|
|
||||||
|
|
||||||
int replyfd;
|
int replyfd;
|
||||||
if (srcaddr->sa_family == AF_INET && socklist[socklistindex].type!=SOCKLIST_UNICAST_SOCKET) {
|
if (srcaddr->sa_family == AF_INET
|
||||||
|
&& socklist[socklistindex].type != SOCKLIST_UNICAST_SOCKET) {
|
||||||
extern int socklist_find_reply_socket(struct sockaddr *sa);
|
extern int socklist_find_reply_socket(struct sockaddr *sa);
|
||||||
replyfd = socklist_find_reply_socket(srcaddr);
|
replyfd = socklist_find_reply_socket(srcaddr);
|
||||||
if (replyfd==-1){
|
if (replyfd == -1) {
|
||||||
cw_log(LOG_ERR,"Can't find reply socket for request from %s",sock_addr2str(srcaddr));
|
cw_log(LOG_ERR, "Can't find reply socket for request from %s",
|
||||||
|
sock_addr2str(srcaddr));
|
||||||
free(wtpman);
|
free(wtpman);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
replyfd = socklist[socklistindex].sockfd;
|
replyfd = socklist[socklistindex].sockfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int sockfd = replyfd; //socklist[socklistindex].reply_sockfd;
|
int sockfd = replyfd; //socklist[socklistindex].reply_sockfd;
|
||||||
|
|
||||||
wtpman->conn = conn_create(sockfd, srcaddr, 100);
|
wtpman->conn = conn_create(sockfd, srcaddr, 100);
|
||||||
if (!wtpman->conn) {
|
if (!wtpman->conn) {
|
||||||
@ -525,10 +523,10 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr)
|
|||||||
|
|
||||||
wtpman->conn->strict_capwap = conf_strict_capwap;
|
wtpman->conn->strict_capwap = conf_strict_capwap;
|
||||||
wtpman->conn->strict_hdr = conf_strict_headers;
|
wtpman->conn->strict_hdr = conf_strict_headers;
|
||||||
wtpman->conn->radios=mbag_i_create();
|
wtpman->conn->radios = mbag_i_create();
|
||||||
wtpman->conn->local = ac_config;
|
wtpman->conn->local = ac_config;
|
||||||
//wtpman->conn->capwap_mode=0; //CW_MODE_STD; //CISCO;
|
//wtpman->conn->capwap_mode=0; //CW_MODE_STD; //CISCO;
|
||||||
wtpman->conn->capwap_mode=CW_MODE_CISCO;
|
wtpman->conn->capwap_mode = CW_MODE_CISCO;
|
||||||
//wtpman->conn->strict_capwap_hdr=0;
|
//wtpman->conn->strict_capwap_hdr=0;
|
||||||
|
|
||||||
return wtpman;
|
return wtpman;
|
||||||
@ -581,9 +579,9 @@ void wtpman_lw_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// char wi[4096];
|
// char wi[4096];
|
||||||
// wtpinfo_print(wi, &wtpman->wtpinfo);
|
// wtpinfo_print(wi, &wtpman->wtpinfo);
|
||||||
// printf("WTPINFO: \n%s\n", wi);
|
// printf("WTPINFO: \n%s\n", wi);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,13 +30,6 @@
|
|||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
|
|
||||||
#include <stdio.h> //tube
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
|
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
|
||||||
|
|
||||||
@ -114,7 +107,7 @@ int cw_send_response(struct conn *conn, uint8_t * rawmsg, int len)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Special case error message, which is sent when an unexpected messages
|
* Special case error message, which is sent when an unexpected messages
|
||||||
* was received or somethin else happened.
|
* was received or something else happened.
|
||||||
* @param conn conection
|
* @param conn conection
|
||||||
* @param rawmsg the received request message, which the response belongs to
|
* @param rawmsg the received request message, which the response belongs to
|
||||||
* @pqram result_code result code to send
|
* @pqram result_code result code to send
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
indent -l90 -kr -ts8 -i8 -cli8 -cbi0 $1
|
gindent -l90 -kr -ts8 -i8 -cli8 -cbi0 $1
|
||||||
|
Loading…
Reference in New Issue
Block a user