Skip to content
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

output: Add linktype name #11670

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3465,6 +3465,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 @@ -438,8 +438,15 @@ void EvePacket(const Packet *p, JsonBuilder *js, unsigned long max_length)
return;
}
if (!jb_set_uint(js, "linktype", p->datalink)) {
jb_close(js);
return;
}

const char *dl_name = pcap_datalink_val_to_name(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
Loading