aboutsummaryrefslogtreecommitdiff
path: root/src/jail_protocol.h
diff options
context:
space:
mode:
authorlns <matzeton@googlemail.com>2018-07-16 19:32:30 +0200
committerlns <matzeton@googlemail.com>2018-07-16 19:32:30 +0200
commit486645a1b6ed3a12c938201e7729b4aeed5e1f93 (patch)
tree254add30efceb206b88317835599f6bdc6ea62a6 /src/jail_protocol.h
parent05706e63b0a4daf83167e159402207fefd1ca65d (diff)
added skeleton code for a complex jail protocol (instead of a raw tcp2pty communication)
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'src/jail_protocol.h')
-rw-r--r--src/jail_protocol.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/jail_protocol.h b/src/jail_protocol.h
new file mode 100644
index 0000000..fee2ef8
--- /dev/null
+++ b/src/jail_protocol.h
@@ -0,0 +1,46 @@
+#ifndef POTD_JAIL_PROTOCOL_H
+#define POTD_JAIL_PROTOCOL_H 1
+
+#include <stdlib.h>
+#include <stdint.h>
+
+#include "jail.h"
+#include "pevent.h"
+
+#define USER_LEN 255
+#define PASS_LEN 255
+
+#define PROTO_MAGIC 0xdeadc0de
+#define PROTO_TYPE_EHLO 0xcafebabe
+#define PROTO_TYPE_USER 0x41414141
+#define PROTO_TYPE_PASS 0x42424242
+#define PROTO_TYPE_DATA 0x43434343
+
+typedef struct __attribute__((packed, aligned(4))) jail_data {
+ int used;
+ char user[USER_LEN+1];
+ char pass[PASS_LEN+1];
+} jail_data;
+
+typedef struct jail_protocol_hdr {
+ uint32_t magic;
+ uint32_t type;
+ uint32_t size;
+} jail_protocol_hdr;
+
+
+ssize_t jail_protocol_readhdr(jail_data *dst, unsigned char *buf,
+ size_t bufsiz);
+
+ssize_t jail_protocol_writehdr(jail_protocol_hdr *hdr, int type,
+ unsigned char *buf, size_t bufsiz);
+
+int jail_protocol_handshake_read(event_ctx *ev_client, int client_fd,
+ int tty_fd, jail_data *dst);
+
+int jail_protocol_handshake_write(event_ctx *ev_server, int server_fd,
+ int proto_fd, jail_data *dst);
+
+int jail_protocol_loop(event_ctx *ctx, on_event_cb on_event, void *user_data);
+
+#endif