Annotation of src/usr.bin/ssh/opacket.h, Revision 1.2
1.1 markus 1: #ifndef _OPACKET_H
2: /* Written by Markus Friedl. Placed in the public domain. */
3:
4: /* Map old to new API */
5: void ssh_packet_start(struct ssh *, u_char);
6: void ssh_packet_put_char(struct ssh *, int ch);
7: void ssh_packet_put_int(struct ssh *, u_int value);
8: void ssh_packet_put_int64(struct ssh *, u_int64_t value);
9: void ssh_packet_put_bignum(struct ssh *, BIGNUM * value);
10: void ssh_packet_put_bignum2(struct ssh *, BIGNUM * value);
11: void ssh_packet_put_ecpoint(struct ssh *, const EC_GROUP *, const EC_POINT *);
12: void ssh_packet_put_string(struct ssh *, const void *buf, u_int len);
13: void ssh_packet_put_cstring(struct ssh *, const char *str);
14: void ssh_packet_put_raw(struct ssh *, const void *buf, u_int len);
15: void ssh_packet_send(struct ssh *);
16:
17: u_int ssh_packet_get_char(struct ssh *);
18: u_int ssh_packet_get_int(struct ssh *);
19: u_int64_t ssh_packet_get_int64(struct ssh *);
20: void ssh_packet_get_bignum(struct ssh *, BIGNUM * value);
21: void ssh_packet_get_bignum2(struct ssh *, BIGNUM * value);
22: void ssh_packet_get_ecpoint(struct ssh *, const EC_GROUP *, EC_POINT *);
23: void *ssh_packet_get_string(struct ssh *, u_int *length_ptr);
24: char *ssh_packet_get_cstring(struct ssh *, u_int *length_ptr);
25:
26: /* don't allow remaining bytes after the end of the message */
27: #define ssh_packet_check_eom(ssh) \
28: do { \
29: int _len = ssh_packet_remaining(ssh); \
30: if (_len > 0) { \
31: logit("Packet integrity error (%d bytes remaining) at %s:%d", \
32: _len ,__FILE__, __LINE__); \
33: ssh_packet_disconnect(ssh, \
34: "Packet integrity error."); \
35: } \
36: } while (0)
37:
38: /* old API */
39: void packet_close(void);
40: u_int packet_get_char(void);
41: u_int packet_get_int(void);
42: void packet_backup_state(void);
43: void packet_restore_state(void);
44: void packet_set_connection(int, int);
45: int packet_read_seqnr(u_int32_t *);
46: int packet_read_poll_seqnr(u_int32_t *);
1.2 ! djm 47: void packet_process_incoming(const char *buf, u_int len);
1.1 markus 48: #define packet_set_timeout(timeout, count) \
49: ssh_packet_set_timeout(active_state, (timeout), (count))
50: #define packet_connection_is_on_socket() \
51: ssh_packet_connection_is_on_socket(active_state)
52: #define packet_set_nonblocking() \
53: ssh_packet_set_nonblocking(active_state)
54: #define packet_get_connection_in() \
55: ssh_packet_get_connection_in(active_state)
56: #define packet_get_connection_out() \
57: ssh_packet_get_connection_out(active_state)
58: #define packet_set_protocol_flags(protocol_flags) \
59: ssh_packet_set_protocol_flags(active_state, (protocol_flags))
60: #define packet_get_protocol_flags() \
61: ssh_packet_get_protocol_flags(active_state)
62: #define packet_start_compression(level) \
63: ssh_packet_start_compression(active_state, (level))
64: #define packet_set_encryption_key(key, keylen, number) \
65: ssh_packet_set_encryption_key(active_state, (key), (keylen), (number))
66: #define packet_start(type) \
67: ssh_packet_start(active_state, (type))
68: #define packet_put_char(value) \
69: ssh_packet_put_char(active_state, (value))
70: #define packet_put_int(value) \
71: ssh_packet_put_int(active_state, (value))
72: #define packet_put_int64(value) \
73: ssh_packet_put_int64(active_state, (value))
74: #define packet_put_string( buf, len) \
75: ssh_packet_put_string(active_state, (buf), (len))
76: #define packet_put_cstring(str) \
77: ssh_packet_put_cstring(active_state, (str))
78: #define packet_put_raw(buf, len) \
79: ssh_packet_put_raw(active_state, (buf), (len))
80: #define packet_put_bignum(value) \
81: ssh_packet_put_bignum(active_state, (value))
82: #define packet_put_bignum2(value) \
83: ssh_packet_put_bignum2(active_state, (value))
84: #define packet_send() \
85: ssh_packet_send(active_state)
86: #define packet_read() \
87: ssh_packet_read(active_state)
88: #define packet_read_expect(expected_type) \
89: ssh_packet_read_expect(active_state, (expected_type))
90: #define packet_get_int64() \
91: ssh_packet_get_int64(active_state)
92: #define packet_get_bignum(value) \
93: ssh_packet_get_bignum(active_state, (value))
94: #define packet_get_bignum2(value) \
95: ssh_packet_get_bignum2(active_state, (value))
96: #define packet_remaining() \
97: ssh_packet_remaining(active_state)
98: #define packet_get_string(length_ptr) \
99: ssh_packet_get_string(active_state, (length_ptr))
100: #define packet_get_string_ptr(length_ptr) \
101: ssh_packet_get_string_ptr(active_state, (length_ptr))
102: #define packet_get_cstring(length_ptr) \
103: ssh_packet_get_cstring(active_state, (length_ptr))
104: #define packet_send_debug(fmt, args...) \
105: ssh_packet_send_debug(active_state, (fmt), ##args)
106: #define packet_disconnect(fmt, args...) \
107: ssh_packet_disconnect(active_state, (fmt), ##args)
108: #define packet_write_poll() \
109: ssh_packet_write_poll(active_state)
110: #define packet_write_wait() \
111: ssh_packet_write_wait(active_state)
112: #define packet_have_data_to_write() \
113: ssh_packet_have_data_to_write(active_state)
114: #define packet_not_very_much_data_to_write() \
115: ssh_packet_not_very_much_data_to_write(active_state)
116: #define packet_set_interactive(interactive, qos_interactive, qos_bulk) \
117: ssh_packet_set_interactive(active_state, (interactive), (qos_interactive), (qos_bulk))
118: #define packet_is_interactive() \
119: ssh_packet_is_interactive(active_state)
120: #define packet_set_maxsize(s) \
121: ssh_packet_set_maxsize(active_state, (s))
122: #define packet_inc_alive_timeouts() \
123: ssh_packet_inc_alive_timeouts(active_state)
124: #define packet_set_alive_timeouts(ka) \
125: ssh_packet_set_alive_timeouts(active_state, (ka))
126: #define packet_get_maxsize() \
127: ssh_packet_get_maxsize(active_state)
128: #define packet_add_padding(pad) \
129: sshpkt_add_padding(active_state, (pad))
130: #define packet_send_ignore(nbytes) \
131: ssh_packet_send_ignore(active_state, (nbytes))
132: #define packet_need_rekeying() \
133: ssh_packet_need_rekeying(active_state)
134: #define packet_set_rekey_limit(bytes) \
135: ssh_packet_set_rekey_limit(active_state, (bytes))
136: #define packet_set_server() \
137: ssh_packet_set_server(active_state)
138: #define packet_set_authenticated() \
139: ssh_packet_set_authenticated(active_state)
140: #define packet_get_input() \
141: ssh_packet_get_input(active_state)
142: #define packet_get_output() \
143: ssh_packet_get_output(active_state)
144: #define packet_set_compress_hooks(ctx, allocfunc, freefunc) \
145: ssh_packet_set_compress_hooks(active_state, ctx, \
146: allocfunc, freefunc);
147: #define packet_check_eom() \
148: ssh_packet_check_eom(active_state)
149: #define set_newkeys(mode) \
150: ssh_set_newkeys(active_state, (mode))
151: #define packet_get_state(m) \
152: ssh_packet_get_state(active_state, m)
153: #define packet_set_state(m) \
154: ssh_packet_set_state(active_state, m)
155: #if 0
156: #define get_remote_ipaddr() \
157: ssh_remote_ipaddr(active_state)
158: #endif
159: #define packet_get_raw(lenp) \
160: sshpkt_ptr(active_state, lenp)
161: #define packet_get_ecpoint(c,p) \
162: ssh_packet_get_ecpoint(active_state, c, p)
163: #define packet_put_ecpoint(c,p) \
164: ssh_packet_put_ecpoint(active_state, c, p)
165: #define packet_get_rekey_timeout() \
166: ssh_packet_get_rekey_timeout(active_state)
167: #define packet_set_rekey_limits(x,y) \
168: ssh_packet_set_rekey_limits(active_state, x, y)
169: #define packet_get_bytes(x,y) \
170: ssh_packet_get_bytes(active_state, x, y)
171:
172: #endif /* _OPACKET_H */