tcp_ev.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2009 iptelorg GmbH
  5. *
  6. * Permission to use, copy, modify, and distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /*
  19. * tcp_ev.h - tcp events
  20. */
  21. /*
  22. * History:
  23. * --------
  24. * 2009-04-09 initial version (andrei)
  25. */
  26. #ifndef __tcp_ev_h
  27. #define __tcp_ev_h
  28. #include <errno.h>
  29. #include <string.h>
  30. #include "ip_addr.h"
  31. /** a connect attempt got a RST from the peer
  32. * Note: the RST might be for the connect() itself (SYN), for the first
  33. * send() attempt on the connection (unlikely) or received immediately after
  34. * the connect() succeeded (unlikely, the remote host would have a very small
  35. * window after accepting a connection to send a RST before it receives
  36. * any data).
  37. *
  38. * @param err - if 0 it should be ignored (no corresp. libc error), if non-0
  39. * it will contain the errno.
  40. * @param lip - pointer to an ip_addr containing the local ip
  41. * or 0 if dynamic (WARNING can be 0).
  42. * @param lport - pointer to an ip_addr containing the local port or 0
  43. * if unknown/dynamic.
  44. * @param dst - pointer to a sockaddr_union containing the destination.
  45. * @param proto - protocol used
  46. */
  47. #define TCP_EV_CONNECT_RST(err, lip, lport, dst, proto) \
  48. LM_ERR("connect %s failed (RST) %s\n", \
  49. su2a(dst, sizeof(*(dst))), (err)?strerror(err):"")
  50. /** a connect failed because the remote host/network is unreachable. */
  51. #define TCP_EV_CONNECT_UNREACHABLE(err, lip, lport, dst, proto) \
  52. LM_ERR("connect %s failed (unreachable) %s\n", \
  53. su2a(dst, sizeof(*(dst))), (err)?strerror(err):"")
  54. /** a connect attempt did timeout. */
  55. #define TCP_EV_CONNECT_TIMEOUT(err, lip, lport, dst, proto) \
  56. LM_ERR("connect %s failed (timeout) %s\n", \
  57. su2a(dst, sizeof(*(dst))), (err)?strerror(err):"")
  58. /** a connect attempt failed because the local ports are exhausted. */
  59. #define TCP_EV_CONNECT_NO_MORE_PORTS(err, lip, lport, dst, proto) \
  60. LM_ERR("connect %s failed (no more ports) %s\n", \
  61. su2a(dst, sizeof(*(dst))), (err)?strerror(err):"")
  62. /** a connect attempt failed for some unknown reason. */
  63. #define TCP_EV_CONNECT_ERR(err, lip, lport, dst, proto) \
  64. LM_ERR("connect %s failed %s\n", \
  65. su2a(dst, sizeof(*(dst))), (err)?strerror(err):"")
  66. /** send failed due to timeout.
  67. * @param err - if 0 it should be ignored (no corresp. libc error), if non-0
  68. * it will contain the errno.
  69. * @param rcv - pointer to rcv_info structure
  70. *
  71. */
  72. #define TCP_EV_SEND_TIMEOUT(err, rcv)
  73. /** send failed due to buffering capacity being exceeded.
  74. * (only in async mode) */
  75. #define TCP_EV_SENDQ_FULL(err, rcv)
  76. /** established connection closed for being idle too long. */
  77. #define TCP_EV_IDLE_CONN_CLOSED(err, rcv)
  78. #endif /*__tcp_ev_h*/
  79. /* vi: set ts=4 sw=4 tw=79:ai:cindent: */