Commit 8831000b authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

protocol handler: added flags field

The protocol handler struct got a 'flags' field for special information
and characteristics of the given protocol.

This now enables us to move away central protocol information such as
CLOSEACTION and DUALCHANNEL from single defines in a central place, out
to each protocol's definition. It also made us stop abusing the protocol
field for other info than the protocol, and we could start cleaning up
other protocol-specific things by adding flags bits to set in the
handler struct.

The "protocol" field connectdata struct was removed as well and the code
now refers directly to the conn->handler->protocol field instead. To
make things work properly, the code now always store a conn->given
pointer that points out the original handler struct so that the code can
learn details from the original protocol even if conn->handler is
modified along the way - for example when switching to go over a HTTP
proxy.
parent ed8749e3
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ const struct Curl_handler Curl_handler_rtmp = {
  ZERO_NULL,                            /* perform_getsock */
  rtmp_disconnect,                      /* disconnect */
  PORT_RTMP,                            /* defport */
  PROT_RTMP                             /* protocol */
  PROT_RTMP,                            /* protocol */
  PROTOPT_NONE                          /* flags*/
};

const struct Curl_handler Curl_handler_rtmpt = {
@@ -91,7 +92,8 @@ const struct Curl_handler Curl_handler_rtmpt = {
  ZERO_NULL,                            /* perform_getsock */
  rtmp_disconnect,                      /* disconnect */
  PORT_RTMPT,                           /* defport */
  PROT_RTMPT                            /* protocol */
  PROT_RTMPT,                           /* protocol */
  PROTOPT_NONE                          /* flags*/
};

const struct Curl_handler Curl_handler_rtmpe = {
@@ -108,7 +110,8 @@ const struct Curl_handler Curl_handler_rtmpe = {
  ZERO_NULL,                            /* perform_getsock */
  rtmp_disconnect,                      /* disconnect */
  PORT_RTMP,                            /* defport */
  PROT_RTMPE                            /* protocol */
  PROT_RTMPE,                           /* protocol */
  PROTOPT_NONE                          /* flags*/
};

const struct Curl_handler Curl_handler_rtmpte = {
@@ -125,7 +128,8 @@ const struct Curl_handler Curl_handler_rtmpte = {
  ZERO_NULL,                            /* perform_getsock */
  rtmp_disconnect,                      /* disconnect */
  PORT_RTMPT,                           /* defport */
  PROT_RTMPTE                           /* protocol */
  PROT_RTMPTE,                          /* protocol */
  PROTOPT_NONE                          /* flags*/
};

const struct Curl_handler Curl_handler_rtmps = {
@@ -142,7 +146,8 @@ const struct Curl_handler Curl_handler_rtmps = {
  ZERO_NULL,                            /* perform_getsock */
  rtmp_disconnect,                      /* disconnect */
  PORT_RTMPS,                           /* defport */
  PROT_RTMPS                            /* protocol */
  PROT_RTMPS,                           /* protocol */
  PROTOPT_NONE                          /* flags*/
};
const struct Curl_handler Curl_handler_rtmpts = {
  "RTMPTS",                             /* scheme */
@@ -158,7 +163,8 @@ const struct Curl_handler Curl_handler_rtmpts = {
  ZERO_NULL,                            /* perform_getsock */
  rtmp_disconnect,                      /* disconnect */
  PORT_RTMPS,                           /* defport */
  PROT_RTMPTS                           /* protocol */
  PROT_RTMPTS,                          /* protocol */
  PROTOPT_NONE                          /* flags*/
};

static CURLcode rtmp_setup(struct connectdata *conn)
+3 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -108,7 +108,8 @@ const struct Curl_handler Curl_handler_dict = {
  ZERO_NULL,                            /* perform_getsock */
  ZERO_NULL,                            /* disconnect */
  PORT_DICT,                            /* defport */
  PROT_DICT                             /* protocol */
  PROT_DICT,                            /* protocol */
  PROTOPT_NONE                          /* flags */
};

static char *unescape_word(struct SessionHandle *data, const char *inputbuff)
+2 −1
Original line number Diff line number Diff line
@@ -127,7 +127,8 @@ const struct Curl_handler Curl_handler_file = {
  ZERO_NULL,                            /* perform_getsock */
  ZERO_NULL,                            /* disconnect */
  0,                                    /* defport */
  PROT_FILE                             /* protocol */
  PROT_FILE,                            /* protocol */
  PROTOPT_BANPROXY                      /* flags */
};


+9 −6
Original line number Diff line number Diff line
@@ -179,7 +179,8 @@ const struct Curl_handler Curl_handler_ftp = {
  ZERO_NULL,                       /* perform_getsock */
  ftp_disconnect,                  /* disconnect */
  PORT_FTP,                        /* defport */
  PROT_FTP                         /* protocol */
  PROT_FTP,                        /* protocol */
  PROTOPT_DUAL | PROTOPT_CLOSEACTION /* flags */
};


@@ -202,7 +203,8 @@ const struct Curl_handler Curl_handler_ftps = {
  ZERO_NULL,                       /* perform_getsock */
  ftp_disconnect,                  /* disconnect */
  PORT_FTPS,                       /* defport */
  PROT_FTP | PROT_FTPS | PROT_SSL  /* protocol */
  PROT_FTP | PROT_FTPS,            /* protocol */
  PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION /* flags */
};
#endif

@@ -225,7 +227,8 @@ static const struct Curl_handler Curl_handler_ftp_proxy = {
  ZERO_NULL,                            /* perform_getsock */
  ZERO_NULL,                            /* disconnect */
  PORT_FTP,                             /* defport */
  PROT_HTTP                             /* protocol */
  PROT_HTTP,                            /* protocol */
  PROTOPT_NONE                          /* flags */
};


@@ -248,7 +251,8 @@ static const struct Curl_handler Curl_handler_ftps_proxy = {
  ZERO_NULL,                            /* perform_getsock */
  ZERO_NULL,                            /* disconnect */
  PORT_FTPS,                            /* defport */
  PROT_HTTP                             /* protocol */
  PROT_HTTP,                            /* protocol */
  PROTOPT_NONE                          /* flags */
};
#endif
#endif
@@ -2480,7 +2484,6 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
        /* Curl_ssl_connect is BLOCKING */
        result = Curl_ssl_connect(conn, FIRSTSOCKET);
        if(CURLE_OK == result) {
          conn->protocol |= PROT_FTPS;
          conn->ssl[SECONDARYSOCKET].use = FALSE; /* clear-text data */
          result = ftp_state_user(conn);
        }
@@ -2949,7 +2952,7 @@ static CURLcode ftp_connect(struct connectdata *conn,
  }
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_PROXY */

  if(conn->protocol & PROT_FTPS) {
  if(conn->handler->protocol & PROT_FTPS) {
    /* BLOCKING */
    /* FTPS is simply ftp with SSL for the control channel */
    /* now, perform the SSL initialization for this socket */
+3 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -113,7 +113,8 @@ const struct Curl_handler Curl_handler_gopher = {
  ZERO_NULL,                            /* perform_getsock */
  ZERO_NULL,                            /* disconnect */
  PORT_GOPHER,                          /* defport */
  PROT_GOPHER                           /* protocol */
  PROT_GOPHER,                          /* protocol */
  PROTOPT_NONE                          /* flags */
};

static CURLcode gopher_do(struct connectdata *conn, bool *done)
Loading