- (djm) [openbsd-compat/port-linux.c] Check whether SELinux is enabled
[openssh-git.git] / buffer.h
blobe2a9dd1002a024be67001c225678cb11ddf18b5a
1 /* $OpenBSD: buffer.h,v 1.21 2010/08/31 11:54:45 djm Exp $ */
3 /*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
5 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
6 * All rights reserved
7 * Code for manipulating FIFO buffers.
9 * As far as I am concerned, the code I have written for this software
10 * can be used freely for any purpose. Any derived versions of this
11 * software must be clearly marked as such, and if the derived work is
12 * incompatible with the protocol description in the RFC file, it must be
13 * called by a name other than "ssh" or "Secure Shell".
16 #ifndef BUFFER_H
17 #define BUFFER_H
19 typedef struct {
20 u_char *buf; /* Buffer for data. */
21 u_int alloc; /* Number of bytes allocated for data. */
22 u_int offset; /* Offset of first byte containing data. */
23 u_int end; /* Offset of last byte containing data. */
24 } Buffer;
26 void buffer_init(Buffer *);
27 void buffer_clear(Buffer *);
28 void buffer_free(Buffer *);
30 u_int buffer_len(const Buffer *);
31 void *buffer_ptr(const Buffer *);
33 void buffer_append(Buffer *, const void *, u_int);
34 void *buffer_append_space(Buffer *, u_int);
36 int buffer_check_alloc(Buffer *, u_int);
38 void buffer_get(Buffer *, void *, u_int);
40 void buffer_consume(Buffer *, u_int);
41 void buffer_consume_end(Buffer *, u_int);
43 void buffer_dump(const Buffer *);
45 int buffer_get_ret(Buffer *, void *, u_int);
46 int buffer_consume_ret(Buffer *, u_int);
47 int buffer_consume_end_ret(Buffer *, u_int);
49 #include <openssl/bn.h>
51 void buffer_put_bignum(Buffer *, const BIGNUM *);
52 void buffer_put_bignum2(Buffer *, const BIGNUM *);
53 void buffer_get_bignum(Buffer *, BIGNUM *);
54 void buffer_get_bignum2(Buffer *, BIGNUM *);
56 u_short buffer_get_short(Buffer *);
57 void buffer_put_short(Buffer *, u_short);
59 u_int buffer_get_int(Buffer *);
60 void buffer_put_int(Buffer *, u_int);
62 u_int64_t buffer_get_int64(Buffer *);
63 void buffer_put_int64(Buffer *, u_int64_t);
65 int buffer_get_char(Buffer *);
66 void buffer_put_char(Buffer *, int);
68 void *buffer_get_string(Buffer *, u_int *);
69 void *buffer_get_string_ptr(Buffer *, u_int *);
70 void buffer_put_string(Buffer *, const void *, u_int);
71 char *buffer_get_cstring(Buffer *, u_int *);
72 void buffer_put_cstring(Buffer *, const char *);
74 #define buffer_skip_string(b) \
75 do { u_int l = buffer_get_int(b); buffer_consume(b, l); } while (0)
77 int buffer_put_bignum_ret(Buffer *, const BIGNUM *);
78 int buffer_get_bignum_ret(Buffer *, BIGNUM *);
79 int buffer_put_bignum2_ret(Buffer *, const BIGNUM *);
80 int buffer_get_bignum2_ret(Buffer *, BIGNUM *);
81 int buffer_get_short_ret(u_short *, Buffer *);
82 int buffer_get_int_ret(u_int *, Buffer *);
83 int buffer_get_int64_ret(u_int64_t *, Buffer *);
84 void *buffer_get_string_ret(Buffer *, u_int *);
85 char *buffer_get_cstring_ret(Buffer *, u_int *);
86 void *buffer_get_string_ptr_ret(Buffer *, u_int *);
87 int buffer_get_char_ret(char *, Buffer *);
89 #ifdef OPENSSL_HAS_ECC
90 #include <openssl/ec.h>
92 int buffer_put_ecpoint_ret(Buffer *, const EC_GROUP *, const EC_POINT *);
93 void buffer_put_ecpoint(Buffer *, const EC_GROUP *, const EC_POINT *);
94 int buffer_get_ecpoint_ret(Buffer *, const EC_GROUP *, EC_POINT *);
95 void buffer_get_ecpoint(Buffer *, const EC_GROUP *, EC_POINT *);
96 #endif
98 #endif /* BUFFER_H */