Created
September 13, 2012 09:11
-
-
Save kanru/3713093 to your computer and use it in GitHub Desktop.
Patch to build supl-proxy and fallback to non-TLS connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- trunk.old/config.mk 2011-10-25 19:41:31.000000000 +0000 | |
+++ trunk/config.mk 2012-06-07 02:37:28.000000000 +0000 | |
@@ -1,10 +1,10 @@ | |
-# Generated by ./configure script - Tue Oct 25 22:41:31 EEST 2011 | |
+# Generated by ./configure script - Thu Jun 7 02:37:27 UTC 2012 | |
# Modifications to this file are lost if ./configure is ran again. | |
CONF_VERSION = 1.0.5 | |
-CONF_CFLAGS = -Wall -O2 | |
+CONF_CFLAGS = -Wall -O2 -g | |
CONF_ASN_CFLAGS = | |
-CONF_PREFIX = /usr | |
+CONF_PREFIX = /usr/local | |
CONF_PRECOMPILED_ASN = yes | |
-CONF_SUPL_DEBUG = | |
+CONF_SUPL_DEBUG = -DSUPL_DEBUG | |
CONF_ASN1_SKELETONS = | |
--- trunk.old/src/Makefile 2011-10-17 18:09:22.000000000 +0000 | |
+++ trunk/src/Makefile 2012-06-07 02:39:04.000000000 +0000 | |
@@ -24,10 +24,10 @@ supl-client: libsupl.so supl-client.o | |
$(CC) -o $@ supl-client.o -L. -lsupl -lssl -lm | |
supl-proxy: libsupl.so supl-proxy.o | |
- $(CC) -o $@ supl-proxy.o -L. -lsupl -lssl -lm | |
+ $(CC) -o $@ supl-proxy.o -L. -lsupl -lssl -lm -lcrypto | |
supl-cert: supl-cert.o | |
- $(CC) -o $@ supl-cert.o $(shell pkg-config --libs openssl) -lm | |
+ $(CC) -o $@ supl-cert.o $(shell pkg-config --libs openssl) -lssl -lcrypto -lm | |
libsupl.so: libsupl.so.1.0 | |
ln -sf libsupl.so.1 libsupl.so | |
--- trunk.old/src/supl.c 2011-10-27 18:41:19.000000000 +0000 | |
+++ trunk/src/supl.c 2012-06-07 03:18:57.000000000 +0000 | |
@@ -107,7 +107,10 @@ int EXPORT supl_ulp_send(supl_ctx_t *ctx | |
} | |
#endif | |
- err = SSL_write(ctx->ssl, pdu->buffer, pdu->size); | |
+ if (ctx->ssl) | |
+ err = SSL_write(ctx->ssl, pdu->buffer, pdu->size); | |
+ else | |
+ err = write(ctx->fd, pdu->buffer, pdu->size); | |
if (err <= 0) { | |
#if SUPL_DEBUG | |
if (debug.debug) fprintf(debug.log, "Error: SSL_write error: %s\n", strerror(errno)); | |
@@ -129,7 +132,10 @@ int EXPORT supl_ulp_recv(supl_ctx_t *ctx | |
asn_dec_rval_t rval; | |
ULP_PDU_t *length; | |
- err = SSL_read(ctx->ssl, pdu->buffer, sizeof(pdu->buffer)); | |
+ if (ctx->ssl) | |
+ err = SSL_read(ctx->ssl, pdu->buffer, sizeof(pdu->buffer)); | |
+ else | |
+ err = read(ctx->fd, pdu->buffer, sizeof(pdu->buffer)); | |
if (err <= 0) { | |
#ifdef SUPL_DEBUG | |
if (debug.debug) fprintf(debug.log, "Error: SSL_read error: %s\n", strerror(errno)); | |
@@ -147,7 +153,10 @@ int EXPORT supl_ulp_recv(supl_ctx_t *ctx | |
#ifdef SUPL_DEBUG | |
if (debug.debug) fprintf(debug.log, "SSL_read got %u bytes (total %lu)\n", n, length->length); | |
#endif | |
- err = SSL_read(ctx->ssl, &pdu->buffer[n], sizeof(pdu->buffer)-n); | |
+ if (ctx->ssl) | |
+ err = SSL_read(ctx->ssl, &pdu->buffer[n], sizeof(pdu->buffer)-n); | |
+ else | |
+ err = read(ctx->fd, &pdu->buffer[n], sizeof(pdu->buffer)-n); | |
if (err <= 0) { | |
#ifdef SUPL_DEBUG | |
if (debug.debug) fprintf(debug.log, "Error: SSL_read (again) error: %s\n", strerror(errno)); | |
--- trunk.old/src/supl-proxy.c 2011-10-17 18:13:54.000000000 +0000 | |
+++ trunk/src/supl-proxy.c 2012-06-07 03:16:36.000000000 +0000 | |
@@ -19,6 +19,7 @@ | |
#include "supl.h" | |
#include "asn-supl/ULP-PDU.h" | |
+#include <openssl/err.h> | |
#define SUPL_PORT "7275" | |
@@ -34,6 +35,12 @@ static void ssl_error(SSL *ssl, int err) | |
if (err == -1) fprintf(stderr, " I/O error (%s)\n", strerror(errno)); | |
if (err == 0) fprintf(stderr, " SSL peer closed connection\n"); | |
} | |
+ if (ssl_err == SSL_ERROR_SSL) { | |
+ do { | |
+ ssl_err = ERR_get_error(); | |
+ fprintf(stderr, "%s\n", ERR_error_string(ssl_err, NULL)); | |
+ } while (ssl_err); | |
+ } | |
} | |
static int ssl_accept(int port, supl_ctx_t *client_ctx) { | |
@@ -111,6 +118,7 @@ static int ssl_accept(int port, supl_ctx | |
fprintf(stderr, "Connection from %s:%d\n", buffer, ntohs(sa_cli.sin_port)); | |
} | |
+#if 0 | |
/* ----------------------------------------------- */ | |
/* TCP connection is ready. Do server side SSL. */ | |
@@ -150,6 +158,9 @@ static int ssl_accept(int port, supl_ctx | |
client_ctx->ssl = ssl; | |
client_ctx->ssl_ctx = ctx; | |
+#endif | |
+ client_ctx->ssl = NULL; | |
+ client_ctx->fd = sd; | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment