-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc fixes for qrild #21
base: master
Are you sure you want to change the base?
Changes from 1 commit
ca18508
d86dacc
4246d2a
9e9b6ba
8ade7c5
b501651
bec5bb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,9 +178,18 @@ void *qmi_tlv_get_array(struct qmi_tlv *tlv, uint8_t id, size_t len_size, | |
int qmi_tlv_set(struct qmi_tlv *tlv, uint8_t id, void *buf, size_t len); | ||
int qmi_tlv_set_array(struct qmi_tlv *tlv, uint8_t id, size_t len_size, | ||
void *buf, size_t len, size_t size); | ||
|
||
struct qmi_response_type_v01 *qmi_tlv_get_result(struct qmi_tlv *tlv); | ||
|
||
static inline int qmi_tlv_dump_buf(void *buf, size_t len) { | ||
struct qmi_tlv *tlv = qmi_tlv_decode(buf, len); | ||
if (!tlv) | ||
return -1; | ||
qmi_tlv_dump(tlv); | ||
qmi_tlv_free(tlv); | ||
|
||
return 0; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say, also squash |
||
/* Initial kernel header didn't expose these */ | ||
#ifndef QRTR_NODE_BCAST | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include <ctype.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
|
@@ -227,7 +228,7 @@ struct qmi_response_type_v01 *qmi_tlv_get_result(struct qmi_tlv *tlv) | |
} | ||
|
||
#define MIN(x, y) ((x) < (y) ? (x) : (y)) | ||
#define LINE_LENGTH 64 | ||
#define LINE_LENGTH 40 | ||
|
||
static inline uint8_t to_hex(uint8_t ch) | ||
{ | ||
|
@@ -238,7 +239,7 @@ static inline uint8_t to_hex(uint8_t ch) | |
void qmi_tlv_dump(struct qmi_tlv *tlv) { | ||
struct qmi_tlv_item *item; | ||
struct qmi_header *pkt; | ||
unsigned offset = 0; | ||
unsigned offset = sizeof(struct qmi_header); | ||
void *pkt_data; | ||
int i = 0, li, j, k; | ||
uint8_t ch; | ||
|
@@ -254,10 +255,11 @@ void qmi_tlv_dump(struct qmi_tlv *tlv) { | |
printf("<<< msg_id : 0x%1$04x (%1$u)\n", pkt->msg_id); | ||
printf("<<< txn_id : 0x%1$04x (%1$u)\n", pkt->txn_id); | ||
printf("<<< TLVs:\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please pass |
||
while (offset < tlv->size - sizeof(struct qmi_header)) { | ||
// I do not understand why this -1 is needed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh? |
||
while (offset < tlv->size - 1) { | ||
item = pkt_data + offset; | ||
printf("<<< TLV %d: {id: 0x%02x, len: 0x%02x}\n", i, item->key, item->len); | ||
if (item->len > pkt->msg_len - offset) { | ||
if (item->len > pkt->msg_len + sizeof(struct qmi_header) - offset) { | ||
fprintf(stderr, "Invalid item length!\n"); | ||
return; | ||
} | ||
|
@@ -271,6 +273,18 @@ void qmi_tlv_dump(struct qmi_tlv *tlv) { | |
line[li++] = to_hex(ch); | ||
line[li++] = k < linelen - 1 ? ':' : ' '; | ||
} | ||
|
||
for (; k < LINE_LENGTH; k++) { | ||
line[li++] = ' '; | ||
line[li++] = ' '; | ||
line[li++] = ' '; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a possibility to overflow it? |
||
} | ||
|
||
for (k = 0; k < linelen; k++) { | ||
ch = item->data[j + k]; | ||
line[li++] = isprint(ch) ? ch : '.'; | ||
} | ||
|
||
line[li] = '\0'; | ||
|
||
printf("%s\n\n", line); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-EINVAL