1
0

DHTMessage.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef DHTMessage_H
  16. #define DHTMessage_H
  17. #include "benc/Dict.h"
  18. /**
  19. * Maximum number of bytes in a message.
  20. * Ethernet MTU is 1500 so it's hard to imagine much more.
  21. */
  22. #define DHTMessage_MAX_SIZE 1536
  23. /**
  24. * This struct represents a DHT message which will be passed to the
  25. * modules. The only part of the message which will be available to
  26. * all modules is Message.peer. Incoming modules will have Message.bytes
  27. * and Message.length when they come from the network module.
  28. */
  29. struct DHTMessage;
  30. struct DHTMessage
  31. {
  32. struct Address* address;
  33. struct Message* binMessage;
  34. /** The message as a bencoded dictionary. */
  35. Dict* asDict;
  36. struct EncodingScheme* encodingScheme;
  37. int encIndex;
  38. /**
  39. * If this message is an outgoing reply, replyTo is the original query.
  40. * For incoming replies or any queries, it is NULL.
  41. */
  42. struct DHTMessage* replyTo;
  43. /** A memory allocator which will be freed after this message is sent. */
  44. struct Allocator* allocator;
  45. };
  46. #endif