summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-23 12:43:19 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-23 12:43:19 +0000
commit9069c486ecd182ce5c5095f45c9748b175b36f1f (patch)
treef927d993634f3a13d9833cce478ddc27069b3d46
parent3960b7affa107530a67baf695febf12e15600865 (diff)
Update device options before forking
-rw-r--r--hcid/main.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/hcid/main.c b/hcid/main.c
index 3f43c067..5ba69bac 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -127,7 +127,7 @@ static inline struct device_opts *find_device_opts(char *ref)
return NULL;
}
-static struct device_opts *get_device_opts(int sock, int hdev)
+static struct device_opts *get_device_opts(int hdev)
{
struct device_opts *device_opts = NULL;
struct hci_dev_info di;
@@ -296,6 +296,27 @@ static void configure_device(int dev_id)
char mode[14];
int dd;
+ device_opts = get_device_opts(dev_id);
+
+ /* Set default discoverable timeout if not set */
+ if (!(device_opts->flags & (1 << HCID_SET_DISCOVTO)))
+ device_opts->discovto = HCID_DEFAULT_DISCOVERABLE_TIMEOUT;
+
+ /* Set scan mode */
+ if (!read_device_mode(&di.bdaddr, mode, sizeof(mode))) {
+ if (!strcmp(mode, MODE_OFF) && hcid.offmode == HCID_OFFMODE_NOSCAN)
+ device_opts->scan = SCAN_DISABLED;
+ else if (!strcmp(mode, MODE_CONNECTABLE))
+ device_opts->scan = SCAN_PAGE;
+ else if (!strcmp(mode, MODE_DISCOVERABLE)) {
+ /* Set discoverable only if timeout is 0 */
+ if (!get_discoverable_timeout(dev_id))
+ device_opts->scan = SCAN_PAGE | SCAN_INQUIRY;
+ else
+ device_opts->scan = SCAN_PAGE;
+ }
+ }
+
/* Do configuration in the separate process */
switch (fork()) {
case 0:
@@ -311,7 +332,7 @@ static void configure_device(int dev_id)
if (dd < 0) {
error("Can't open device hci%d: %s (%d)",
dev_id, strerror(errno), errno);
- exit(1);
+ return;
}
if (hci_devinfo(dev_id, &di) < 0)
@@ -323,27 +344,6 @@ static void configure_device(int dev_id)
memset(&dr, 0, sizeof(dr));
dr.dev_id = dev_id;
- device_opts = get_device_opts(dd, dev_id);
-
- /* Set default discoverable timeout if not set */
- if (!(device_opts->flags & (1 << HCID_SET_DISCOVTO)))
- device_opts->discovto = HCID_DEFAULT_DISCOVERABLE_TIMEOUT;
-
- /* Set scan mode */
- if (!read_device_mode(&di.bdaddr, mode, sizeof(mode))) {
- if (!strcmp(mode, MODE_OFF) && hcid.offmode == HCID_OFFMODE_NOSCAN)
- device_opts->scan = SCAN_DISABLED;
- else if (!strcmp(mode, MODE_CONNECTABLE))
- device_opts->scan = SCAN_PAGE;
- else if (!strcmp(mode, MODE_DISCOVERABLE)) {
- /* Set discoverable only if timeout is 0 */
- if (!get_discoverable_timeout(dev_id))
- device_opts->scan = SCAN_PAGE | SCAN_INQUIRY;
- else
- device_opts->scan = SCAN_PAGE;
- }
- }
-
/* Set packet type */
if ((device_opts->flags & (1 << HCID_SET_PTYPE))) {
dr.dev_opt = device_opts->pkt_type;