Improved mod detection, also for bindings. detections are cached.
FossilOrigin-Name: bb2a4cd9c18aded4fa028aa8d385c811d7550a37ddaf3da17f90399315abf637
This commit is contained in:
@ -19,39 +19,42 @@ extern int cisco_register_actions_ac(struct cw_actiondef *def);
|
||||
|
||||
static int init()
|
||||
{
|
||||
cw_dbg(DBG_INFO,"Initialiazing mod_cisco ...");
|
||||
struct mod_ac * cmod = modload_ac("capwap");
|
||||
cw_dbg(DBG_INFO, "Initialiazing mod_cisco ...");
|
||||
struct mod_ac *cmod = modload_ac("capwap");
|
||||
cmod->register_actions(&actions);
|
||||
if (!cmod ){
|
||||
cw_log(LOG_ERR,"Can't initzialize mod_cisco, failed to load bas mod mod_capwap");
|
||||
if (!cmod) {
|
||||
cw_log(LOG_ERR,
|
||||
"Can't initzialize mod_cisco, failed to load base mod mod_capwap");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rc = cisco_register_actions_ac(&actions);
|
||||
cw_dbg(DBG_INFO,"Initialized mod cisco with %d actions",rc);
|
||||
cw_dbg(DBG_INFO, "Initialized mod cisco with %d actions", rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,int elems_len,struct sockaddr *from)
|
||||
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
|
||||
struct sockaddr *from, int mode)
|
||||
{
|
||||
if (mode != MOD_DETECT_CAPWAP)
|
||||
return 0;
|
||||
|
||||
int offset = cw_get_hdr_msg_offset(rawmsg);
|
||||
const uint8_t *msg_ptr = rawmsg + offset;
|
||||
|
||||
const uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
||||
const uint8_t *elem;
|
||||
|
||||
|
||||
|
||||
/* To detect a Cisco AP we look for any vendor
|
||||
* specific payload Cisco identifier */
|
||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
||||
int id = cw_get_elem_id(elem);
|
||||
if (id==CW_ELEM_VENDOR_SPECIFIC_PAYLOAD){
|
||||
if (id == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
||||
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
||||
if (vendor_id==CW_VENDOR_ID_CISCO){
|
||||
conn->detected=1;
|
||||
conn->actions=&actions;
|
||||
if (vendor_id == CW_VENDOR_ID_CISCO) {
|
||||
conn->actions = &actions;
|
||||
return 1;
|
||||
|
||||
}
|
||||
@ -64,13 +67,13 @@ static int detect(struct conn *conn,const uint8_t *rawmsg, int rawlen,int elems_
|
||||
}
|
||||
|
||||
static struct mod_ac capwap_ac = {
|
||||
.name ="cisco",
|
||||
.name = "cisco",
|
||||
.init = init,
|
||||
.detect = detect
|
||||
|
||||
.detect = detect,
|
||||
.register_actions = cisco_register_actions_ac
|
||||
};
|
||||
|
||||
struct mod_ac * mod_cisco_ac(){
|
||||
struct mod_ac *mod_cisco_ac()
|
||||
{
|
||||
return &capwap_ac;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user