sshbpp.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Abstraction of the binary packet protocols used in SSH.
  3. */
  4. #ifndef PUTTY_SSHBPP_H
  5. #define PUTTY_SSHBPP_H
  6. typedef struct BinaryPacketProtocol BinaryPacketProtocol;
  7. struct BinaryPacketProtocolVtable {
  8. void (*free)(BinaryPacketProtocol *);
  9. void (*handle_input)(BinaryPacketProtocol *);
  10. PktOut *(*new_pktout)(int type);
  11. void (*format_packet)(BinaryPacketProtocol *, PktOut *);
  12. };
  13. struct BinaryPacketProtocol {
  14. const struct BinaryPacketProtocolVtable *vt;
  15. bufchain *in_raw, *out_raw;
  16. PacketQueue *in_pq;
  17. PacketLogSettings *pls;
  18. LogContext *logctx;
  19. int seen_disconnect;
  20. char *error;
  21. };
  22. #define ssh_bpp_free(bpp) ((bpp)->vt->free(bpp))
  23. #define ssh_bpp_handle_input(bpp) ((bpp)->vt->handle_input(bpp))
  24. #define ssh_bpp_new_pktout(bpp, type) ((bpp)->vt->new_pktout(type))
  25. #define ssh_bpp_format_packet(bpp, pkt) ((bpp)->vt->format_packet(bpp, pkt))
  26. BinaryPacketProtocol *ssh1_bpp_new(void);
  27. void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
  28. const struct ssh_cipher *cipher,
  29. const void *session_key);
  30. void ssh1_bpp_start_compression(BinaryPacketProtocol *bpp);
  31. BinaryPacketProtocol *ssh2_bpp_new(void);
  32. void ssh2_bpp_new_outgoing_crypto(
  33. BinaryPacketProtocol *bpp,
  34. const struct ssh2_cipher *cipher, const void *ckey, const void *iv,
  35. const struct ssh_mac *mac, int etm_mode, const void *mac_key,
  36. const struct ssh_compress *compression);
  37. void ssh2_bpp_new_incoming_crypto(
  38. BinaryPacketProtocol *bpp,
  39. const struct ssh2_cipher *cipher, const void *ckey, const void *iv,
  40. const struct ssh_mac *mac, int etm_mode, const void *mac_key,
  41. const struct ssh_compress *compression);
  42. BinaryPacketProtocol *ssh2_bare_bpp_new(void);
  43. #ifdef MPEXT
  44. const struct ssh_cipher * ssh1_bpp_get_cipher(BinaryPacketProtocol *bpp);
  45. int ssh1_bpp_get_compressing(BinaryPacketProtocol *bpp);
  46. const struct ssh2_cipher * ssh2_bpp_get_cscipher(BinaryPacketProtocol *bpp);
  47. const struct ssh2_cipher * ssh2_bpp_get_sccipher(BinaryPacketProtocol *bpp);
  48. const struct ssh_compress * ssh2_bpp_get_cscomp(BinaryPacketProtocol *bpp);
  49. const struct ssh_compress * ssh2_bpp_get_sccomp(BinaryPacketProtocol *bpp);
  50. #endif
  51. #endif /* PUTTY_SSHBPP_H */