summaryrefslogtreecommitdiff
path: root/package/supl/patches/patch-src_supl_c
diff options
context:
space:
mode:
Diffstat (limited to 'package/supl/patches/patch-src_supl_c')
-rw-r--r--package/supl/patches/patch-src_supl_c46
1 files changed, 46 insertions, 0 deletions
diff --git a/package/supl/patches/patch-src_supl_c b/package/supl/patches/patch-src_supl_c
new file mode 100644
index 000000000..26ab45b18
--- /dev/null
+++ b/package/supl/patches/patch-src_supl_c
@@ -0,0 +1,46 @@
+ - implement bind to device functionality
+--- trunk.orig/src/supl.c 2011-10-27 20:41:19.000000000 +0200
++++ trunk/src/supl.c 2013-04-24 18:56:17.742529773 +0200
+@@ -41,7 +41,7 @@ static struct supl_debug_s {
+ } debug;
+ #endif
+
+-static int server_connect(char *server);
++static int server_connect(char *server, char *iface);
+ static int pdu_make_ulp_start(supl_ctx_t *ctx, supl_ulp_t *pdu);
+ static int pdu_make_ulp_pos_init(supl_ctx_t *ctx, supl_ulp_t *pdu);
+ static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp);
+@@ -236,7 +236,7 @@ int EXPORT supl_server_connect(supl_ctx_
+ if (!ctx->ssl) return E_SUPL_CONNECT;
+
+ if (server) {
+- ctx->fd = server_connect(server);
++ ctx->fd = server_connect(server, ctx->iface);
+ if (ctx->fd == -1) return E_SUPL_CONNECT;
+ }
+
+@@ -266,7 +266,7 @@ void EXPORT supl_close(supl_ctx_t *ctx)
+ }
+
+
+-static int server_connect(char *server) {
++static int server_connect(char *server, char *iface) {
+ int fd = -1;
+ struct addrinfo *ailist, *aip;
+ struct addrinfo hint;
+@@ -283,6 +283,15 @@ static int server_connect(char *server)
+ if ((fd = socket(aip->ai_family, SOCK_STREAM, 0)) < 0) {
+ err = errno;
+ }
++
++ if (strlen(iface)) {
++ struct ifreq ifr;
++ strncpy(ifr.ifr_name, iface, IFNAMSIZ);
++ ifr.ifr_name[IFNAMSIZ - 1] = 0;
++ if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)))
++ fprintf(stderr, "Error: binding to device %s failed\n", iface);
++ }
++
+ if (connect(fd, aip->ai_addr, aip->ai_addrlen) != 0) {
+ return -1;
+ }