Renamed cw_str to cw_strlist_elem.

FossilOrigin-Name: eb87e178a02fd3daebd4d168489a4e5c99be67602caa8ea50d5b6702a4d13005
This commit is contained in:
7u83@mail.ru 2015-10-18 07:49:14 +00:00
parent 2704f537e4
commit 0b39c92a79
20 changed files with 50 additions and 41 deletions

View File

@ -28,4 +28,3 @@ uint8_t * bstr16_create_from_str(const char *s)
return mem; return mem;
} }

View File

@ -942,12 +942,12 @@ static inline int cw_addelem_result_code(uint8_t * dst, uint32_t code)
/* Message to text stuff */ /* Message to text stuff */
/* Constants to string conversion lists */ /* Constants to string conversion lists */
extern struct cw_str capwap_strings_msg[]; extern struct cw_strlist_elem capwap_strings_msg[];
extern struct cw_str capwap_strings_state[]; extern struct cw_strlist_elem capwap_strings_state[];
extern struct cw_str capwap_strings_vendor[]; extern struct cw_strlist_elem capwap_strings_vendor[];
extern struct cw_str capwap_strings_elem[]; extern struct cw_strlist_elem capwap_strings_elem[];
extern struct cw_str capwap_strings_result[]; extern struct cw_strlist_elem capwap_strings_result[];
extern struct cw_str mbag_item_strings[]; extern struct cw_strlist_elem mbag_item_strings[];

View File

@ -90,7 +90,7 @@ int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst
extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def); extern int cw_register_actions_capwap_80211_wtp(struct cw_actiondef *def);
extern struct cw_str capwap_strings_elem80211[]; extern struct cw_strlist_elem capwap_strings_elem80211[];
extern int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def); extern int cw_register_actions_capwap_80211_ac(struct cw_actiondef *def);

View File

@ -1,6 +1,6 @@
#include "capwap.h" #include "capwap.h"
struct cw_str capwap_strings_elem[] = { struct cw_strlist_elem capwap_strings_elem[] = {
{CW_ELEM_AC_DESCRIPTOR, "AC Descriptor"}, {CW_ELEM_AC_DESCRIPTOR, "AC Descriptor"},
{CW_ELEM_AC_IPV4_LIST, "AC IPv4 List"}, {CW_ELEM_AC_IPV4_LIST, "AC IPv4 List"},

View File

@ -1,7 +1,7 @@
#include "capwap_80211.h" #include "capwap_80211.h"
struct cw_str capwap_strings_elem80211[] = { struct cw_strlist_elem capwap_strings_elem80211[] = {
{CW_ELEM80211_ADD_WLAN, "802.11 Add WLAN"}, {CW_ELEM80211_ADD_WLAN, "802.11 Add WLAN"},
{CW_ELEM80211_ANTENNA, "802.11 Antenna"}, {CW_ELEM80211_ANTENNA, "802.11 Antenna"},

View File

@ -25,7 +25,7 @@
/** /**
* CAPWAP Message Strings * CAPWAP Message Strings
*/ */
struct cw_str capwap_strings_msg[] = { struct cw_strlist_elem capwap_strings_msg[] = {
{ CW_MSG_DISCOVERY_REQUEST, "Discovery Request" }, { CW_MSG_DISCOVERY_REQUEST, "Discovery Request" },
{ CW_MSG_DISCOVERY_RESPONSE,"Discovery Response" }, { CW_MSG_DISCOVERY_RESPONSE,"Discovery Response" },
{ CW_MSG_JOIN_REQUEST, "Join Request"}, { CW_MSG_JOIN_REQUEST, "Join Request"},

View File

@ -1,7 +1,7 @@
#include "capwap.h" #include "capwap.h"
struct cw_str capwap_strings_result[] = { struct cw_strlist_elem capwap_strings_result[] = {
{CW_RESULT_SUCCESS,"Success"}, /* 0 */ {CW_RESULT_SUCCESS,"Success"}, /* 0 */
{CW_RESULT_MISSING_AC_LIST,"AC List Message Element MUST be Present"}, /* 1 */ {CW_RESULT_MISSING_AC_LIST,"AC List Message Element MUST be Present"}, /* 1 */

View File

@ -1,6 +1,6 @@
#include "capwap.h" #include "capwap.h"
struct cw_str capwap_strings_state[] = { struct cw_strlist_elem capwap_strings_state[] = {
{ CW_STATE_DISCOVERY, "Discovery" }, { CW_STATE_DISCOVERY, "Discovery" },
{ CW_STATE_JOIN,"Join" }, { CW_STATE_JOIN,"Join" },
{ CW_STATE_RUN,"Run" }, { CW_STATE_RUN,"Run" },

View File

@ -1,7 +1,7 @@
#include "capwap.h" #include "capwap.h"
struct cw_str capwap_strings_vendor[] = { struct cw_strlist_elem capwap_strings_vendor[] = {
{ CW_VENDOR_ID_CISCO, "Cisco" }, { CW_VENDOR_ID_CISCO, "Cisco" },
{ CW_VENDOR_ID_ZYXEL, "Zyxel" }, { CW_VENDOR_ID_ZYXEL, "Zyxel" },
{ CW_VENDOR_ID_FSF, "FSF"}, { CW_VENDOR_ID_FSF, "FSF"},

View File

@ -5,7 +5,7 @@
#include "strheap.h" #include "strheap.h"
#include "action.h" #include "action.h"
extern struct cw_str cipwap_strings_elem[]; extern struct cw_strlist_elem cipwap_strings_elem[];
extern int cw_register_actions_cipwap_wtp(struct cw_actiondef *def); extern int cw_register_actions_cipwap_wtp(struct cw_actiondef *def);

View File

@ -4,7 +4,7 @@
#include "capwap_cisco.h" #include "capwap_cisco.h"
struct cw_str cipwap_strings_elem[] = { struct cw_strlist_elem cipwap_strings_elem[] = {
{CW_ELEM_WTP_IPV4_IP_ADDRESS, "WTP IPv4 IP Address"}, {CW_ELEM_WTP_IPV4_IP_ADDRESS, "WTP IPv4 IP Address"},
{CW_ELEM_WTP_IPV6_IP_ADDRESS, "WTP IPv6 IP Address"}, {CW_ELEM_WTP_IPV6_IP_ADDRESS, "WTP IPv6 IP Address"},

View File

@ -12,10 +12,6 @@ void cw_init(struct conn * conn, uint8_t *buffer, int type, int seqnum, struct r
void cw_init_response(struct conn * conn, uint8_t *req) void cw_init_response(struct conn * conn, uint8_t *req)
{ {
uint8_t *buffer=conn->resp_buffer; uint8_t *buffer=conn->resp_buffer;

View File

@ -2,7 +2,7 @@
#include "strlist.h" #include "strlist.h"
int cw_strlist_get_id(struct cw_str *s,const char *str) int cw_strlist_get_id(struct cw_strlist_elem *s,const char *str)
{ {
while ( s->id!=CW_STR_STOP){ while ( s->id!=CW_STR_STOP){
if (strcmp(s->str,str)==0) if (strcmp(s->str,str)==0)

View File

@ -1,7 +1,7 @@
#include "strlist.h" #include "strlist.h"
const char * cw_strlist_get_str(struct cw_str *s,int id) const char * cw_strlist_get_str(struct cw_strlist_elem *s,int id)
{ {
while ( s->id!=CW_STR_STOP){ while ( s->id!=CW_STR_STOP){
if (s->id==id) if (s->id==id)

View File

@ -71,7 +71,7 @@ uint32_t cw_dbg_opt_level = 0;
#define DBG_CLR_CYAN "\x1b[36m" #define DBG_CLR_CYAN "\x1b[36m"
static struct cw_str color_on[] = { static struct cw_strlist_elem color_on[] = {
{ DBG_PKT_IN, DBG_CLR_YELLO }, { DBG_PKT_IN, DBG_CLR_YELLO },
{ DBG_PKT_OUT, DBG_CLR_YELLO_I }, { DBG_PKT_OUT, DBG_CLR_YELLO_I },
@ -90,19 +90,19 @@ static struct cw_str color_on[] = {
{ DBG_WARN, DBG_CLR_CYAN }, { DBG_WARN, DBG_CLR_CYAN },
{ CW_STR_STOP, "" } { CW_STR_STOP, "" }
}; };
static struct cw_str color_ontext[] = { static struct cw_strlist_elem color_ontext[] = {
{ DBG_ELEM_DMP, "\x1b[30m"}, { DBG_ELEM_DMP, "\x1b[30m"},
{ CW_STR_STOP, "" } { CW_STR_STOP, "" }
}; };
static struct cw_str color_off[] = { static struct cw_strlist_elem color_off[] = {
{ CW_STR_STOP, "\x1b[22;39m\x1b[23m" } { CW_STR_STOP, "\x1b[22;39m\x1b[23m" }
}; };
static struct cw_str prefix[] = { static struct cw_strlist_elem prefix[] = {
{ DBG_INFO, " Info -" }, { DBG_INFO, " Info -" },
{ DBG_PKT_IN, " Pkt IN -" }, { DBG_PKT_IN, " Pkt IN -" },
{ DBG_PKT_OUT, " Pkt Out -" }, { DBG_PKT_OUT, " Pkt Out -" },

View File

@ -64,7 +64,7 @@ void cw_dbg_packet(struct conn *conn, uint8_t * packet, int len);
#endif #endif
/** /**
* @defgroup DebugOptions Debug Options * @defgroup DbgOptions Debug Options
* @{ * @{
*/ */
@ -157,7 +157,7 @@ enum cw_dbg_levels{
extern uint32_t cw_dbg_opt_display; extern uint32_t cw_dbg_opt_display;
extern uint32_t cw_dbg_opt_level; extern uint32_t cw_dbg_opt_level;
extern struct cw_str cw_dbg_strings[]; extern struct cw_strlist_elem cw_dbg_strings[];

View File

@ -16,13 +16,24 @@
*/ */
/**
*@file
*@brief
*/
#include <string.h> //#include <string.h>
#include "dbg.h" #include "dbg.h"
/**
*@addtogroup DbgOptions
*@{
*/
struct cw_str cw_dbg_strings[] = { /**
* Debug strings
*/
struct cw_strlist_elem cw_dbg_strings[] = {
{ DBG_INFO, "info" }, { DBG_INFO, "info" },
{ DBG_PKT_IN, "pkt_in" }, { DBG_PKT_IN, "pkt_in" },
{ DBG_PKT_OUT, "pkt_out" }, { DBG_PKT_OUT, "pkt_out" },
@ -45,6 +56,9 @@ struct cw_str cw_dbg_strings[] = {
{ CW_STR_STOP, NULL } { CW_STR_STOP, NULL }
}; };
/**
*@}
*/

View File

@ -4,7 +4,7 @@
static int cmp(const void *v1,const void*v2) static int cmp(const void *v1,const void*v2)
{ {
return ((struct cw_str *)v1)->id - ((struct cw_str *)v2)->id; return ((struct cw_strlist_elem *)v1)->id - ((struct cw_strlist_elem *)v2)->id;
} }
static void del(void* d) static void del(void* d)
@ -17,13 +17,13 @@ cw_strheap_t cw_strheap_create()
return mavl_create(cmp,del); return mavl_create(cmp,del);
} }
const char * cw_strheap_add(cw_strheap_t t, struct cw_str *s) const char * cw_strheap_add(cw_strheap_t t, struct cw_strlist_elem *s)
{ {
mavl_del(t,s); mavl_del(t,s);
return mavl_add(t,s); return mavl_add(t,s);
} }
int cw_strheap_register_strings(cw_strheap_t h, struct cw_str *s) int cw_strheap_register_strings(cw_strheap_t h, struct cw_strlist_elem *s)
{ {
int n=0; int n=0;
while ( s->id!=CW_STR_STOP){ while ( s->id!=CW_STR_STOP){

View File

@ -11,12 +11,12 @@ typedef struct avltree * cw_strheap_t;
extern cw_strheap_t cw_strheap_create(); extern cw_strheap_t cw_strheap_create();
extern int cw_strheap_register_strings(cw_strheap_t h, struct cw_str *s); extern int cw_strheap_register_strings(cw_strheap_t h, struct cw_strlist_elem *s);
static inline const char * cw_strheap_get(cw_strheap_t h, int id) { static inline const char * cw_strheap_get(cw_strheap_t h, int id) {
struct cw_str s; struct cw_strlist_elem s;
s.id=id; s.id=id;
struct cw_str *r = avltree_get(h,&s); struct cw_strlist_elem *r = avltree_get(h,&s);
if (r) if (r)
return r->str; return r->str;
return NULL; return NULL;

View File

@ -7,14 +7,14 @@
*/ */
#include "stdio.h"
/** /**
*Key/String pair, used for string tables, *Key/String pair, used for string tables,
*to display message element names and so on... *to display message element names and so on...
*/ */
struct cw_str { struct cw_strlist_elem {
/** ID, an integer value */
int id; int id;
/** a pointer to the string */
const char *str; const char *str;
}; };
@ -22,8 +22,8 @@ struct cw_str {
#define CW_STR_STOP 0xffffffff #define CW_STR_STOP 0xffffffff
extern const char *cw_strlist_get_str(struct cw_str *s, int id); extern const char *cw_strlist_get_str(struct cw_strlist_elem *s, int id);
extern int cw_strlist_get_id(struct cw_str *s, const char *str); extern int cw_strlist_get_id(struct cw_strlist_elem *s, const char *str);
#endif #endif