Skip to content

Commit

Permalink
Portability fixes for Solaris, *BSD
Browse files Browse the repository at this point in the history
OpenBSD needs <sys/types.h> to be included before <netinet/in.h>.
Use IPPROTO_TCP not SOL_TCP for getsockopt() level.
Don't attempt to use FreeBSD's TCP_INFO sockopt.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jun 11, 2012
1 parent 80beecc commit ba4fd25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cstp.c
Expand Up @@ -32,9 +32,10 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <netinet/tcp.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>

#include <openssl/ssl.h>
#include <openssl/err.h>
Expand Down Expand Up @@ -110,12 +111,12 @@ static void calculate_mtu(struct openconnect_info *vpninfo, int *base_mtu, int *
*mtu = vpninfo->mtu;
*base_mtu = vpninfo->basemtu;

#ifdef TCP_INFO
#if defined(__linux__) && defined(TCP_INFO)
if (!*mtu || !*base_mtu) {
struct tcp_info ti;
socklen_t ti_size = sizeof(ti);

if (!getsockopt(vpninfo->ssl_fd, SOL_TCP, TCP_INFO,
if (!getsockopt(vpninfo->ssl_fd, IPPROTO_TCP, TCP_INFO,
&ti, &ti_size)) {
vpn_progress(vpninfo, PRG_TRACE,
_("TCP_INFO rcv mss %d, snd mss %d, adv mss %d, pmtu %d\n"),
Expand All @@ -134,7 +135,7 @@ static void calculate_mtu(struct openconnect_info *vpninfo, int *base_mtu, int *
if (!*mtu) {
int mss;
socklen_t mss_size = sizeof(mss);
if (!getsockopt(vpninfo->ssl_fd, SOL_TCP, TCP_MAXSEG,
if (!getsockopt(vpninfo->ssl_fd, IPPROTO_TCP, TCP_MAXSEG,
&mss, &mss_size)) {
vpn_progress(vpninfo, PRG_TRACE, _("TCP_MAXSEG %d\n"), mss);
*mtu = mss - 13;
Expand Down
1 change: 1 addition & 0 deletions openssl.c
Expand Up @@ -23,6 +23,7 @@
*/

#include <errno.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
Expand Down

0 comments on commit ba4fd25

Please sign in to comment.