client: Restructure {srvc,bankd}_read_cb()
Introduce some switch statements to make code more extensable. Change-Id: I9d1a6c29cbfc2f01995a2093978fae8577f1771f
This commit is contained in:
parent
15b75e1e5c
commit
1a17104639
|
@ -49,18 +49,23 @@ int bankd_read_cb(struct ipa_client_conn *conn, struct msgb *msg)
|
||||||
if (msgb_length(msg) < sizeof(*hh))
|
if (msgb_length(msg) < sizeof(*hh))
|
||||||
goto invalid;
|
goto invalid;
|
||||||
msg->l2h = &hh->data[0];
|
msg->l2h = &hh->data[0];
|
||||||
if (hh->proto != IPAC_PROTO_OSMO)
|
switch (hh->proto) {
|
||||||
|
case IPAC_PROTO_OSMO:
|
||||||
|
if (!he || msgb_l2len(msg) < sizeof(*he))
|
||||||
|
goto invalid;
|
||||||
|
msg->l2h = &he->data[0];
|
||||||
|
switch (he->proto) {
|
||||||
|
case IPAC_PROTO_EXT_RSPRO:
|
||||||
|
printf("Received RSPRO %s\n", msgb_hexdump(msg));
|
||||||
|
rc = bankd_handle_msg(bc, msg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
goto invalid;
|
goto invalid;
|
||||||
if (!he || msgb_l2len(msg) < sizeof(*he))
|
}
|
||||||
goto invalid;
|
|
||||||
msg->l2h = &he->data[0];
|
|
||||||
|
|
||||||
if (he->proto != IPAC_PROTO_EXT_RSPRO)
|
|
||||||
goto invalid;
|
|
||||||
|
|
||||||
printf("Received RSPRO %s\n", msgb_hexdump(msg));
|
|
||||||
|
|
||||||
rc = bankd_handle_msg(bc, msg);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
|
|
@ -281,21 +281,28 @@ static int srvc_read_cb(struct ipa_client_conn *conn, struct msgb *msg)
|
||||||
if (msgb_length(msg) < sizeof(*hh))
|
if (msgb_length(msg) < sizeof(*hh))
|
||||||
goto invalid;
|
goto invalid;
|
||||||
msg->l2h = &hh->data[0];
|
msg->l2h = &hh->data[0];
|
||||||
if (hh->proto != IPAC_PROTO_OSMO)
|
switch (hh->proto) {
|
||||||
|
case IPAC_PROTO_OSMO:
|
||||||
|
if (!he || msgb_l2len(msg) < sizeof(*he))
|
||||||
|
goto invalid;
|
||||||
|
msg->l2h = &he->data[0];
|
||||||
|
switch (he->proto) {
|
||||||
|
case IPAC_PROTO_EXT_RSPRO:
|
||||||
|
printf("Received RSPRO %s\n", msgb_hexdump(msg));
|
||||||
|
pdu = rspro_dec_msg(msg);
|
||||||
|
if (!pdu)
|
||||||
|
goto invalid;
|
||||||
|
rc = srvc->handle_rx(srvc, pdu);
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_RsproPDU, pdu);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
goto invalid;
|
goto invalid;
|
||||||
if (!he || msgb_l2len(msg) < sizeof(*he))
|
}
|
||||||
goto invalid;
|
|
||||||
msg->l2h = &he->data[0];
|
|
||||||
|
|
||||||
if (he->proto != IPAC_PROTO_EXT_RSPRO)
|
|
||||||
goto invalid;
|
|
||||||
|
|
||||||
printf("Received RSPRO %s\n", msgb_hexdump(msg));
|
|
||||||
pdu = rspro_dec_msg(msg);
|
|
||||||
if (!pdu)
|
|
||||||
goto invalid;
|
|
||||||
|
|
||||||
rc = srvc->handle_rx(srvc, pdu);
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
invalid:
|
invalid:
|
||||||
|
|
Loading…
Reference in New Issue