|
Packit |
549fdc |
/*
|
|
Packit |
549fdc |
* Copyright (C) 2011-2012 Free Software Foundation, Inc.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* This file is part of GnuTLS.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* GnuTLS is free software: you can redistribute it and/or modify
|
|
Packit |
549fdc |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
549fdc |
* the Free Software Foundation, either version 3 of the License, or
|
|
Packit |
549fdc |
* (at your option) any later version.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* GnuTLS is distributed in the hope that it will be useful,
|
|
Packit |
549fdc |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
549fdc |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
549fdc |
* GNU General Public License for more details.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* You should have received a copy of the GNU General Public License
|
|
Packit |
549fdc |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
549fdc |
*/
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
/*
|
|
Packit |
549fdc |
* The inline commands is a facility that can be used optionally
|
|
Packit |
549fdc |
* when --inline-commands is set during invocation of gnutls-cli
|
|
Packit |
549fdc |
* to send inline commands at any time while a secure connection
|
|
Packit |
549fdc |
* between the client and server is active. This is especially
|
|
Packit |
549fdc |
* useful when the HTTPS connection is (HTTP) persistent -
|
|
Packit |
549fdc |
* inline commands can be issued between HTTP requests, ex: GET.
|
|
Packit |
549fdc |
* session renegotiation and session resumption can be issued
|
|
Packit |
549fdc |
* inline between GET requests.
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* Following inline commands are currently supported:
|
|
Packit |
549fdc |
* ^resume^ - perform session resumption (similar to option -r)
|
|
Packit |
549fdc |
* ^renegotiate^ - perform session renegotiation (similar to option -e)
|
|
Packit |
549fdc |
*
|
|
Packit |
549fdc |
* inline-commands-prefix is an additional option that can be set
|
|
Packit |
549fdc |
* from gnutls-cli to change the default prefix (^) of inline commands.
|
|
Packit |
549fdc |
* This option is only relevant if inline-commands option is enabled.
|
|
Packit |
549fdc |
* This option expects a single US-ASCII character (octets 0 - 127).
|
|
Packit |
549fdc |
* For ex: if --inline-commands-prefix=@, the inline commands will be
|
|
Packit |
549fdc |
* @resume@, @renegotiate@, etc...
|
|
Packit |
549fdc |
*/
|
|
Packit |
549fdc |
typedef enum INLINE_COMMAND { INLINE_COMMAND_NONE,
|
|
Packit |
549fdc |
INLINE_COMMAND_RESUME,
|
|
Packit |
549fdc |
INLINE_COMMAND_RENEGOTIATE
|
|
Packit |
549fdc |
} inline_command_t;
|
|
Packit |
549fdc |
#define NUM_INLINE_COMMANDS 2
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#define MAX_INLINE_COMMAND_BYTES 20
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
typedef struct inline_cmds {
|
|
Packit |
549fdc |
char *current_ptr; /* points to the start of the current buffer being processed */
|
|
Packit |
549fdc |
char *new_buffer_ptr; /* points to start or offset within the caller's buffer,
|
|
Packit |
549fdc |
* and refers to bytes yet to be processed. */
|
|
Packit |
549fdc |
inline_command_t cmd_found;
|
|
Packit |
549fdc |
int lf_found;
|
|
Packit |
549fdc |
int bytes_to_flush;
|
|
Packit |
549fdc |
ssize_t bytes_copied;
|
|
Packit |
549fdc |
char inline_cmd_buffer[MAX_INLINE_COMMAND_BYTES];
|
|
Packit |
549fdc |
} inline_cmds_st;
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
struct inline_command_definitions {
|
|
Packit |
549fdc |
int command;
|
|
Packit |
549fdc |
char string[MAX_INLINE_COMMAND_BYTES];
|
|
Packit |
549fdc |
};
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
/* All inline commands will contain a trailing LF */
|
|
Packit |
549fdc |
struct inline_command_definitions inline_commands_def[] = {
|
|
Packit |
549fdc |
{INLINE_COMMAND_RESUME, "^resume^\n"},
|
|
Packit |
549fdc |
{INLINE_COMMAND_RENEGOTIATE, "^renegotiate^\n"},
|
|
Packit |
549fdc |
};
|