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

View File

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

View File

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

View File

@ -165,6 +165,9 @@ static const char *
format_nid(const u_char *data)
{
static char buf[4][11+5];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int i = 0;
i = (i + 1) % 4;
snprintf(buf[i], 16, "%02x:%02x:%02x:%02x",
@ -176,6 +179,9 @@ static const char *
format_256(const u_char *data)
{
static char buf[4][64+5];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int i = 0;
i = (i + 1) % 4;
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)
{
static char buf[4][sizeof("0000000.000s")];
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static int i = 0;
i = (i + 1) % 4;
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,
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;
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)
{
u_int bcc;
#ifdef __rtems__
__section(".rtemsrwset.bsd_prog_tcpdump.content")
#endif /* __rtems__ */
static const struct smbfnsint *fn = &trans2_fns[0];
const u_char *data, *param;
const u_char *w = words + 1;

View File

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