From: Stefan Metzmacher Date: Tue, 8 Apr 2025 12:28:39 +0000 (+0200) Subject: s3:smbstatus: provide the transport type via json output X-Git-Tag: tevent-0.17.0~254 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e0d1478f46984736f2358b68497dc765c3a079c;p=thirdparty%2Fsamba.git s3:smbstatus: provide the transport type via json output Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- diff --git a/source3/utils/status_json.c b/source3/utils/status_json.c index f558c91dec7..f7727b4c39d 100644 --- a/source3/utils/status_json.c +++ b/source3/utils/status_json.c @@ -299,8 +299,32 @@ static int add_channel_to_json(struct json_object *parent_json, struct timeval tv; struct timeval_buf tv_buf; char *time_str = NULL; + const char *transport_str = NULL; + enum smb_transport_type tt = + (enum smb_transport_type)channel->transport_type; int result; + switch (tt) { + case SMB_TRANSPORT_TYPE_UNKNOWN: + transport_str = "unknown"; + break; + case SMB_TRANSPORT_TYPE_NBT: + transport_str = "nbt"; + break; + case SMB_TRANSPORT_TYPE_TCP: + transport_str = "tcp"; + break; + } + + if (transport_str == NULL) { + transport_str = talloc_asprintf(frame, + "unknown%u", + tt); + if (transport_str == NULL) { + goto failure; + } + } + sub_json = json_new_object(); if (json_is_invalid(&sub_json)) { goto failure; @@ -331,6 +355,10 @@ static int add_channel_to_json(struct json_object *parent_json, if (result < 0) { goto failure; } + result = json_add_string(&sub_json, "transport", transport_str); + if (result < 0) { + goto failure; + } result = json_add_object(parent_json, id_str, &sub_json); if (result < 0) {