1 /* 2 * Copyright (C) 2011-2012 Free Software Foundation, Inc. 3 * 4 * This file is part of GnuTLS. 5 * 6 * GnuTLS is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * GnuTLS is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef GNUTLS_SRC_INLINE_CMDS_H 21 #define GNUTLS_SRC_INLINE_CMDS_H 22 23 /* 24 * The inline commands is a facility that can be used optionally 25 * when --inline-commands is set during invocation of gnutls-cli 26 * to send inline commands at any time while a secure connection 27 * between the client and server is active. This is especially 28 * useful when the HTTPS connection is (HTTP) persistent - 29 * inline commands can be issued between HTTP requests, ex: GET. 30 * session renegotiation and session resumption can be issued 31 * inline between GET requests. 32 * 33 * Following inline commands are currently supported: 34 * ^resume^ - perform session resumption (similar to option -r) 35 * ^renegotiate^ - perform session renegotiation (similar to option -e) 36 * 37 * inline-commands-prefix is an additional option that can be set 38 * from gnutls-cli to change the default prefix (^) of inline commands. 39 * This option is only relevant if inline-commands option is enabled. 40 * This option expects a single US-ASCII character (octets 0 - 127). 41 * For ex: if --inline-commands-prefix=@, the inline commands will be 42 * @resume@, @renegotiate@, etc... 43 */ 44 typedef enum INLINE_COMMAND { INLINE_COMMAND_NONE, 45 INLINE_COMMAND_RESUME, 46 INLINE_COMMAND_RENEGOTIATE, 47 INLINE_COMMAND_REKEY_LOCAL, 48 INLINE_COMMAND_REKEY_BOTH 49 } inline_command_t; 50 51 #define MAX_INLINE_COMMAND_BYTES 20 52 53 typedef struct inline_cmds { 54 char *current_ptr; /* points to the start of the current buffer being processed */ 55 char *new_buffer_ptr; /* points to start or offset within the caller's buffer, 56 * and refers to bytes yet to be processed. */ 57 inline_command_t cmd_found; 58 int lf_found; 59 int bytes_to_flush; 60 ssize_t bytes_copied; 61 char inline_cmd_buffer[MAX_INLINE_COMMAND_BYTES]; 62 } inline_cmds_st; 63 64 65 struct inline_command_definitions { 66 int command; 67 char string[MAX_INLINE_COMMAND_BYTES]; 68 }; 69 70 /* All inline commands will contain a trailing LF */ 71 struct inline_command_definitions inline_commands_def[] = { 72 {INLINE_COMMAND_RESUME, "^resume^\n"}, 73 {INLINE_COMMAND_REKEY_LOCAL, "^rekey1^\n"}, 74 {INLINE_COMMAND_REKEY_BOTH, "^rekey^\n"}, 75 {INLINE_COMMAND_RENEGOTIATE, "^renegotiate^\n"}, 76 }; 77 78 #define NUM_INLINE_COMMANDS ((unsigned)(sizeof(inline_commands_def)/sizeof(inline_commands_def[0]))) 79 80 #endif /* GNUTLS_SRC_INLINE_CMDS_H */ 81