Skip to content

Commit

Permalink
output: Add linktype name
Browse files Browse the repository at this point in the history
Issue: 6954

This commit adds the linktype name to the output stream. The name is
determined from the pcap utility function pcap_datalink_val_to_name
  • Loading branch information
jlucovsky committed Oct 19, 2024
1 parent 3718fc9 commit 29d5eea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3472,6 +3472,10 @@
"properties": {
"linktype": {
"type": "integer"
},
"linktype_name": {
"type": "string",
"description": "the descriptive name of the linktype"
}
},
"additionalProperties": false
Expand Down
7 changes: 7 additions & 0 deletions src/output-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,15 @@ void EvePacket(const Packet *p, JsonBuilder *js, uint32_t max_length)
return;
}
if (!jb_set_uint(js, "linktype", p->datalink)) {
jb_close(js);
return;
}

const char *dl_name = DatalinkValueToName(p->datalink);
// Intentionally ignore the return value from jb_set_string and proceed
// so the jb object is closed
jb_set_string(js, "linktype_name", dl_name == NULL ? "n/a" : dl_name);

jb_close(js);
}

Expand Down

0 comments on commit 29d5eea

Please sign in to comment.