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