diff options
author | Richard Levitte <levitte@openssl.org> | 2016-02-03 00:27:44 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-02-03 19:40:32 +0100 |
commit | d858c87653257185ead1c5baf3d84cd7276dd912 (patch) | |
tree | 88c6ea3d7634e2cd36e4d4910d5d7f81a32562fc /ssl/d1_lib.c | |
parent | 75d5bd4e7d61ba3ed845f9e8170eac6a48a26407 (diff) | |
download | openssl-d858c87653257185ead1c5baf3d84cd7276dd912.tar.gz |
Refactoring BIO: Adapt BIO_s_datagram and all that depends on it
The control commands that previously took a struct sockaddr * have
been changed to take a BIO_ADDR * instead.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'ssl/d1_lib.c')
-rw-r--r-- | ssl/d1_lib.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index 65e30f7132..3fde524ba8 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -75,7 +75,7 @@ static void get_current_time(struct timeval *t); static int dtls1_set_handshake_header(SSL *s, int type, unsigned long len); static int dtls1_handshake_write(SSL *s); -int dtls1_listen(SSL *s, struct sockaddr *client); +int dtls1_listen(SSL *s, BIO_ADDR *client); static unsigned int dtls1_link_min_mtu(void); /* XDTLS: figure out the right values */ @@ -484,7 +484,7 @@ static void get_current_time(struct timeval *t) #define LISTEN_SEND_VERIFY_REQUEST 1 -int dtls1_listen(SSL *s, struct sockaddr *client) +int dtls1_listen(SSL *s, BIO_ADDR *client) { int next, n, ret = 0, clearpkt = 0; unsigned char cookie[DTLS1_COOKIE_LENGTH]; @@ -495,7 +495,7 @@ int dtls1_listen(SSL *s, struct sockaddr *client) unsigned int rectype, versmajor, msgseq, msgtype, clientvers, cookielen; BIO *rbio, *wbio; BUF_MEM *bufm; - struct sockaddr_storage tmpclient; + BIO_ADDR *tmpclient = NULL; PACKET pkt, msgpkt, msgpayload, session, cookiepkt; /* Ensure there is no state left over from a previous invocation */ @@ -805,11 +805,14 @@ int dtls1_listen(SSL *s, struct sockaddr *client) * This is unneccessary if rbio and wbio are one and the same - but * maybe they're not. */ - if(BIO_dgram_get_peer(rbio, &tmpclient) <= 0 - || BIO_dgram_set_peer(wbio, &tmpclient) <= 0) { + if ((tmpclient = BIO_ADDR_new()) == NULL + || BIO_dgram_get_peer(rbio, tmpclient) <= 0 + || BIO_dgram_set_peer(wbio, tmpclient) <= 0) { SSLerr(SSL_F_DTLS1_LISTEN, ERR_R_INTERNAL_ERROR); goto end; } + BIO_ADDR_free(tmpclient); + tmpclient = NULL; if (BIO_write(wbio, buf, reclen) < (int)reclen) { if(BIO_should_retry(wbio)) { @@ -863,6 +866,7 @@ int dtls1_listen(SSL *s, struct sockaddr *client) ret = 1; clearpkt = 0; end: + BIO_ADDR_free(tmpclient); BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_PEEK_MODE, 0, NULL); if (clearpkt) { /* Dump this packet. Ignore return value */ |