summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-09-11 23:11:11 +0200
committerMarcel Holtmann <marcel@holtmann.org>2008-09-11 23:11:11 +0200
commita3fbc8a1d14cd97eb9d59db2fcf9ce9fd4c64ec7 (patch)
tree60c89809992bb11cb55c64901be1a5c806a5bdd2 /src
parent151046c5165860ddea6e84498cc0a0e191de1c40 (diff)
Move link mode and policy setting before bringing up the device
Diffstat (limited to 'src')
-rw-r--r--src/main.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/main.c b/src/main.c
index cba908f7..3acc41d4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,8 +66,6 @@ enum {
HCID_SET_CLASS,
HCID_SET_PAGETO,
HCID_SET_DISCOVTO,
- HCID_SET_LM,
- HCID_SET_LP,
};
struct main_opts main_opts;
@@ -183,11 +181,9 @@ static void parse_config(GKeyFile *config)
}
main_opts.link_mode = HCI_LM_ACCEPT;
- main_opts.flags |= (1 << HCID_SET_LM);
main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
HCI_LP_HOLD | HCI_LP_PARK;
- main_opts.flags |= (1 << HCID_SET_LP);
}
static void update_service_classes(const bdaddr_t *bdaddr, uint8_t value)
@@ -332,7 +328,6 @@ static void at_child_exit(void)
static void configure_device(int dev_id)
{
- struct hci_dev_req dr;
struct hci_dev_info di;
pid_t pid;
int dd;
@@ -364,27 +359,6 @@ static void configure_device(int dev_id)
exit(1);
}
- memset(&dr, 0, sizeof(dr));
- dr.dev_id = dev_id;
-
- /* Set link mode */
- if ((main_opts.flags & (1 << HCID_SET_LM))) {
- dr.dev_opt = main_opts.link_mode;
- if (ioctl(dd, HCISETLINKMODE, (unsigned long) &dr) < 0) {
- error("Can't set link mode on hci%d: %s (%d)",
- dev_id, strerror(errno), errno);
- }
- }
-
- /* Set link policy */
- if ((main_opts.flags & (1 << HCID_SET_LP))) {
- dr.dev_opt = main_opts.link_policy;
- if (ioctl(dd, HCISETLINKPOL, (unsigned long) &dr) < 0) {
- error("Can't set link policy on hci%d: %s (%d)",
- dev_id, strerror(errno), errno);
- }
- }
-
/* Set device name */
if ((main_opts.flags & (1 << HCID_SET_NAME)) && main_opts.name) {
change_local_name_cp cp;
@@ -432,6 +406,7 @@ static void configure_device(int dev_id)
static void init_device(int dev_id)
{
+ struct hci_dev_req dr;
struct hci_dev_info di;
pid_t pid;
int dd;
@@ -457,6 +432,23 @@ static void init_device(int dev_id)
exit(1);
}
+ memset(&dr, 0, sizeof(dr));
+ dr.dev_id = dev_id;
+
+ /* Set link mode */
+ dr.dev_opt = main_opts.link_mode;
+ if (ioctl(dd, HCISETLINKMODE, (unsigned long) &dr) < 0) {
+ error("Can't set link mode on hci%d: %s (%d)",
+ dev_id, strerror(errno), errno);
+ }
+
+ /* Set link policy */
+ dr.dev_opt = main_opts.link_policy;
+ if (ioctl(dd, HCISETLINKPOL, (unsigned long) &dr) < 0) {
+ error("Can't set link policy on hci%d: %s (%d)",
+ dev_id, strerror(errno), errno);
+ }
+
/* Start HCI device */
if (ioctl(dd, HCIDEVUP, dev_id) < 0 && errno != EALREADY) {
error("Can't init device hci%d: %s (%d)",