Skip to contentSkip to conversation

Add DisableNameResolving option to main.conf

PATCH In review Ilya Rubtsov 2 participants 6 messages May 7, 2009 – May 10, 2009 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add DisableNameResolving option to main.conf

Hi!

This patch adds new option to main.conf - DisableNameResolving. If DisableNameResolving=true then we don't ask remote devices for their names after inquiry. Default value is false. That's all :)

src/adapter.c +1 -1
index 500f82f..02c6d9e 100644
@@ -1076,7 +1076,7 @@ static int start_inquiry(struct btd_adapter *adapter)
 
    hci_close_dev(dd);
 
-    adapter->state |= RESOLVE_NAME;
+    adapter->state |= main_opts.disable_nameres;
 
    return 0;

}
@@ -1126,7 +1126,7 @@ static int start_periodic_inquiry(struct btd_adapter *adapter)

    hci_close_dev(dd);
-    adapter->state |= RESOLVE_NAME;
+    adapter->state |= main_opts.disable_nameres;
    return 0;
}
@@ -2446,7 +2446,7 @@ struct btd_adapter *adapter_create(DBusConnection *conn, int id,
    }

    adapter->dev_id = id;
-    adapter->state |= RESOLVE_NAME;
+    adapter->state |= main_opts.disable_nameres;
    adapter->path = g_strdup(path);
    adapter->already_up = devup;
src/dbus-hci.c +1 -1
index e52b4f6..014360b 100644
@@ -458,7 +458,7 @@ void hcid_dbus_inquiry_start(bdaddr_t *local)
    /* Disable name resolution for non D-Bus clients */
    if (!adapter_has_discov_sessions(adapter)) {
        state = adapter_get_state(adapter);
-        state &= ~RESOLVE_NAME;
+        state &= ~main_opts.disable_nameres;
        adapter_set_state(adapter, state);
    }

}
@@ -687,7 +687,7 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,

    }

    /* the inquiry result can be triggered by NON D-Bus client */
-    if (adapter_get_state(adapter) & RESOLVE_NAME)
+    if (adapter_get_state(adapter) & main_opts.disable_nameres)
        name_status = NAME_REQUIRED;
    else
        name_status = NAME_NOT_REQUIRED;
src/hcid.h +1 -0
index ae356d3..efefa6c 100644
@@ -59,6 +59,7 @@ struct main_opts {
    uint16_t    link_policy;
    gboolean    remember_powered;
    gboolean    reverse_sdp;
+    int        disable_nameres;
 
    uint8_t        scan;
    uint8_t        mode;
src/main.c +11 -0
index 08bef4a..5358db1 100644
@@ -187,6 +187,18 @@ static void parse_config(GKeyFile *config)
    } else
        main_opts.reverse_sdp = boolean;
 
+    boolean = g_key_file_get_boolean(config, "General",
+                        "DisableNameResolving", &err);
+    if (err) {
+        debug("%s", err->message);
+        g_clear_error(&err);
+    } else {       +        if (boolean)
+            main_opts.disable_nameres = 0x00;
+        else
+            main_opts.disable_nameres = 0x10;
+    }
+
    main_opts.link_mode = HCI_LM_ACCEPT;
 
    main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
src/main.conf +0 -0
index c736e49..7dad783 100644
@@ -46,3 +46,7 @@ RememberPowered = true

# doesn't like us doing reverse SDP for some test cases (though there could in

# theory be other useful purposes for this too). Defaults to true.
ReverseServiceDiscovery = true
+
+# Disable name resolving after inquiry. Set it to 'true' if you don't need remote
+# devices name and want shorter discovery cycle
+DisableNameRevolving = false
#1 lore raw

Sorry, there was mistake :(

src/adapter.c +1 -1
index 500f82f..02c6d9e 100644
@@ -1076,7 +1076,7 @@ static int start_inquiry(struct btd_adapter *adapter)
 
    hci_close_dev(dd);
 
-    adapter->state |= RESOLVE_NAME;
+    adapter->state |= main_opts.disable_nameres;
 
    return 0;

}
@@ -1126,7 +1126,7 @@ static int start_periodic_inquiry(struct btd_adapter *adapter)

    hci_close_dev(dd);
-    adapter->state |= RESOLVE_NAME;
+    adapter->state |= main_opts.disable_nameres;
    return 0;
}
@@ -2446,7 +2446,7 @@ struct btd_adapter *adapter_create(DBusConnection *conn, int id,
    }

    adapter->dev_id = id;
-    adapter->state |= RESOLVE_NAME;
+    adapter->state |= main_opts.disable_nameres;
    adapter->path = g_strdup(path);
    adapter->already_up = devup;
src/dbus-hci.c +1 -1
index e52b4f6..014360b 100644
@@ -458,7 +458,7 @@ void hcid_dbus_inquiry_start(bdaddr_t *local)
    /* Disable name resolution for non D-Bus clients */
    if (!adapter_has_discov_sessions(adapter)) {
        state = adapter_get_state(adapter);
-        state &= ~RESOLVE_NAME;
+        state &= ~main_opts.disable_nameres;
        adapter_set_state(adapter, state);
    }

}
@@ -687,7 +687,7 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,

    }

    /* the inquiry result can be triggered by NON D-Bus client */
-    if (adapter_get_state(adapter) & RESOLVE_NAME)
+    if (adapter_get_state(adapter) & main_opts.disable_nameres)
        name_status = NAME_REQUIRED;
    else
        name_status = NAME_NOT_REQUIRED;
src/hcid.h +1 -0
index ae356d3..efefa6c 100644
@@ -59,6 +59,7 @@ struct main_opts {
    uint16_t    link_policy;
    gboolean    remember_powered;
    gboolean    reverse_sdp;
+    int        disable_nameres;
 
    uint8_t        scan;
    uint8_t        mode;
src/main.c +11 -0
index 08bef4a..5358db1 100644
@@ -187,6 +187,18 @@ static void parse_config(GKeyFile *config)
    } else
        main_opts.reverse_sdp = boolean;
 
+    boolean = g_key_file_get_boolean(config, "General",
+                        "DisableNameResolving", &err);
+    if (err) {
+        debug("%s", err->message);
+        g_clear_error(&err);
+    } else {       +        if (boolean)
+            main_opts.disable_nameres = 0x00;
+        else
+            main_opts.disable_nameres = 0x10;
+    }
+
    main_opts.link_mode = HCI_LM_ACCEPT;
 
    main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
src/main.conf +0 -0
index c736e49..75a8b04 100644
@@ -46,3 +46,7 @@ RememberPowered = true

# doesn't like us doing reverse SDP for some test cases (though there could in

# theory be other useful purposes for this too). Defaults to true.
ReverseServiceDiscovery = true
+
+# Disable name resolving after inquiry. Set it to 'true' if you don't need remote
+# devices name and want shorter discovery cycle
+DisableNameResolving = false
#2 lore raw

I think I fixed coding style.. And it seems to work. And I think the code is quite understandble now :)

src/adapter.c +0 -0
index 500f82f..a7a02cc 100644

-1076,7 +1076,8 @@ static int start_inquiry(struct btd_adapter *adapter)

    hci_close_dev(dd);

- adapter->state |= RESOLVE_NAME;
+ if (!main_opts.disable_nameres)
+ adapter->state |= RESOLVE_NAME;

    return 0;
}

-1126,7 +1127,8 @@ static int start_periodic_inquiry(struct btd_adapter *adapter)

    hci_close_dev(dd);

- adapter->state |= RESOLVE_NAME;
+ if (!main_opts.disable_nameres)
+ adapter->state |= RESOLVE_NAME;

    return 0;
}
-2446,7 +2448,8 @@ struct btd_adapter *adapter_create(DBusConnection *conn, int id,
    }

    adapter->dev_id = id;
-    adapter->state |= RESOLVE_NAME;
+    if (!main_opts.disable_nameres)
+        adapter->state |= RESOLVE_NAME;
    adapter->path = g_strdup(path);
    adapter->already_up = devup;
src/hcid.h +0 -0
index ae356d3..c10f65a 100644
-59,6 +59,7 @@ struct main_opts {
    uint16_t    link_policy;
    gboolean    remember_powered;
    gboolean    reverse_sdp;

+ gboolean disable_nameres;

    uint8_t        scan;
    uint8_t        mode;
src/main.c +0 -0
index 08bef4a..d7d29b3 100644

-187,6 +187,13 @@ static void parse_config(GKeyFile *config)

    } else
        main_opts.reverse_sdp = boolean;

+ boolean = g_key_file_get_boolean(config, "General",
+ "DisableNameResolving", &err);
+ if (err)
+ g_clear_error(&err);
+ else
+ main_opts.disable_nameres = boolean;
+
main_opts.link_mode = HCI_LM_ACCEPT;

main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |

src/main.conf +0 -0
index c736e49..0c6994a 100644

-46,3 +46,7 @@ RememberPowered = true
# doesn't like us doing reverse SDP for some test cases (though there could in

# theory be other useful purposes for this too). Defaults to true.
ReverseServiceDiscovery = true
+
+# Disable name resolving after inquiry. Set it to 'true' if you don't need
+# remote devices name and want shorter discovery cycle
+DisableNameResolving = false
#3 lore raw

And now with variable named name_resolv with default value 'true'

src/adapter.c +2 -1
index 500f82f..bb3e770 100644
@@ -1076,7 +1076,8 @@ static int start_inquiry(struct btd_adapter *adapter)
 
    hci_close_dev(dd);
 
-    adapter->state |= RESOLVE_NAME;
+    if (main_opts.name_resolv)
+        adapter->state |= RESOLVE_NAME;
 
    return 0;

}
@@ -1126,7 +1127,8 @@ static int start_periodic_inquiry(struct btd_adapter *adapter)

    hci_close_dev(dd);

- adapter->state |= RESOLVE_NAME;
+ if (main_opts.name_resolv)
+ adapter->state |= RESOLVE_NAME;

    return 0;
}
@@ -2446,7 +2448,8 @@ struct btd_adapter *adapter_create(DBusConnection *conn, int id,
    }

    adapter->dev_id = id;
-    adapter->state |= RESOLVE_NAME;
+    if (main_opts.name_resolv)
+        adapter->state |= RESOLVE_NAME;
    adapter->path = g_strdup(path);
    adapter->already_up = devup;
src/hcid.h +1 -0
index ae356d3..5e80fb6 100644
@@ -59,6 +59,7 @@ struct main_opts {
    uint16_t    link_policy;
    gboolean    remember_powered;
    gboolean    reverse_sdp;
+    gboolean    name_resolv;
 
    uint8_t        scan;
    uint8_t        mode;
src/main.c +8 -0
index 08bef4a..53412c1 100644
@@ -187,6 +187,13 @@ static void parse_config(GKeyFile *config)
    } else
        main_opts.reverse_sdp = boolean;
 
+    boolean = g_key_file_get_boolean(config, "General",
+                        "NameResolving", &err);
+    if (err)
+        g_clear_error(&err);
+    else
+        main_opts.name_resolv = boolean;
+
    main_opts.link_mode = HCI_LM_ACCEPT;
 
    main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
@@ -304,6 +311,7 @@ static void init_defaults(void)
    main_opts.discovto    = HCID_DEFAULT_DISCOVERABLE_TIMEOUT;
    main_opts.remember_powered = TRUE;
    main_opts.reverse_sdp = TRUE;
+    main_opts.name_resolv = TRUE;
 
    if (gethostname(main_opts.host_name, sizeof(main_opts.host_name) - 

1) < 0)

        strcpy(main_opts.host_name, "noname");
src/main.conf +0 -0
index c736e49..4f70a2c 100644
@@ -46,3 +46,7 @@ RememberPowered = true

# doesn't like us doing reverse SDP for some test cases (though there could in

# theory be other useful purposes for this too). Defaults to true.
ReverseServiceDiscovery = true
+
+# Enable name resolving after inquiry. Set it to 'false' if you don't need
+# remote devices name and want shorter discovery cycle. Default is 'true'
+NameResolving = true
#4 lore raw

PATCH 1/1 Add NameResolving option to main.conf

Patch adds new option to main.conf - NameResolving. If NameResolving=false then we don't ask remote devices for their names after inquiry. Default value is true.

---
 src/adapter.c |    9 ++++++---
 src/hcid.h    |    1 +
 src/main.c    |    8 ++++++++
 src/main.conf |    4 ++++
 4 files changed, 19 insertions(+), 3 deletions(-)
src/adapter.c +6 -3
index 977e507..a54078c 100644
@@ -1076,7 +1076,8 @@ static int start_inquiry(struct btd_adapter *adapter)
 
 	hci_close_dev(dd);
 
-	adapter->state |= RESOLVE_NAME;
+	if (main_opts.name_resolv)
+		adapter->state |= RESOLVE_NAME;
 
 	return 0;
 }
@@ -1126,7 +1127,8 @@ static int start_periodic_inquiry(struct btd_adapter *adapter)
 
 	hci_close_dev(dd);
 
-	adapter->state |= RESOLVE_NAME;
+	if (main_opts.name_resolv)
+		adapter->state |= RESOLVE_NAME;
 
 	return 0;
 }
@@ -2446,7 +2448,8 @@ struct btd_adapter *adapter_create(DBusConnection *conn, int id,
 	}
 
 	adapter->dev_id = id;
-	adapter->state |= RESOLVE_NAME;
+	if (main_opts.name_resolv)
+		adapter->state |= RESOLVE_NAME;
 	adapter->path = g_strdup(path);
 	adapter->already_up = devup;
 
src/hcid.h +1 -0
index 6e618a8..4fbbef1 100644
@@ -59,6 +59,7 @@ struct main_opts {
 	uint16_t	link_policy;
 	gboolean	remember_powered;
 	gboolean	reverse_sdp;
+	gboolean	name_resolv;
 
 	uint8_t		scan;
 	uint8_t		mode;
src/main.c +8 -0
index d7bb399..0467fe1 100644
@@ -187,6 +187,13 @@ static void parse_config(GKeyFile *config)
 	} else
 		main_opts.reverse_sdp = boolean;
 
+	boolean = g_key_file_get_boolean(config, "General",
+						"NameResolving", &err);
+	if (err)
+		g_clear_error(&err);
+	else
+		main_opts.name_resolv = boolean;
+
 	main_opts.link_mode = HCI_LM_ACCEPT;
 
 	main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
@@ -304,6 +311,7 @@ static void init_defaults(void)
 	main_opts.discovto	= HCID_DEFAULT_DISCOVERABLE_TIMEOUT;
 	main_opts.remember_powered = TRUE;
 	main_opts.reverse_sdp = TRUE;
+	main_opts.name_resolv = TRUE;
 
 	if (gethostname(main_opts.host_name, sizeof(main_opts.host_name) - 1) < 0)
 		strcpy(main_opts.host_name, "noname");
src/main.conf +4 -0
index c736e49..b252a82 100644
@@ -46,3 +46,7 @@ RememberPowered = true
 # doesn't like us doing reverse SDP for some test cases (though there could in
 # theory be other useful purposes for this too). Defaults to true.
 ReverseServiceDiscovery = true
+
+# Enable name resolving after inquiry. Set it to 'false' if you don't need
+# remote devices name and want shorter discovery cycle. Defaults to 'true'.
+NameResolving = true
Signature · 1 line
1.6.0.4
maintainer
#5 lore raw

Re: [PATCH] Add NameResolving option to main.conf

Hi Ilya,

Quoted 1 line

Patch adds new option to main.conf - NameResolving. If NameResolving=false then we don't ask remote devices for their names after inquiry. Default value is true.

patch been applied. However even for the commit message, please don't use more than 72 characters per row.

Regards

Marcel