MultiInterface.h 1.6 KB

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