[PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.

2010-08-17 Thread Sjur Brændeland
---
 plugins/ste.c |   20 +++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 16ddbe1..479d85c 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
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.

2010-08-17 Thread Marcel Holtmann
Hi Sjur,

 ---
  plugins/ste.c |   20 +++-
  1 files changed, 19 insertions(+), 1 deletions(-)

patch has been applied. Thanks.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono