diff options
author | Denis Kenzior <denkenz@gmail.com> | 2013-02-13 20:40:30 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2013-02-14 08:47:10 -0600 |
commit | 7ba9521f102b39e64c2584d9b063367d39240fc3 (patch) | |
tree | 6b2aeef6aea251b91354f287149ef7a5f7837a60 /plugins/hfp_hf_bluez5.c | |
parent | 83b43c8abdafdb9ad4b5dc7fa2d62ff537eab93c (diff) | |
download | ofono-7ba9521f102b39e64c2584d9b063367d39240fc3.tar.bz2 |
hfp_hf_bluez5: Ensure active SLC for SCO links
Whenever a SCO connection is attempted, ensure that the SLC link is
already active between us and the same remote peer.
Diffstat (limited to 'plugins/hfp_hf_bluez5.c')
-rw-r--r-- | plugins/hfp_hf_bluez5.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c index 6de5065e..5de61880 100644 --- a/plugins/hfp_hf_bluez5.c +++ b/plugins/hfp_hf_bluez5.c @@ -434,12 +434,28 @@ static const GDBusMethodTable profile_methods[] = { { } }; +static ofono_bool_t slc_match(struct ofono_modem *modem, void *userdata) +{ + const char *remote = userdata; + const char *value = ofono_modem_get_string(modem, "Remote"); + + if (value == NULL) + return FALSE; + + /* Make sure SLC has been established */ + if (ofono_modem_get_powered(modem) != TRUE) + return FALSE; + + return g_str_equal(remote, value); +} + static gboolean sco_accept(GIOChannel *io, GIOCondition cond, gpointer user_data) { struct sockaddr_sco saddr; socklen_t alen; int sk, nsk; + char remote[18]; if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) return FALSE; @@ -453,7 +469,13 @@ static gboolean sco_accept(GIOChannel *io, GIOCondition cond, if (nsk < 0) return TRUE; - /* TODO: Verify if the device has a modem */ + bt_ba2str(&saddr.sco_bdaddr, remote); + + if (ofono_modem_find(slc_match, remote) == NULL) { + ofono_error("Rejecting SCO: No SLC connection found!"); + close(nsk); + return TRUE; + } return TRUE; } |