From: Sjur Brændeland <[email protected]>
---
plugins/modem.conf | 5 +++++
plugins/modemconf.c | 1 +
plugins/ste.c | 20 +++++++++++++++++++-
3 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/plugins/modem.conf b/plugins/modem.conf
index 66bf932..b577114 100644
--- a/plugins/modem.conf
+++ b/plugins/modem.conf
@@ -44,3 +44,8 @@
#[n900]
#Driver=n900modem
#Interface=phonet0
+
+# Sample STE modem
+#[ste]
+#Interface=cfttyS0
+#Driver=ste
diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 3747cd9..d7b1354 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -138,6 +138,7 @@ static struct {
{ "g1", set_device },
{ "wavecom", set_device },
{ "ste", set_device },
+ { "ste", set_interface },
{ "calypso", set_device },
{ "palmpre", set_device },
{ "isimodem", set_interface },
diff --git a/plugins/ste.c b/plugins/ste.c
index 5a71945..e737bbb 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <net/if.h>
#include <glib.h>
#include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)
if (!device) {
struct sockaddr_caif addr;
int err;
+ const char *interface;
/* Create a CAIF socket for AT Service */
- fd = socket(AF_CAIF, SOCK_SEQPACKET, CAIFPROTO_AT);
+ fd = socket(AF_CAIF, SOCK_STREAM, CAIFPROTO_AT);
if (fd < 0) {
ofono_error("Failed to create CAIF socket for AT");
return -EIO;
}
+ /* Bind CAIF socket to specified interface */
+ interface = ofono_modem_get_string(modem, "Interface");
+ if (interface) {
+ struct ifreq ifreq;
+ memset(&ifreq, 0, sizeof(ifreq));
+ strcpy(ifreq.ifr_name, interface);
+ err = setsockopt(fd, SOL_SOCKET,
+ SO_BINDTODEVICE, &ifreq, sizeof(ifreq));
+ if (err < 0) {
+ ofono_error("Failed to bind caif socket "
+ "to interface");
+ close(fd);
+ return err;
+ }
+ }
+
memset(&addr, 0, sizeof(addr));
addr.family = AF_CAIF;
addr.u.at.type = CAIF_ATTYPE_PLAIN;
--
1.6.3.3
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono