0002-src-Use-stdint-types.patch 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. From 24957c135eaacd718f3c788285de33d64316b32e Mon Sep 17 00:00:00 2001
  2. From: Felix Janda <felix.janda@posteo.de>
  3. Date: Sat, 16 May 2015 10:31:24 +0200
  4. Subject: [PATCH 1/2] src: Use stdint types
  5. Backport of upstream commit 047f37b1d5d865084a435fd7594b8c5c332ccb8d
  6. Please note that the backported patch does not include two changes
  7. to arptables.h from the upstream - these modified lines added in commit
  8. dbbe9f7de36aa3c7dd61dc89092c03f7902e474e which was committed after
  9. the 0.0.4 release.
  10. Upstream-status: backport
  11. Signed-off-by: Felix Janda <felix.janda@posteo.de>
  12. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  13. Signed-off-by: Brendan Heading <brendanheading@gmail.com>
  14. ---
  15. arptables.c | 8 ++++----
  16. include/arptables.h | 3 ++-
  17. include/libarptc/libarptc.h | 7 ++++---
  18. libarptc/libarptc.c | 4 ++--
  19. libarptc/libarptc_incl.c | 2 +-
  20. 5 files changed, 13 insertions(+), 11 deletions(-)
  21. diff --git a/arptables.c b/arptables.c
  22. index 5535ab2..6d1377f 100644
  23. --- a/arptables.c
  24. +++ b/arptables.c
  25. @@ -230,7 +230,7 @@ extern void dump_entries(const arptc_handle_t handle);
  26. /etc/protocols */
  27. struct pprot {
  28. char *name;
  29. - u_int8_t num;
  30. + uint8_t num;
  31. };
  32. /* Primitive headers... */
  33. @@ -925,7 +925,7 @@ mask_to_dotted(const struct in_addr *mask)
  34. {
  35. int i;
  36. static char buf[20];
  37. - u_int32_t maskaddr, bits;
  38. + uint32_t maskaddr, bits;
  39. maskaddr = ntohl(mask->s_addr);
  40. @@ -967,7 +967,7 @@ string_to_number(const char *s, unsigned int min, unsigned int max,
  41. }
  42. static void
  43. -set_option(unsigned int *options, unsigned int option, u_int16_t *invflg,
  44. +set_option(unsigned int *options, unsigned int option, uint16_t *invflg,
  45. int invert)
  46. {
  47. if (*options & option)
  48. @@ -1107,7 +1107,7 @@ register_target(struct arptables_target *me)
  49. }
  50. static void
  51. -print_num(u_int64_t number, unsigned int format)
  52. +print_num(uint64_t number, unsigned int format)
  53. {
  54. if (format & FMT_KILOMEGAGIGA) {
  55. if (number > 99999) {
  56. diff --git a/include/arptables.h b/include/arptables.h
  57. index 820b664..e6a6ba6 100644
  58. --- a/include/arptables.h
  59. +++ b/include/arptables.h
  60. @@ -1,6 +1,7 @@
  61. #ifndef _ARPTABLES_USER_H
  62. #define _ARPTABLES_USER_H
  63. +#include <stdint.h>
  64. #include "arptables_common.h"
  65. #include "libarptc/libarptc.h"
  66. @@ -126,7 +127,7 @@ extern char *mask_to_dotted(const struct in_addr *mask);
  67. extern void parse_hostnetworkmask(const char *name, struct in_addr **addrpp,
  68. struct in_addr *maskp, unsigned int *naddrs);
  69. -extern u_int16_t parse_protocol(const char *s);
  70. +extern uint16_t parse_protocol(const char *s);
  71. extern int do_command(int argc, char *argv[], char **table,
  72. arptc_handle_t *handle);
  73. diff --git a/include/libarptc/libarptc.h b/include/libarptc/libarptc.h
  74. index e4f1175..76fbfab 100644
  75. --- a/include/libarptc/libarptc.h
  76. +++ b/include/libarptc/libarptc.h
  77. @@ -6,9 +6,10 @@
  78. #include <linux/netfilter_arp/arp_tables.h>
  79. #ifndef ARPT_MIN_ALIGN
  80. -/* arpt_entry has pointers and u_int64_t's in it, so if you align to
  81. - it, you'll also align to any crazy matches and targets someone
  82. - might write */
  83. +/* arpt_entry has pointers and uint64_t's in it, so if you align to
  84. + * it, you'll also align to any crazy matches and targets someone
  85. + * might write.
  86. + */
  87. #define ARPT_MIN_ALIGN (__alignof__(struct arpt_entry))
  88. #endif
  89. diff --git a/libarptc/libarptc.c b/libarptc/libarptc.c
  90. index 2dcaaef..701bae0 100644
  91. --- a/libarptc/libarptc.c
  92. +++ b/libarptc/libarptc.c
  93. @@ -256,8 +256,8 @@ unconditional(const struct arpt_arp *arp)
  94. {
  95. unsigned int i;
  96. - for (i = 0; i < sizeof(*arp)/sizeof(u_int32_t); i++)
  97. - if (((u_int32_t *)arp)[i])
  98. + for (i = 0; i < sizeof(*arp) / sizeof(uint32_t); i++)
  99. + if (((uint32_t *)arp)[i])
  100. return 0;
  101. return 1;
  102. diff --git a/libarptc/libarptc_incl.c b/libarptc/libarptc_incl.c
  103. index 2fa3d43..b41fcb2 100644
  104. --- a/libarptc/libarptc_incl.c
  105. +++ b/libarptc/libarptc_incl.c
  106. @@ -1706,7 +1706,7 @@ TC_COMMIT(TC_HANDLE_T *handle)
  107. /* Kernel will think that pointer should be 64-bits, and get
  108. padding. So we accomodate here (assumption: alignment of
  109. `counters' is on 64-bit boundary). */
  110. - u_int64_t *kernptr = (u_int64_t *)&newcounters->counters;
  111. + uint64_t *kernptr = (uint64_t *)&newcounters->counters;
  112. if ((unsigned long)&newcounters->counters % 8 != 0) {
  113. fprintf(stderr,
  114. "counters alignment incorrect! Mail rusty!\n");
  115. --
  116. 2.4.3