]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbstatus: provide the transport type via json output
authorStefan Metzmacher <metze@samba.org>
Tue, 8 Apr 2025 12:28:39 +0000 (14:28 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2025 10:17:30 +0000 (10:17 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/utils/status_json.c

index f558c91dec71de1e817e825ef8e8ce921b9a313b..f7727b4c39d5232b0eefa08701b3f7f5f108a3e9 100644 (file)
@@ -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) {