0000-solaris.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. From 1ac599a0f29500a15faf0dbbdc2565cc7dce2420 Mon Sep 17 00:00:00 2001
  2. From: Shaun Ruffell <sruffell@digium.com>
  3. Date: Fri, 7 Sep 2012 14:31:19 -0500
  4. Subject: [PATCH 4/5] pjproject: Fix for Solaris builds. Do not undef s_addr.
  5. pjproject, in order to solve build problems on Windows [1], undefines s_addr in
  6. one of it's headers that is included in res_rtp_asterisk.c. On Solaris s_addr is
  7. not a structure member, but defined to map to the real strucuture member,
  8. therefore when building on Solaris it's possible to get build errors like:
  9. [CC] res_rtp_asterisk.c -> res_rtp_asterisk.o
  10. In file included from /export/home/admin/asterisk-11-svn/include/asterisk/stun.h:29,
  11. from res_rtp_asterisk.c:51:
  12. /export/home/admin/asterisk-11-svn/include/asterisk/network.h: In function `inaddrcmp':
  13. /export/home/admin/asterisk-11-svn/include/asterisk/network.h:92: error: structure has no member named `s_addr'
  14. /export/home/admin/asterisk-11-svn/include/asterisk/network.h:92: error: structure has no member named `s_addr'
  15. res_rtp_asterisk.c: In function `ast_rtp_on_ice_tx_pkt':
  16. res_rtp_asterisk.c:706: warning: dereferencing type-punned pointer will break strict-aliasing rules
  17. res_rtp_asterisk.c:710: warning: dereferencing type-punned pointer will break strict-aliasing rules
  18. res_rtp_asterisk.c: In function `rtp_add_candidates_to_ice':
  19. res_rtp_asterisk.c:1085: error: structure has no member named `s_addr'
  20. make[2]: *** [res_rtp_asterisk.o] Error 1
  21. make[1]: *** [res] Error 2
  22. make[1]: Leaving directory `/export/home/admin/asterisk-11-svn'
  23. gmake: *** [_cleantest_all] Error 2
  24. Unfortunately, in order to make this work, I also had to make sure pjproject
  25. only used the typdef pj_in_addr and not the struct pj_in_addr so that when
  26. building Asterisk I could "typedef struct in_addr pj_in_addr". It's possible
  27. then that the library and users of those interfaces in Asterisk have a different
  28. idea about the type of the argument. While on the surface it looks like they are
  29. all 32 bit big endian values.
  30. [1] http://trac.pjsip.org/repos/changeset/484
  31. Reported-by: Ben Klang
  32. (issues ASTERISK-20366)
  33. Updated by ASTERISK-27997
  34. ---
  35. pjlib/include/pj/sock.h | 8 +++++++-
  36. pjlib/src/pj/sock_bsd.c | 2 +-
  37. pjlib/src/pj/sock_symbian.cpp | 2 +-
  38. pjlib/src/pj/sock_uwp.cpp | 2 +-
  39. pjsip/src/test/transport_test.c | 2 +-
  40. 5 files changed, 11 insertions(+), 5 deletions(-)
  41. diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h
  42. index 4daf298..c35833c 100644
  43. --- a/pjlib/include/pj/sock.h
  44. +++ b/pjlib/include/pj/sock.h
  45. @@ -484,6 +484,7 @@ typedef enum pj_socket_sd_type
  46. */
  47. #define PJ_INVALID_SOCKET (-1)
  48. +#ifndef _ASTERISK_H
  49. /* Must undefine s_addr because of pj_in_addr below */
  50. #undef s_addr
  51. @@ -495,6 +496,11 @@ typedef struct pj_in_addr
  52. pj_uint32_t s_addr; /**< The 32bit IP address. */
  53. } pj_in_addr;
  54. +#else
  55. +#include <sys/types.h>
  56. +#include <netinet/in.h>
  57. +typedef struct in_addr pj_in_addr;
  58. +#endif
  59. /**
  60. * Maximum length of text representation of an IPv4 address.
  61. @@ -712,7 +718,7 @@ PJ_DECL(char*) pj_inet_ntoa(pj_in_addr inaddr);
  62. *
  63. * @return nonzero if the address is valid, zero if not.
  64. */
  65. -PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp);
  66. +PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp);
  67. /**
  68. * This function converts an address in its standard text presentation form
  69. diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c
  70. index e416991..940fce1 100644
  71. --- a/pjlib/src/pj/sock_bsd.c
  72. +++ b/pjlib/src/pj/sock_bsd.c
  73. @@ -244,7 +244,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
  74. * numbers-and-dots notation into binary data and stores it in the structure
  75. * that inp points to.
  76. */
  77. -PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
  78. +PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
  79. {
  80. char tempaddr[PJ_INET_ADDRSTRLEN];
  81. diff --git a/pjlib/src/pj/sock_symbian.cpp b/pjlib/src/pj/sock_symbian.cpp
  82. index 09239b0..e72bbda 100644
  83. --- a/pjlib/src/pj/sock_symbian.cpp
  84. +++ b/pjlib/src/pj/sock_symbian.cpp
  85. @@ -299,7 +299,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
  86. * numbers-and-dots notation into binary data and stores it in the structure
  87. * that inp points to.
  88. */
  89. -PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
  90. +PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
  91. {
  92. enum { MAXIPLEN = PJ_INET_ADDRSTRLEN };
  93. diff --git a/pjlib/src/pj/sock_uwp.cpp b/pjlib/src/pj/sock_uwp.cpp
  94. index 876c328..40250bf 100644
  95. --- a/pjlib/src/pj/sock_uwp.cpp
  96. +++ b/pjlib/src/pj/sock_uwp.cpp
  97. @@ -933,7 +933,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
  98. * numbers-and-dots notation into binary data and stores it in the structure
  99. * that inp points to.
  100. */
  101. -PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
  102. +PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
  103. {
  104. char tempaddr[PJ_INET_ADDRSTRLEN];
  105. diff --git a/pjsip/src/test/transport_test.c b/pjsip/src/test/transport_test.c
  106. index e5083d1..c429cc7 100644
  107. --- a/pjsip/src/test/transport_test.c
  108. +++ b/pjsip/src/test/transport_test.c
  109. @@ -35,7 +35,7 @@ int generic_transport_test(pjsip_transport *tp)
  110. /* Check that local address name is valid. */
  111. {
  112. - struct pj_in_addr addr;
  113. + pj_in_addr addr;
  114. if (pj_inet_pton(pj_AF_INET(), &tp->local_name.host,
  115. &addr) == PJ_SUCCESS)
  116. --
  117. 2.7.4