From 7d1ef1ff014907f6a2663131ea2c0326e1dc4660 Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Fri, 4 May 2018 11:37:53 +0000 Subject: [PATCH] Init state machine FossilOrigin-Name: 05b6545a5e1640a5f904ba9c07dd2734df2dfd9ade87d4cfcaaee24bfdc6a638 --- src/ac/shell.c | 55 ++++++++++++++++++++++++++++++++++++++++++++--- src/ac/wtplist.c | 6 +++++- src/ac/wtplist.h | 2 +- src/wtp/cisco.ktv | 4 ++-- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/ac/shell.c b/src/ac/shell.c index c0b1668b..813710c1 100644 --- a/src/ac/shell.c +++ b/src/ac/shell.c @@ -11,13 +11,62 @@ #include "cw/dbg.h" -void execute_cmd(const char *str) +#include "cw/connlist.h" + + +#include "wtplist.h" + +void show_aps(FILE *out){ + struct connlist * cl; + mavliter_t it; + + + + wtplist_lock(); + + cl = wtplist_get_connlist(); + + + mavliter_init(&it,cl->by_addr); + fprintf(out,"IP\t\t\twtp-name\n"); + mavliter_foreach(&it){ + cw_KTV_t * result; + char addr[SOCK_ADDR_BUFSIZE]; + char wtp_name[CAPWAP_MAX_WTP_NAME_LEN]; + struct conn * conn; + conn = mavliter_get_ptr(&it); + + sock_addr2str_p(&conn->addr,addr); + + result = cw_ktv_get(conn->remote_cfg,"wtp-name",NULL); + if (result==NULL){ + strcpy(wtp_name,""); + } + else{ + result->type->to_str(result,wtp_name,CAPWAP_MAX_WTP_NAME_LEN); + } + + + fprintf(out,"%s\t\t%s\n",addr,wtp_name); + + + } + + + wtplist_unlock(); + +} + + +void execute_cmd(FILE * out, const char *str) { char cmd[1024]; char args[1024]; sscanf(str,"%s%s",cmd,args); - printf("CMD: %s, ARGS: %s\n",cmd,args); + printf("CMD: %s, ARGS:\n",cmd); + + show_aps(out); @@ -39,7 +88,7 @@ void shell_loop(FILE *file) fflush(file); fgets(str,sizeof(str),file); - execute_cmd(str); + execute_cmd(file,str); }while (c!=EOF); diff --git a/src/ac/wtplist.c b/src/ac/wtplist.c index a4c46142..2481bcb4 100644 --- a/src/ac/wtplist.c +++ b/src/ac/wtplist.c @@ -103,6 +103,10 @@ void wtplist_remove(struct wtpman * wtpman) return; } - + +struct connlist * wtplist_get_connlist(void) +{ + return connlist; +} diff --git a/src/ac/wtplist.h b/src/ac/wtplist.h index a001f5a4..c5373a1c 100644 --- a/src/ac/wtplist.h +++ b/src/ac/wtplist.h @@ -14,6 +14,6 @@ extern void wtplist_remove(struct wtpman * wtpman); extern void wtplist_lock(); extern void wtplist_unlock(); extern struct wtpman * wtplist_get_by_session_id(uint8_t *session_id); - +struct connlist * wtplist_get_connlist(void); #endif diff --git a/src/wtp/cisco.ktv b/src/wtp/cisco.ktv index 71ad7708..c174138f 100644 --- a/src/wtp/cisco.ktv +++ b/src/wtp/cisco.ktv @@ -19,7 +19,7 @@ ac-name-with-priority/ac2 :Byte: 5 capwap-control-ip-address/address.0 :IPAddress: 192.168.0.175 capwap-control-ip-address/address.1 :IPAddress: 192.168.0.175 capwap-control-ip-address/address.2 :IPAddress: 192.168.0.173 -capwap-control-ip-address/wtps.0 :Word: 0 +capwap-control-ip-address/wtps.0 :Word: 1 capwap-control-ip-address/wtps.1 :Word: 1 capwap-control-ip-address/wtps.2 :Word: 1 capwap-local-ip-address :IPAddress: 192.168.56.1 @@ -61,7 +61,7 @@ cisco/ap-regulatory-domain.1/slot :Byte: 1 cisco/ap-sub-mode :Byte: 0 cisco/ap-telnet-ssh/ssh :Bool: false cisco/ap-telnet-ssh/telnet :Bool: false -cisco/ap-timesync/timestamp :Dword: 1525248241 +cisco/ap-timesync/timestamp :Dword: 1525354079 cisco/ap-timesync/type :Byte: 0 cisco/ap-username-and-password/802.1x-credentials/option :Word: 2 cisco/ap-username-and-password/802.1x-credentials/password :Str: