scp_common.h
Go to the documentation of this file.
1 /**
2  * @file scp_common.h
3  * @brief Definitions common to SCP client and server
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSSH Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _SCP_COMMON_H
32 #define _SCP_COMMON_H
33 
34 //Dependencies
35 #include "ssh/ssh.h"
36 
37 //File permissions
38 #define SCP_MODE_IXOTH 0x0001
39 #define SCP_MODE_IWOTH 0x0002
40 #define SCP_MODE_IROTH 0x0004
41 #define SCP_MODE_IRWXO 0x0007
42 #define SCP_MODE_IXGRP 0x0008
43 #define SCP_MODE_IWGRP 0x0010
44 #define SCP_MODE_IRGRP 0x0020
45 #define SCP_MODE_IRWXG 0x0038
46 #define SCP_MODE_IXUSR 0x0040
47 #define SCP_MODE_IWUSR 0x0080
48 #define SCP_MODE_IRUSR 0x0100
49 #define SCP_MODE_IRWXU 0x01C0
50 
51 //C++ guard
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 
57 /**
58  * @brief SCP directive opcodes
59  **/
60 
61 typedef enum
62 {
69  SCP_OPCODE_TIME = 84
71 
72 
73 /**
74  * @brief SCP directive parameters
75  **/
76 
77 typedef struct
78 {
80  uint32_t mode;
81  uint64_t size;
82  uint32_t mtime;
83  uint32_t atime;
84  const char_t *filename;
85  const char_t *message;
86 } ScpDirective;
87 
88 
89 //SCP related functions
90 size_t scpFormatDirective(const ScpDirective *directive, char_t *buffer);
91 error_t scpParseDirective(const char_t *buffer, ScpDirective *directive);
92 
93 //C++ guard
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif
char char_t
Definition: compiler_port.h:48
error_t
Error codes.
Definition: error.h:43
size_t scpFormatDirective(const ScpDirective *directive, char_t *buffer)
Format SCP directive.
Definition: scp_common.c:48
error_t scpParseDirective(const char_t *buffer, ScpDirective *directive)
Parse SCP directive.
Definition: scp_common.c:127
ScpOpcode
SCP directive opcodes.
Definition: scp_common.h:62
@ SCP_OPCODE_END
Definition: scp_common.h:68
@ SCP_OPCODE_WARNING
Definition: scp_common.h:64
@ SCP_OPCODE_OK
Definition: scp_common.h:63
@ SCP_OPCODE_TIME
Definition: scp_common.h:69
@ SCP_OPCODE_ERROR
Definition: scp_common.h:65
@ SCP_OPCODE_DIR
Definition: scp_common.h:67
@ SCP_OPCODE_FILE
Definition: scp_common.h:66
Secure Shell (SSH)
SCP directive parameters.
Definition: scp_common.h:78
const char_t * filename
Definition: scp_common.h:84
uint32_t mtime
Definition: scp_common.h:82
uint32_t atime
Definition: scp_common.h:83
uint32_t mode
Definition: scp_common.h:80
ScpOpcode opcode
Definition: scp_common.h:79
const char_t * message
Definition: scp_common.h:85
uint64_t size
Definition: scp_common.h:81