MultiInterface.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 MultiInterface_H
  16. #define MultiInterface_H
  17. #include "interface/Interface.h"
  18. #include "interface/InterfaceController.h"
  19. #include "util/log/Log.h"
  20. #include "util/Linker.h"
  21. Linker_require("interface/MultiInterface.c")
  22. /*
  23. * An Interface such as Ethernet or UDP which may connect to multiple peers
  24. * through the same socket, Interfaces are MultiInterface must send and expect
  25. * a configurable length key to be sent in front of the message, this key
  26. * indicates which peer the message is from/to.
  27. */
  28. struct MultiInterface
  29. {
  30. /** The interface which is wrapped by this MultiInterface. */
  31. struct Interface* const iface;
  32. /**
  33. * The number of bytes which this interface will send
  34. * ahead of the message to signal it's origin.
  35. */
  36. const int keySize;
  37. };
  38. struct Interface* MultiInterface_ifaceForKey(struct MultiInterface* mIface, void* key);
  39. struct MultiInterface* MultiInterface_new(int keySize,
  40. struct Interface* external,
  41. struct InterfaceController* ic,
  42. struct Log* logger);
  43. #endif