Packet.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * ZeroTier One - Global Peer to Peer Ethernet
  3. * Copyright (C) 2012-2013 ZeroTier Networks LLC
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * --
  19. *
  20. * ZeroTier may be used and distributed under the terms of the GPLv3, which
  21. * are available at: http://www.gnu.org/licenses/gpl-3.0.html
  22. *
  23. * If you would like to embed ZeroTier into a commercial application or
  24. * redistribute it in a modified binary form, please contact ZeroTier Networks
  25. * LLC. Start here: http://www.zerotier.com/
  26. */
  27. #include "Packet.hpp"
  28. namespace ZeroTier {
  29. const char *Packet::verbString(Verb v)
  30. throw()
  31. {
  32. switch(v) {
  33. case VERB_NOP: return "NOP";
  34. case VERB_HELLO: return "HELLO";
  35. case VERB_ERROR: return "ERROR";
  36. case VERB_OK: return "OK";
  37. case VERB_WHOIS: return "WHOIS";
  38. case VERB_RENDEZVOUS: return "RENDEZVOUS";
  39. case VERB_FRAME: return "FRAME";
  40. case VERB_MULTICAST_FRAME: return "MULTICAST_FRAME";
  41. case VERB_MULTICAST_LIKE: return "MULTICAST_LIKE";
  42. }
  43. return "(unknown)";
  44. }
  45. const char *Packet::errorString(ErrorCode e)
  46. throw()
  47. {
  48. switch(e) {
  49. case ERROR_NONE: return "NONE";
  50. case ERROR_INVALID_REQUEST: return "INVALID_REQUEST";
  51. case ERROR_BAD_PROTOCOL_VERSION: return "BAD_PROTOCOL_VERSION";
  52. case ERROR_NOT_FOUND: return "NOT_FOUND";
  53. case ERROR_IDENTITY_COLLISION: return "IDENTITY_COLLISION";
  54. case ERROR_IDENTITY_INVALID: return "IDENTITY_INVALID";
  55. case ERROR_UNSUPPORTED_OPERATION: return "UNSUPPORTED_OPERATION";
  56. }
  57. return "(unknown)";
  58. }
  59. } // namespace ZeroTier