if (!dsid)
return -ENOENT;
- if (vpninfo->tncc_fd != -1) {
+ if (vpninfo->tncc_fd >= 0) {
/* update TNCC once we get a DSID cookie */
oncp_send_tncc_command(vpninfo, 0);
}
int dtls_fd, ret;
/* Sanity check for the removal of new_dtls_{fd,ssl} */
- if (vpninfo->dtls_fd != -1) {
+ if (vpninfo->dtls_fd >= 0) {
vpn_progress(vpninfo, PRG_ERR, _("DTLS connection attempted with an existing fd\n"));
vpninfo->dtls_attempt_period = 0;
return -EINVAL;
reserve some extra space to handle that */
int receive_mtu = MAX(2048, vpninfo->ip_info.mtu + 256);
- while (readable && vpninfo->dtls_fd != -1) {
+ while (readable && vpninfo->dtls_fd >= 0) {
int len = receive_mtu + vpninfo->pkt_trailer;
int i;
struct pkt *pkt;
openconnect_close_https(vpninfo, 1);
if (vpninfo->proto->udp_shutdown)
vpninfo->proto->udp_shutdown(vpninfo);
- if (vpninfo->tncc_fd != -1)
+ if (vpninfo->tncc_fd >= 0)
closesocket(vpninfo->tncc_fd);
- if (vpninfo->cmd_fd_write != -1) {
+ if (vpninfo->cmd_fd_write >= 0) {
closesocket(vpninfo->cmd_fd);
closesocket(vpninfo->cmd_fd_write);
}
_("RX: %"PRIu64" packets (%"PRIu64" B); TX: %"PRIu64" packets (%"PRIu64" B)\n"),
stats->rx_pkts, stats->rx_bytes, stats->tx_pkts, stats->tx_bytes);
- if (vpninfo->ssl_fd != -1)
+ if (vpninfo->ssl_fd >= 0)
vpn_progress(vpninfo, PRG_INFO, _("SSL ciphersuite: %s\n"), openconnect_get_cstp_cipher(vpninfo));
if (vpninfo->dtls_state == DTLS_CONNECTED)
vpn_progress(vpninfo, PRG_INFO, _("%s ciphersuite: %s\n"),
vpninfo->reconnect_timeout = reconnect_timeout;
vpninfo->reconnect_interval = reconnect_interval;
- if (vpninfo->cmd_fd != -1) {
+ if (vpninfo->cmd_fd >= 0) {
monitor_fd_new(vpninfo, cmd);
monitor_read_fd(vpninfo, cmd);
}
while ((this = dequeue_packet(&vpninfo->incoming_queue)))
free_pkt(vpninfo, this);
#ifdef HAVE_VHOST
- } else if (vpninfo->vhost_fd != -1) {
+ } else if (vpninfo->vhost_fd >= 0) {
did_work += vhost_tun_mainloop(vpninfo, &timeout, vhost_r, did_work);
/* If it returns zero *then* it will have read the eventfd
* and there's no need to do so again until we poll again. */
/* If we're still attempting DTLS, do nothing yet. */
switch (vpninfo->dtls_state) {
case DTLS_ESTABLISHED:
- if (vpninfo->ssl_fd != -1) {
+ if (vpninfo->ssl_fd >= 0) {
openconnect_close_https(vpninfo, 0); /* don't keep stale HTTPS socket */
vpn_progress(vpninfo, PRG_INFO,
_("DTLS tunnel connected; exiting HTTPS mainloop.\n"));
* gets invoked. When f5_connect() actually establishes the tunnel,
* it does so to start the PPP state machine for the TCP connection.
*/
- if (vpninfo->ssl_fd != -1 && vpninfo->ppp->ppp_state != PPPS_DEAD)
+ if (vpninfo->ssl_fd >= 0 && vpninfo->ppp->ppp_state != PPPS_DEAD)
return ppp_mainloop(vpninfo, 0, &vpninfo->ssl_times, timeout, readable);
/* This will call *back* into the protocol's ->tcp_connect()
int pulse_bye(struct openconnect_info *vpninfo, const char *reason)
{
int ret = -1;
- if (vpninfo->ssl_fd != -1) {
+ if (vpninfo->ssl_fd >= 0) {
struct oc_text_buf *buf = buf_alloc();
buf_append_ift_hdr(buf, VENDOR_JUNIPER, 0x89);
if (!buf_error(buf))
void cmd_fd_set(struct openconnect_info *vpninfo, fd_set *fds, int *maxfd)
{
- if (vpninfo->cmd_fd != -1) {
+ if (vpninfo->cmd_fd >= 0) {
FD_SET(vpninfo->cmd_fd, fds);
if (vpninfo->cmd_fd > *maxfd)
*maxfd = vpninfo->cmd_fd;
{
set_fd_cloexec(tun_fd);
- if (vpninfo->tun_fd != -1)
+ if (vpninfo->tun_fd >= 0)
unmonitor_fd(vpninfo, tun);
vpninfo->tun_fd = tun_fd;
#ifdef __sun__
close(vpninfo->ip_fd);
vpninfo->ip_fd = -1;
- if (vpninfo->ip6_fd != -1) {
+ if (vpninfo->ip6_fd >= 0) {
close(vpninfo->ip6_fd);
vpninfo->ip6_fd = -1;
}
void shutdown_vhost(struct openconnect_info *vpninfo)
{
- if (vpninfo->vhost_fd != -1)
+ if (vpninfo->vhost_fd >= 0)
close(vpninfo->vhost_fd);
- if (vpninfo->vhost_kick_fd != -1)
+ if (vpninfo->vhost_kick_fd >= 0)
close(vpninfo->vhost_kick_fd);
- if (vpninfo->vhost_call_fd != -1)
+ if (vpninfo->vhost_call_fd >= 0)
close(vpninfo->vhost_call_fd);
vpninfo->vhost_fd = vpninfo->vhost_kick_fd = vpninfo->vhost_call_fd = -1;