blob: b608253b6e26c312d2b4be772926ce67d4ae2f1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#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_TIMEOUT 1000
#define PROTO_MAGIC 0xdeadc0de
#define PROTO_TYPE_USER 0x41414141
#define PROTO_TYPE_PASS 0x42424242
#define PROTO_TYPE_DATA 0x43434343
typedef struct jail_data {
int used;
uint32_t last_type;
char user[USER_LEN+1];
char pass[PASS_LEN+1];
} jail_data;
typedef struct __attribute__((packed, aligned(4))) 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(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(int server_fd, jail_data *dst);
int jail_protocol_loop(event_ctx *ctx, on_event_cb on_event, void *user_data);
#endif
|