Error.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Error_H
  16. #define Error_H
  17. #include "rust/cjdns_sys/Rffi.h"
  18. #include "wire/Message.h"
  19. enum Error_e {
  20. /** No error, everything is ok. */
  21. Error_NONE = 0,
  22. /** The switch label was malformed. */
  23. Error_MALFORMED_ADDRESS = 1,
  24. /** Packet dropped because link is congested. */
  25. Error_FLOOD = 2,
  26. /** Packet dropped because node has oversent its limit. */
  27. Error_LINK_LIMIT_EXCEEDED = 3,
  28. /** Message too big to send. */
  29. Error_OVERSIZE_MESSAGE = 4,
  30. /** Message smaller than expected headers. */
  31. Error_RUNT = 5,
  32. /** Authentication failed. */
  33. Error_AUTHENTICATION = 6,
  34. /** Header is invalid or checksum failed. */
  35. Error_INVALID = 7,
  36. /** Message could not be sent to its destination through no fault of the sender. */
  37. Error_UNDELIVERABLE = 8,
  38. /** The route enters and leaves through the same interface in one switch. */
  39. Error_LOOP_ROUTE = 9,
  40. /** The switch is unable to represent the return path. */
  41. Error_RETURN_PATH_INVALID = 10,
  42. /** Not invalid, but not something the code is able to handle. */
  43. Error_UNHANDLED = 11,
  44. /** Too many messages, cannot handle. */
  45. Error_OVERFLOW = 12,
  46. /** Something went wrong, it should not have happened. */
  47. Error_INTERNAL = 13,
  48. };
  49. #define Error(m, ...) \
  50. Rffi_error_fl( \
  51. String_printf(Message_getAlloc(m), __VA_ARGS__)->bytes, \
  52. Gcc_SHORT_FILE, \
  53. Gcc_LINE, \
  54. Message_getAlloc(m))
  55. #endif