dect
/
libdect
Archived
13
0
Fork 0

sfmt: treat empty IEs as absent

Empty mandatory IEs may be coded as empty attributes, treat them as absent
without failing policy checks.

Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
Patrick McHardy 2010-05-27 19:18:59 +02:00
parent 29b6ed4903
commit 80a2fb4435
5 changed files with 26 additions and 12 deletions

View File

@ -123,6 +123,7 @@ static void mm_authenticate_cfm(struct dect_handle *dh,
} else {
debug("authentication failure\n");
err:
mm_locate_res(dh, mme);
dect_ie_collection_put(dh, priv->locate);
}
}

View File

@ -316,9 +316,10 @@ enum dect_sfmt_variable_length_ies {
/* Call information IE */
enum dect_sfmt_ie_status {
DECT_SFMT_IE_NONE,
DECT_SFMT_IE_OPTIONAL,
DECT_SFMT_IE_MANDATORY
DECT_SFMT_IE_NONE = 0,
/* -1 indicates generic errors */
DECT_SFMT_IE_OPTIONAL = -2,
DECT_SFMT_IE_MANDATORY = -3,
};
enum dect_sfmt_ie_flags {

View File

@ -481,13 +481,16 @@ int dect_lce_send(const struct dect_handle *dh,
{
struct dect_data_link *ddl = ta->link;
struct dect_msg_buf *mb;
int err;
mb = dect_mbuf_alloc(dh);
if (mb == NULL)
return -1;
dect_mbuf_reserve(mb, DECT_S_HDR_SIZE);
dect_build_sfmt_msg(dh, desc, msg, mb);
err = dect_build_sfmt_msg(dh, desc, msg, mb);
if (err < 0)
return err;
if (ddl->sdu_timer && dect_timer_running(ddl->sdu_timer))
dect_ddl_stop_sdu_timer(dh, ddl);

View File

@ -1868,7 +1868,7 @@ int dect_mm_locate_res(struct dect_handle *dh, struct dect_mm_endpoint *mme,
* TPUI or NWK identity assignment begins an identity assignment
* procedure.
*/
if (accept &&
if (accept && param->portable_identity &&
(param->portable_identity->type == DECT_PORTABLE_ID_TYPE_TPUI ||
param->nwk_assigned_identity)) {
mp->type = DECT_MMP_TEMPORARY_IDENTITY_ASSIGNMENT;

View File

@ -2245,10 +2245,6 @@ enum dect_sfmt_error dect_parse_sfmt_msg(const struct dect_handle *dh,
if (dect_parse_sfmt_ie_header(ie, mb) < 0)
return -1;
/* Treat empty variable length IEs as absent */
if (!(ie->id & DECT_SFMT_IE_FIXED_LEN) && ie->len == 2)
goto next;
/* Locate a matching member in the description and apply
* policy checks. */
while (1) {
@ -2281,6 +2277,13 @@ enum dect_sfmt_error dect_parse_sfmt_msg(const struct dect_handle *dh,
dect_msg_ie_init(desc, dst);
}
found:
/* Treat empty variable length IEs as absent */
if (!(ie->id & DECT_SFMT_IE_FIXED_LEN) && ie->len == 2) {
dect_debug(" IE: <%s> id: %x len: %u (empty)\n",
dect_ie_handlers[ie->id].name, ie->id, ie->len);
goto next;
}
/* Ignore corrupt optional IEs */
if (dect_parse_sfmt_ie(dh, desc, dst, ie) < 0 &&
dect_rx_status(dh, desc) == DECT_SFMT_IE_MANDATORY)
@ -2388,12 +2391,13 @@ enum dect_sfmt_error dect_build_sfmt_msg(const struct dect_handle *dh,
if (err != DECT_SFMT_OK)
return err;
}
} else {
if (*src == NULL)
goto next;
} else if (*src != NULL) {
err = dect_build_sfmt_ie(dh, desc, mb, *src);
if (err != DECT_SFMT_OK)
return err;
} else {
if (dect_tx_status(dh, desc) == DECT_SFMT_IE_MANDATORY)
goto err_mandatory;
}
next:
src = next;
@ -2401,6 +2405,11 @@ next:
}
return DECT_SFMT_OK;
err_mandatory:
dect_debug(" IE <%s> id: %x missing\n",
dect_ie_handlers[desc->type].name, desc->type);
return DECT_SFMT_MANDATORY_IE_MISSING;
}
void dect_msg_free(const struct dect_handle *dh,