tcpdump: Move static variables to special section

This fixes some issues if tcpdump is invoked a second time.
This commit is contained in:
Sebastian Huber 2019-03-11 09:33:28 +01:00
parent c0776e69be
commit d542c19668
6 changed files with 39 additions and 0 deletions

View File

@ -1266,7 +1266,13 @@ struct hnamemem *
newhnamemem(netdissect_options *ndo) newhnamemem(netdissect_options *ndo)
{ {
register struct hnamemem *p; register struct hnamemem *p;
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static struct hnamemem *ptr = NULL; static struct hnamemem *ptr = NULL;
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static u_int num = 0; static u_int num = 0;
if (num <= 0) { if (num <= 0) {
@ -1285,7 +1291,13 @@ struct h6namemem *
newh6namemem(netdissect_options *ndo) newh6namemem(netdissect_options *ndo)
{ {
register struct h6namemem *p; register struct h6namemem *p;
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static struct h6namemem *ptr = NULL; static struct h6namemem *ptr = NULL;
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static u_int num = 0; static u_int num = 0;
if (num <= 0) { if (num <= 0) {

View File

@ -576,6 +576,9 @@ ataddr_string(netdissect_options *ndo,
register struct hnamemem *tp, *tp2; register struct hnamemem *tp, *tp2;
register int i = (atnet << 8) | athost; register int i = (atnet << 8) | athost;
char nambuf[256+1]; char nambuf[256+1];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int first = 1; static int first = 1;
FILE *fp; FILE *fp;

View File

@ -608,6 +608,9 @@ void esp_print_decodesecret(netdissect_options *ndo)
{ {
char *line; char *line;
char *p; char *p;
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int initialized = 0; static int initialized = 0;
if (!initialized) { if (!initialized) {

View File

@ -165,6 +165,9 @@ static const char *
format_nid(const u_char *data) format_nid(const u_char *data)
{ {
static char buf[4][11+5]; static char buf[4][11+5];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int i = 0; static int i = 0;
i = (i + 1) % 4; i = (i + 1) % 4;
snprintf(buf[i], 16, "%02x:%02x:%02x:%02x", snprintf(buf[i], 16, "%02x:%02x:%02x:%02x",
@ -176,6 +179,9 @@ static const char *
format_256(const u_char *data) format_256(const u_char *data)
{ {
static char buf[4][64+5]; static char buf[4][64+5];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int i = 0; static int i = 0;
i = (i + 1) % 4; i = (i + 1) % 4;
snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64, snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
@ -191,6 +197,9 @@ static const char *
format_interval(const uint32_t n) format_interval(const uint32_t n)
{ {
static char buf[4][sizeof("0000000.000s")]; static char buf[4][sizeof("0000000.000s")];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int i = 0; static int i = 0;
i = (i + 1) % 4; i = (i + 1) % 4;
snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000); snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000);

View File

@ -115,6 +115,9 @@ static void
trans2_qfsinfo(netdissect_options *ndo, trans2_qfsinfo(netdissect_options *ndo,
const u_char *param, const u_char *data, int pcnt, int dcnt) const u_char *param, const u_char *data, int pcnt, int dcnt)
{ {
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int level = 0; static int level = 0;
const char *fmt=""; const char *fmt="";
@ -179,6 +182,9 @@ print_trans2(netdissect_options *ndo,
const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf) const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
{ {
u_int bcc; u_int bcc;
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static const struct smbfnsint *fn = &trans2_fns[0]; static const struct smbfnsint *fn = &trans2_fns[0];
const u_char *data, *param; const u_char *data, *param;
const u_char *w = words + 1; const u_char *w = words + 1;

View File

@ -323,6 +323,9 @@ ts_print(netdissect_options *ndo,
struct tm *tm; struct tm *tm;
time_t Time; time_t Time;
char buf[TS_BUF_SIZE]; char buf[TS_BUF_SIZE];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static struct timeval tv_ref; static struct timeval tv_ref;
struct timeval tv_result; struct timeval tv_result;
int negative_offset; int negative_offset;
@ -510,6 +513,9 @@ tok2str(register const struct tok *lp, register const char *fmt,
register u_int v) register u_int v)
{ {
static char buf[4][TOKBUFSIZE]; static char buf[4][TOKBUFSIZE];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int idx = 0; static int idx = 0;
char *ret; char *ret;