smb_message.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //---------------------------------------------------------------------------
  2. // __________________ _________ _____ _____ .__ ._.
  3. // \______ \______ \ / _____/ / \ / _ \ |__| ____ | |
  4. // | | _/| | \ \_____ \ / \ / \ / /_\ \| _/ __ \ | |
  5. // | | \| ` \/ / Y \ / | | \ ___/ \|
  6. // |______ /_______ /_______ \____|__ / /\ \____|__ |__|\___ | __
  7. // \/ \/ \/ \/ )/ \/ \/ \/
  8. //
  9. // This file is part of libdsm. Copyright © 2014 VideoLabs SAS
  10. //
  11. // Author: Julien 'Lta' BALLET <contact@lta.io>
  12. //
  13. // This program is free software. It comes without any warranty, to the extent
  14. // permitted by applicable law. You can redistribute it and/or modify it under
  15. // the terms of the Do What The Fuck You Want To Public License, Version 2, as
  16. // published by Sam Hocevar. See the COPYING file for more details.
  17. //----------------------------------------------------------------------------
  18. #ifndef __BDSM_SMB_MESSAGE_H_
  19. #define __BDSM_SMB_MESSAGE_H_
  20. // The actual packet data format definition is here
  21. #include "bdsm/smb_defs.h"
  22. // This is used with convenience functions to build packets.
  23. typedef struct
  24. {
  25. size_t payload_size; // Size of the allocated payload
  26. size_t cursor; // Write cursor in the payload
  27. smb_packet_t *packet; // Yummy yummy, Fruity fruity !
  28. } smb_message_t;
  29. smb_message_t *smb_message_new(uint8_t cmd, size_t payload_size);
  30. smb_message_t *smb_message_grow(smb_message_t *msg, size_t size);
  31. void smb_message_destroy(smb_message_t *msg);
  32. int smb_message_advance(smb_message_t *msg, size_t size);
  33. int smb_message_append(smb_message_t *msg, const void *data,
  34. size_t data_size);
  35. int smb_message_put8(smb_message_t *msg, uint8_t data);
  36. int smb_message_put16(smb_message_t *msg, uint16_t data);
  37. int smb_message_put32(smb_message_t *msg, uint32_t data);
  38. int smb_message_put64(smb_message_t *msg, uint64_t data);
  39. size_t smb_message_put_utf16(smb_message_t *msg, const char *src_enc,
  40. const char *str, size_t str_len);
  41. int smb_message_put_uuid(smb_message_t *msg, uint32_t a, uint16_t b,
  42. uint16_t c, const uint8_t e[8]);
  43. void smb_message_set_default_flags(smb_message_t *msg);
  44. void smb_message_set_andx_members(smb_message_t *msg);
  45. void smb_message_flag(smb_message_t *msg, uint32_t flag, int value);
  46. #endif