DHTMessage.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. int pleaseRespond;
  39. /**
  40. * If this message is an outgoing reply, replyTo is the original query.
  41. * For incoming replies or any queries, it is NULL.
  42. */
  43. struct DHTMessage* replyTo;
  44. /** A memory allocator which will be freed after this message is sent. */
  45. struct Allocator* allocator;
  46. };
  47. #endif