Fixed issues with result codes

FossilOrigin-Name: d2b3ffce2340674f747a8a3086dd0ce1b9594c320965078ae88f634753e0859a
This commit is contained in:
7u83@mail.ru 2016-03-13 17:38:51 +00:00
parent ef2ddd635a
commit f884609be8
1 changed files with 20 additions and 16 deletions

View File

@ -155,7 +155,7 @@ static int check_len(struct conn *conn, struct cw_action_in *a, uint8_t * data,
return 1; return 1;
} }
static struct mod_ac * detect_mod(struct conn *conn, uint8_t * rawmsg, int len, static struct mod_ac *detect_mod(struct conn *conn, uint8_t * rawmsg, int len,
int elems_len, struct sockaddr *from, int mode) int elems_len, struct sockaddr *from, int mode)
{ {
if (conn->mods) { if (conn->mods) {
@ -163,8 +163,8 @@ static struct mod_ac * detect_mod(struct conn *conn, uint8_t * rawmsg, int len,
int i; int i;
for (i = 0; mods[i]; i++) { for (i = 0; mods[i]; i++) {
if (mods[i]->detect) { if (mods[i]->detect) {
if (mods[i]-> if (mods[i]->detect
detect(conn, rawmsg, len, elems_len, from, mode)) { (conn, rawmsg, len, elems_len, from, mode)) {
return mods[i]; return mods[i];
} }
@ -175,22 +175,25 @@ static struct mod_ac * detect_mod(struct conn *conn, uint8_t * rawmsg, int len,
return MOD_NULL; return MOD_NULL;
} }
static struct cw_actiondef * load_mods(struct conn *conn, uint8_t * rawmsg, int len, static struct cw_actiondef *load_mods(struct conn *conn, uint8_t * rawmsg, int len,
int elems_len, struct sockaddr *from) int elems_len, struct sockaddr *from)
{ {
struct mod_ac * cmod = detect_mod(conn, rawmsg, len, elems_len, from, MOD_MODE_CAPWAP); struct mod_ac *cmod =
detect_mod(conn, rawmsg, len, elems_len, from, MOD_MODE_CAPWAP);
if (cmod == MOD_NULL) { if (cmod == MOD_NULL) {
cw_dbg(DBG_MSG_ERR, "Cant't find mod to handle connection from %s , discarding message", cw_dbg(DBG_MSG_ERR,
"Cant't find mod to handle connection from %s , discarding message",
sock_addr2str_p(from)); sock_addr2str_p(from));
return NULL; return NULL;
} }
struct mod_ac * bmod = detect_mod(conn, rawmsg, len, elems_len, from, MOD_MODE_BINDINGS); struct mod_ac *bmod =
detect_mod(conn, rawmsg, len, elems_len, from, MOD_MODE_BINDINGS);
cw_dbg(DBG_INFO,"Mods deteced: %s,%s",cmod->name,bmod->name); cw_dbg(DBG_INFO, "Mods deteced: %s,%s", cmod->name, bmod->name);
struct cw_actiondef * ad = mod_cache_add(cmod,bmod); struct cw_actiondef *ad = mod_cache_add(cmod, bmod);
return ad; return ad;
@ -274,14 +277,14 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
if (!conn->detected) { if (!conn->detected) {
//struct mod_ac *mod; //struct mod_ac *mod;
struct cw_actiondef * ad = load_mods(conn, rawmsg, len, elems_len, from); struct cw_actiondef *ad = load_mods(conn, rawmsg, len, elems_len, from);
if (!ad) { if (!ad) {
cw_log(LOG_ERR,"Eror"); cw_log(LOG_ERR, "Eror");
errno=EAGAIN; errno = EAGAIN;
return -1; return -1;
} }
conn->actions = ad; conn->actions = ad;
conn->detected =1; conn->detected = 1;
} }
@ -395,11 +398,12 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
} }
if (unrecognized) { if (unrecognized) {
cw_dbg(DBG_RFC, "Message has %d unrecognized message elements.", cw_dbg(DBG_RFC, "Message has %d unrecognized message elements.",
unrecognized); unrecognized);
if (!result_code) { /* set only resultcode for request messages */
if ( (!result_code) && ((afm->msg_id & 1))) {
result_code = CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT; result_code = CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
} }