aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2016-03-03 13:26:44 -0600
committerDan Williams <dcbw@redhat.com>2016-03-03 13:26:44 -0600
commit3465107153e373adfd4e50ac90259ed25d556bed (patch)
tree2bb7755187f3136555d401d16ded37dc415736ab /utils
parentfea234dd1ea6f8d558b32d93e127a5bd73e5ae04 (diff)
trivial: whitespace fixes
Diffstat (limited to 'utils')
-rw-r--r--utils/qmitest.c576
1 files changed, 288 insertions, 288 deletions
diff --git a/utils/qmitest.c b/utils/qmitest.c
index 7df896e..5d20a54 100644
--- a/utils/qmitest.c
+++ b/utils/qmitest.c
@@ -77,33 +77,33 @@ print_buf (const char *detail, const char *buf, size_t len)
/**************************************************************/
typedef enum {
- QMI_SVC_CTL = 0x00,
- QMI_SVC_WDS = 0x01,
- QMI_SVC_DMS = 0x02,
- QMI_SVC_NAS = 0x03,
- QMI_SVC_QOS = 0x04,
- QMI_SVC_WMS = 0x05,
- QMI_SVC_PDS = 0x06,
- QMI_SVC_AUTH = 0x07,
- QMI_SVC_AT = 0x08,
- QMI_SVC_VOICE = 0x09,
- QMI_SVC_CAT2 = 0x0A,
- QMI_SVC_UIM = 0x0B,
- QMI_SVC_PBM = 0x0C,
- QMI_SVC_LOC = 0x10,
- QMI_SVC_SAR = 0x11,
- QMI_SVC_RMTFS = 0x14,
- QMI_SVC_CAT = 0xE0,
- QMI_SVC_RMS = 0xE1,
- QMI_SVC_OMA = 0xE2
+ QMI_SVC_CTL = 0x00,
+ QMI_SVC_WDS = 0x01,
+ QMI_SVC_DMS = 0x02,
+ QMI_SVC_NAS = 0x03,
+ QMI_SVC_QOS = 0x04,
+ QMI_SVC_WMS = 0x05,
+ QMI_SVC_PDS = 0x06,
+ QMI_SVC_AUTH = 0x07,
+ QMI_SVC_AT = 0x08,
+ QMI_SVC_VOICE = 0x09,
+ QMI_SVC_CAT2 = 0x0A,
+ QMI_SVC_UIM = 0x0B,
+ QMI_SVC_PBM = 0x0C,
+ QMI_SVC_LOC = 0x10,
+ QMI_SVC_SAR = 0x11,
+ QMI_SVC_RMTFS = 0x14,
+ QMI_SVC_CAT = 0xE0,
+ QMI_SVC_RMS = 0xE1,
+ QMI_SVC_OMA = 0xE2
} qmi_service_type;
struct qmux {
- u8 tf; /* always 1 */
- u16 len;
- u8 ctrl;
- u8 service;
- u8 qmicid;
+ u8 tf; /* always 1 */
+ u16 len;
+ u8 ctrl;
+ u8 service;
+ u8 qmicid;
} __attribute__((__packed__));
struct qmi_tlv_status {
@@ -112,93 +112,93 @@ struct qmi_tlv_status {
} __attribute__((__packed__));
struct getcid_req {
- struct qmux header;
- u8 req;
- u8 tid;
- u16 msgid;
- u16 tlvsize;
- u8 service;
- u16 size;
- u8 qmisvc;
+ struct qmux header;
+ u8 req;
+ u8 tid;
+ u16 msgid;
+ u16 tlvsize;
+ u8 service;
+ u16 size;
+ u8 qmisvc;
} __attribute__((__packed__));
struct releasecid_req {
- struct qmux header;
- u8 req;
- u8 tid;
- u16 msgid;
- u16 tlvsize;
- u8 rlscid;
- u16 size;
- u16 cid;
+ struct qmux header;
+ u8 req;
+ u8 tid;
+ u16 msgid;
+ u16 tlvsize;
+ u8 rlscid;
+ u16 size;
+ u16 cid;
} __attribute__((__packed__));
struct version_info_req {
- struct qmux header;
- u8 req;
- u8 tid;
- u16 msgid;
- u16 tlvsize;
+ struct qmux header;
+ u8 req;
+ u8 tid;
+ u16 msgid;
+ u16 tlvsize;
} __attribute__((__packed__));
struct qmi_ctl_version_info_list_service {
- u8 service_type; /* QMI_SVC_xxx */
- u16 major_version;
- u16 minor_version;
+ u8 service_type; /* QMI_SVC_xxx */
+ u16 major_version;
+ u16 minor_version;
} __attribute__((__packed__));
struct qmi_tlv_ctl_version_info_list {
- u8 count;
- struct qmi_ctl_version_info_list_service services[0];
+ u8 count;
+ struct qmi_ctl_version_info_list_service services[0];
}__attribute__((__packed__));
struct seteventreport_req {
- struct qmux header;
- u8 req;
- u16 tid;
- u16 msgid;
- u16 tlvsize;
- u8 reportchanrate;
- u16 size;
- u8 period;
- u32 mask;
+ struct qmux header;
+ u8 req;
+ u16 tid;
+ u16 msgid;
+ u16 tlvsize;
+ u8 reportchanrate;
+ u16 size;
+ u8 period;
+ u32 mask;
} __attribute__((__packed__));
struct getpkgsrvcstatus_req {
- struct qmux header;
- u8 req;
- u16 tid;
- u16 msgid;
- u16 tlvsize;
+ struct qmux header;
+ u8 req;
+ u16 tid;
+ u16 msgid;
+ u16 tlvsize;
} __attribute__((__packed__));
struct getmeid_req {
- struct qmux header;
- u8 req;
- u16 tid;
- u16 msgid;
- u16 tlvsize;
+ struct qmux header;
+ u8 req;
+ u16 tid;
+ u16 msgid;
+ u16 tlvsize;
} __attribute__((__packed__));
struct qmiwds_stats {
- u32 txok;
- u32 rxok;
- u32 txerr;
- u32 rxerr;
- u32 txofl;
- u32 rxofl;
- u64 txbytesok;
- u64 rxbytesok;
- qbool linkstate;
- qbool reconfigure;
+ u32 txok;
+ u32 rxok;
+ u32 txerr;
+ u32 rxerr;
+ u32 txofl;
+ u32 rxofl;
+ u64 txbytesok;
+ u64 rxbytesok;
+ qbool linkstate;
+ qbool reconfigure;
};
struct nas_signal_req {
- struct qmux header;
- u8 req;
- u16 tid;
- u16 msgid;
- u16 tlvsize;
+ struct qmux header;
+ u8 req;
+ u16 tid;
+ u16 msgid;
+ u16 tlvsize;
} __attribute__((__packed__));
const size_t qmux_size = sizeof(struct qmux);
@@ -206,147 +206,147 @@ const size_t qmux_size = sizeof(struct qmux);
static void
qmux_fill(struct qmux *qmux, u8 service, u16 cid, u16 size)
{
- qmux->tf = 1;
- qmux->len = size - 1;
- qmux->ctrl = 0;
- qmux->service = cid & 0xff;
- qmux->qmicid = cid >> 8;
+ qmux->tf = 1;
+ qmux->len = size - 1;
+ qmux->ctrl = 0;
+ qmux->service = cid & 0xff;
+ qmux->qmicid = cid >> 8;
}
static void *
qmictl_new_getcid(u8 tid, u8 svctype, size_t *size)
{
- struct getcid_req *req;
+ struct getcid_req *req;
req = g_malloc0 (sizeof (*req));
- req->req = 0x00;
- req->tid = tid;
- req->msgid = 0x0022;
- req->tlvsize = 0x0004;
- req->service = 0x01;
- req->size = 0x0001;
- req->qmisvc = svctype;
- *size = sizeof(*req);
+ req->req = 0x00;
+ req->tid = tid;
+ req->msgid = 0x0022;
+ req->tlvsize = 0x0004;
+ req->service = 0x01;
+ req->size = 0x0001;
+ req->qmisvc = svctype;
+ *size = sizeof(*req);
qmux_fill (&req->header, QMI_SVC_CTL, 0, *size);
- return req;
+ return req;
}
static void *
qmictl_new_releasecid(u8 tid, u16 cid, size_t *size)
{
- struct releasecid_req *req;
+ struct releasecid_req *req;
req = g_malloc0 (sizeof (*req));
- req->req = 0x00;
- req->tid = tid;
- req->msgid = 0x0023;
- req->tlvsize = 0x05;
- req->rlscid = 0x01;
- req->size = 0x0002;
- req->cid = cid;
- *size = sizeof(*req);
+ req->req = 0x00;
+ req->tid = tid;
+ req->msgid = 0x0023;
+ req->tlvsize = 0x05;
+ req->rlscid = 0x01;
+ req->size = 0x0002;
+ req->cid = cid;
+ *size = sizeof(*req);
qmux_fill (&req->header, QMI_SVC_CTL, 0, *size);
- return req;
+ return req;
}
static void *
qmictl_new_version_info(u8 tid, size_t *size)
{
- struct version_info_req *req;
+ struct version_info_req *req;
req = g_malloc0 (sizeof (*req));
- req->req = 0x00;
- req->tid = tid;
- req->msgid = 0x21;
- req->tlvsize = 0;
- *size = sizeof(*req);
+ req->req = 0x00;
+ req->tid = tid;
+ req->msgid = 0x21;
+ req->tlvsize = 0;
+ *size = sizeof(*req);
qmux_fill (&req->header, QMI_SVC_CTL, 0, *size);
- return req;
+ return req;
}
static void *
qmiwds_new_seteventreport(u8 tid, size_t *size)
{
- struct seteventreport_req *req;
+ struct seteventreport_req *req;
req = g_malloc0 (sizeof (*req));
- req->req = 0x00;
- req->tid = tid;
- req->msgid = 0x0001;
- req->tlvsize = 0x0008;
- req->reportchanrate = 0x11;
- req->size = 0x0005;
- req->period = 0x01;
- req->mask = 0x000000ff;
- *size = sizeof(*req);
- return req;
+ req->req = 0x00;
+ req->tid = tid;
+ req->msgid = 0x0001;
+ req->tlvsize = 0x0008;
+ req->reportchanrate = 0x11;
+ req->size = 0x0005;
+ req->period = 0x01;
+ req->mask = 0x000000ff;
+ *size = sizeof(*req);
+ return req;
}
static void *
qmiwds_new_getpkgsrvcstatus(u8 tid, size_t *size)
{
- struct getpkgsrvcstatus_req *req;
+ struct getpkgsrvcstatus_req *req;
req = g_malloc0 (sizeof (*req));
- req->req = 0x00;
- req->tid = tid;
- req->msgid = 0x22;
- req->tlvsize = 0x0000;
- *size = sizeof(*req);
- return req;
+ req->req = 0x00;
+ req->tid = tid;
+ req->msgid = 0x22;
+ req->tlvsize = 0x0000;
+ *size = sizeof(*req);
+ return req;
}
static void *
qmidms_new_getmeid(u16 cid, u8 tid, size_t *size)
{
- struct getmeid_req *req;
+ struct getmeid_req *req;
req = g_malloc0 (sizeof (*req));
- req->req = 0x00;
- req->tid = tid;
- req->msgid = 0x25;
- req->tlvsize = 0x0000;
- *size = sizeof(*req);
+ req->req = 0x00;
+ req->tid = tid;
+ req->msgid = 0x25;
+ req->tlvsize = 0x0000;
+ *size = sizeof(*req);
qmux_fill (&req->header, QMI_SVC_WDS, cid, *size);
- return req;
+ return req;
}
static int
qmux_parse(u16 *cid, void *buf, size_t size)
{
- struct qmux *qmux = buf;
+ struct qmux *qmux = buf;
- if (!buf || size < 12)
- return -ENOMEM;
+ if (!buf || size < 12)
+ return -ENOMEM;
- if (qmux->tf != 1 || qmux->len != size - 1 || qmux->ctrl != 0x80)
- return -EINVAL;
+ if (qmux->tf != 1 || qmux->len != size - 1 || qmux->ctrl != 0x80)
+ return -EINVAL;
- *cid = (qmux->qmicid << 8) + qmux->service;
- return sizeof(*qmux);
+ *cid = (qmux->qmicid << 8) + qmux->service;
+ return sizeof(*qmux);
}
static u16
tlv_get(void *msg, u16 msgsize, u8 type, void *buf, u16 bufsize)
{
- u16 pos;
- u16 msize = 0;
+ u16 pos;
+ u16 msize = 0;
- if (!msg || !buf)
- return -ENOMEM;
+ if (!msg || !buf)
+ return -ENOMEM;
- for (pos = 4; pos + 3 < msgsize; pos += msize + 3) {
- msize = *(u16 *)(msg + pos + 1);
- if (*(u8 *)(msg + pos) == type) {
- if (bufsize < msize)
- return -ENOMEM;
+ for (pos = 4; pos + 3 < msgsize; pos += msize + 3) {
+ msize = *(u16 *)(msg + pos + 1);
+ if (*(u8 *)(msg + pos) == type) {
+ if (bufsize < msize)
+ return -ENOMEM;
- memcpy(buf, msg + pos + 3, msize);
- return msize;
- }
- }
+ memcpy(buf, msg + pos + 3, msize);
+ return msize;
+ }
+ }
- return -ENOMSG;
+ return -ENOMSG;
}
static int
@@ -354,48 +354,48 @@ qmi_msgisvalid(void *msg, u16 size)
{
struct qmi_tlv_status status;
- if (tlv_get(msg, size, 2, &status, sizeof (status)) == sizeof (status)) {
+ if (tlv_get(msg, size, 2, &status, sizeof (status)) == sizeof (status)) {
if (le16toh (status.status != 0))
return le16toh (status.error);
- else
- return 0;
- }
- return -ENOMSG;
+ else
+ return 0;
+ }
+ return -ENOMSG;
}
static int
qmi_msgid(void *msg, u16 size)
{
- return size < 2 ? -ENODATA : *(u16 *)msg;
+ return size < 2 ? -ENODATA : *(u16 *)msg;
}
static int
qmictl_version_info_resp(void *buf, u16 size)
{
- int result, i;
- u8 offset = sizeof(struct qmux) + 2;
+ int result, i;
+ u8 offset = sizeof(struct qmux) + 2;
u8 svcbuf[100];
struct qmi_tlv_ctl_version_info_list *service_list;
struct qmi_ctl_version_info_list_service *svc;
- if (!buf || size < offset)
- return -ENOMEM;
+ if (!buf || size < offset)
+ return -ENOMEM;
- buf = buf + offset;
- size -= offset;
+ buf = buf + offset;
+ size -= offset;
- result = qmi_msgid(buf, size);
- if (result != 0x21)
- return -EFAULT;
+ result = qmi_msgid(buf, size);
+ if (result != 0x21)
+ return -EFAULT;
- result = qmi_msgisvalid(buf, size);
- if (result != 0)
- return -EFAULT;
+ result = qmi_msgisvalid(buf, size);
+ if (result != 0)
+ return -EFAULT;
/* Get the services TLV */
- result = tlv_get(buf, size, 0x01, svcbuf, sizeof (svcbuf));
- if (result < 0)
- return -EFAULT;
+ result = tlv_get(buf, size, 0x01, svcbuf, sizeof (svcbuf));
+ if (result < 0)
+ return -EFAULT;
service_list = (struct qmi_tlv_ctl_version_info_list *) svcbuf;
if (result < (service_list->count * sizeof (struct qmi_ctl_version_info_list_service)))
@@ -409,140 +409,140 @@ qmictl_version_info_resp(void *buf, u16 size)
le16toh (svc->minor_version));
}
- return 0;
+ return 0;
}
static int
qmictl_getcid_resp(void *buf, u16 size, u16 *cid)
{
- int result;
- u8 offset = sizeof(struct qmux) + 2;
+ int result;
+ u8 offset = sizeof(struct qmux) + 2;
- if (!buf || size < offset)
- return -ENOMEM;
+ if (!buf || size < offset)
+ return -ENOMEM;
- buf = buf + offset;
- size -= offset;
+ buf = buf + offset;
+ size -= offset;
- result = qmi_msgid(buf, size);
- if (result != 0x22)
- return -EFAULT;
+ result = qmi_msgid(buf, size);
+ if (result != 0x22)
+ return -EFAULT;
- result = qmi_msgisvalid(buf, size);
- if (result != 0)
- return -EFAULT;
+ result = qmi_msgisvalid(buf, size);
+ if (result != 0)
+ return -EFAULT;
- result = tlv_get(buf, size, 0x01, cid, 2);
- if (result != 2)
- return -EFAULT;
+ result = tlv_get(buf, size, 0x01, cid, 2);
+ if (result != 2)
+ return -EFAULT;
- return 0;
+ return 0;
}
static int
qmictl_releasecid_resp(void *buf, u16 size)
{
- int result;
- u8 offset = sizeof(struct qmux) + 2;
+ int result;
+ u8 offset = sizeof(struct qmux) + 2;
- if (!buf || size < offset)
- return -ENOMEM;
+ if (!buf || size < offset)
+ return -ENOMEM;
- buf = buf + offset;
- size -= offset;
+ buf = buf + offset;
+ size -= offset;
- result = qmi_msgid(buf, size);
- if (result != 0x23)
- return -EFAULT;
+ result = qmi_msgid(buf, size);
+ if (result != 0x23)
+ return -EFAULT;
- result = qmi_msgisvalid(buf, size);
- if (result != 0)
- return -EFAULT;
+ result = qmi_msgisvalid(buf, size);
+ if (result != 0)
+ return -EFAULT;
- return 0;
+ return 0;
}
static int
qmiwds_event_resp(void *buf, u16 size, struct qmiwds_stats *stats)
{
- int result;
- u8 status[2];
-
- u8 offset = sizeof(struct qmux) + 3;
-
- if (!buf || size < offset || !stats)
- return -ENOMEM;
-
- buf = buf + offset;
- size -= offset;
-
- result = qmi_msgid(buf, size);
- if (result == 0x01) {
- tlv_get(buf, size, 0x10, &stats->txok, 4);
- tlv_get(buf, size, 0x11, &stats->rxok, 4);
- tlv_get(buf, size, 0x12, &stats->txerr, 4);
- tlv_get(buf, size, 0x13, &stats->rxerr, 4);
- tlv_get(buf, size, 0x14, &stats->txofl, 4);
- tlv_get(buf, size, 0x15, &stats->rxofl, 4);
- tlv_get(buf, size, 0x19, &stats->txbytesok, 8);
- tlv_get(buf, size, 0x1A, &stats->rxbytesok, 8);
- } else if (result == 0x22) {
- result = tlv_get(buf, size, 0x01, &status[0], 2);
- if (result >= 1)
- stats->linkstate = status[0] == 0x02;
- if (result == 2)
- stats->reconfigure = status[1] == 0x01;
-
- if (result < 0)
- return result;
- } else {
- return -EFAULT;
- }
-
- return 0;
+ int result;
+ u8 status[2];
+
+ u8 offset = sizeof(struct qmux) + 3;
+
+ if (!buf || size < offset || !stats)
+ return -ENOMEM;
+
+ buf = buf + offset;
+ size -= offset;
+
+ result = qmi_msgid(buf, size);
+ if (result == 0x01) {
+ tlv_get(buf, size, 0x10, &stats->txok, 4);
+ tlv_get(buf, size, 0x11, &stats->rxok, 4);
+ tlv_get(buf, size, 0x12, &stats->txerr, 4);
+ tlv_get(buf, size, 0x13, &stats->rxerr, 4);
+ tlv_get(buf, size, 0x14, &stats->txofl, 4);
+ tlv_get(buf, size, 0x15, &stats->rxofl, 4);
+ tlv_get(buf, size, 0x19, &stats->txbytesok, 8);
+ tlv_get(buf, size, 0x1A, &stats->rxbytesok, 8);
+ } else if (result == 0x22) {
+ result = tlv_get(buf, size, 0x01, &status[0], 2);
+ if (result >= 1)
+ stats->linkstate = status[0] == 0x02;
+ if (result == 2)
+ stats->reconfigure = status[1] == 0x01;
+
+ if (result < 0)
+ return result;
+ } else {
+ return -EFAULT;
+ }
+
+ return 0;
}
static int
qmidms_meid_resp(void *buf, u16 size, char *meid, int meidsize)
{
- int result;
+ int result;
- u8 offset = sizeof(struct qmux) + 3;
+ u8 offset = sizeof(struct qmux) + 3;
- if (!buf || size < offset || meidsize < 14)
- return -ENOMEM;
+ if (!buf || size < offset || meidsize < 14)
+ return -ENOMEM;
- buf = buf + offset;
- size -= offset;
+ buf = buf + offset;
+ size -= offset;
- result = qmi_msgid(buf, size);
- if (result != 0x25)
- return -EFAULT;
+ result = qmi_msgid(buf, size);
+ if (result != 0x25)
+ return -EFAULT;
- result = qmi_msgisvalid(buf, size);
- if (result)
- return -EFAULT;
+ result = qmi_msgisvalid(buf, size);
+ if (result)
+ return -EFAULT;
- result = tlv_get(buf, size, 0x12, meid, 14);
- if (result != 14)
- return -EFAULT;
+ result = tlv_get(buf, size, 0x12, meid, 14);
+ if (result != 14)
+ return -EFAULT;
- return 0;
+ return 0;
}
static void *
qminas_new_signal(u16 cid, u8 tid, size_t *size)
{
- struct nas_signal_req *req;
+ struct nas_signal_req *req;
req = g_malloc0 (sizeof (*req));
- req->req = 0x00;
- req->tid = tid;
- req->msgid = 0x20;
- req->tlvsize = 0x0000;
- *size = sizeof(*req);
+ req->req = 0x00;
+ req->tid = tid;
+ req->msgid = 0x20;
+ req->tlvsize = 0x0000;
+ *size = sizeof(*req);
qmux_fill (&req->header, QMI_SVC_NAS, cid, *size);
- return req;
+ return req;
}
/* NAS/Get Signal Strength TLV 0x01 */
@@ -554,32 +554,32 @@ struct qminas_resp_signalstrength {
static int
qminas_signal_resp(void *buf, u16 size, u8 *dbm, u8 *act)
{
- int result;
- struct qminas_resp_signalstrength signal;
+ int result;
+ struct qminas_resp_signalstrength signal;
- u8 offset = sizeof(struct qmux) + 3;
+ u8 offset = sizeof(struct qmux) + 3;
- if (!buf || size < offset)
- return -ENOMEM;
+ if (!buf || size < offset)
+ return -ENOMEM;
- buf = buf + offset;
- size -= offset;
+ buf = buf + offset;
+ size -= offset;
- result = qmi_msgid(buf, size);
- if (result != 0x20)
- return -EFAULT;
+ result = qmi_msgid(buf, size);
+ if (result != 0x20)
+ return -EFAULT;
- result = qmi_msgisvalid(buf, size);
- if (result)
- return -EFAULT;
+ result = qmi_msgisvalid(buf, size);
+ if (result)
+ return -EFAULT;
- result = tlv_get(buf, size, 0x01, &signal, sizeof (signal));
- if (result != sizeof (signal))
- return -EFAULT;
+ result = tlv_get(buf, size, 0x01, &signal, sizeof (signal));
+ if (result != sizeof (signal))
+ return -EFAULT;
*dbm = signal.dbm;
*act = signal.act;
- return 0;
+ return 0;
}
/*****************************************************/