#ifndef _BPP_H_9e15ba9d_ #define _BPP_H_9e15ba9d_ typedef struct bpp BPP; typedef struct oqb OQB; typedef struct layer LAYER; typedef struct layerdesc LAYERDESC; #include "str.h" #include "algs.h" /* This is more generous than the spec says we need to be; it says 255 including the trailing CRLF. Our max doesn't include the CRLF. */ #define SSH_MAX_VERSION_LEN 256 /* Max size of a packet on the wire (after compression and encryption and adding the leading/trailing goop). The spec says this must be >=35000. */ #define SSH_MAX_PACKET_LEN 40000 /* Max size of a packet payload, in the uncompressed clear. The spec says this must be >=32768. */ #define SSH_MAX_PAYLOAD_LEN 35000 /* bpp = binary packet protocol */ struct bpp { int fd; ENCALG *w_enc; void *w_encstate; ENCALG *r_enc; void *r_encstate; COMPALG *w_comp; void *w_compstate; COMPALG *r_comp; void *r_compstate; MACALG *w_mac; void *w_macstate; MACALG *r_mac; void *r_macstate; KEXALG *kex; HKALG *hk; STR K_S; unsigned int w_seq; unsigned int r_seq; void *kex_k; int kex_klen; void *kex_h; int kex_hlen; HASHALG *kex_hash; void *hashbuf; void *sessid; int sessidlen; LAYER *toplayer; LAYER *botlayer; char c_version[SSH_MAX_VERSION_LEN]; int c_vlen; char s_version[SSH_MAX_VERSION_LEN]; int s_vlen; union { struct { int state; #define SVS_ATNL 1 #define SVS_GOT_S 2 #define SVS_GOT_SS 3 #define SVS_GOT_SSH 4 #define SVS_GOT_SSH_ 5 #define SVS_GOT_CR 6 #define SVS_FLUSHING 7 } svs; struct { int ril; int riw; int rit; int pay; } pkt; } __transparent__; void *c_kexinit_payload; int c_kexinit_paylen; void *s_kexinit_payload; int s_kexinit_paylen; int ipkts_to_rekey; int opkts_to_rekey; int ibytes_to_rekey; int obytes_to_rekey; int want_rekey; void (*input)(BPP *, const void *, int); OQB *output; OQB **outtail; unsigned char rawipkt[SSH_MAX_PACKET_LEN]; unsigned char ipkt[SSH_MAX_PAYLOAD_LEN]; int iplen; unsigned char rawopkt[SSH_MAX_PAYLOAD_LEN]; unsigned char opkt[SSH_MAX_PACKET_LEN]; int oplen; } ; struct oqb { OQB *link; const char *data; int left; char *datafree; } ; struct layer { BPP *b; void (*ipkt)(LAYER *, void *); void (*opkt)(LAYER *, void *); void *arg; LAYER *above; LAYER *below; } ; struct layerdesc { void *(*init)(LAYER *); void (*ifn)(LAYER *, void *); void (*ofn)(LAYER *, void *); } ; extern void above_ipkt(LAYER *); extern void below_opkt(LAYER *); extern void send_disconnect(int, const void *, int, const void *, int); extern void set_rekey(BPP *); #endif