~vcs-imports/busybox/trunk

« back to all changes in this revision

Viewing changes to networking/netstat.c

  • Committer: Denys Vlasenko
  • Author(s): Christian Franke
  • Date: 2023-11-13 10:32:35 UTC
  • Revision ID: git-v1:a63b60bdd6fa26b867c80d44074118babbae7ffd
Cygwin: regenerate defconfig

Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
//config:config NETSTAT
17
17
//config:       bool "netstat (10 kb)"
18
18
//config:       default y
19
 
//config:       select PLATFORM_LINUX
20
19
//config:       help
21
20
//config:       netstat prints information about the Linux networking subsystem.
22
21
//config:
115
114
        TCP_CLOSING, /* now a valid state */
116
115
};
117
116
 
118
 
static const char *const tcp_state[] = {
 
117
static const char *const tcp_state[] ALIGN_PTR = {
119
118
        "",
120
119
        "ESTABLISHED",
121
120
        "SYN_SENT",
273
272
        return inode;
274
273
}
275
274
 
276
 
static int FAST_FUNC add_to_prg_cache_if_socket(const char *fileName,
277
 
                struct stat *statbuf UNUSED_PARAM,
278
 
                void *pid_slash_progname,
279
 
                int depth UNUSED_PARAM)
 
275
static int FAST_FUNC add_to_prg_cache_if_socket(struct recursive_state *state,
 
276
                const char *fileName,
 
277
                struct stat *statbuf UNUSED_PARAM)
280
278
{
281
279
        char *linkname;
282
280
        long inode;
285
283
        if (linkname != NULL) {
286
284
                inode = extract_socket_inode(linkname);
287
285
                free(linkname);
288
 
                if (inode >= 0)
289
 
                        prg_cache_add(inode, (char *)pid_slash_progname);
 
286
                if (inode >= 0) {
 
287
                        char *pid_slash_progname = state->userData;
 
288
                        prg_cache_add(inode, pid_slash_progname);
 
289
                }
290
290
        }
291
291
        return TRUE;
292
292
}
293
293
 
294
 
static int FAST_FUNC dir_act(const char *fileName,
295
 
                struct stat *statbuf UNUSED_PARAM,
296
 
                void *userData UNUSED_PARAM,
297
 
                int depth)
 
294
static int FAST_FUNC dir_act(struct recursive_state *state,
 
295
                const char *fileName,
 
296
                struct stat *statbuf UNUSED_PARAM)
298
297
{
299
298
        const char *pid;
300
299
        char *pid_slash_progname;
302
301
        char cmdline_buf[512];
303
302
        int n, len;
304
303
 
305
 
        if (depth == 0) /* "/proc" itself */
 
304
        if (state->depth == 0) /* "/proc" itself */
306
305
                return TRUE; /* continue looking one level below /proc */
307
306
 
308
307
        pid = fileName + sizeof("/proc/")-1; /* point after "/proc/" */
322
321
                        ACTION_RECURSE | ACTION_QUIET,
323
322
                        add_to_prg_cache_if_socket,
324
323
                        NULL,
325
 
                        (void *)pid_slash_progname,
326
 
                        0);
 
324
                        (void *)pid_slash_progname
 
325
        );
327
326
        free(pid_slash_progname);
328
327
 
329
328
        if (!n)
338
337
 
339
338
        prg_cache_loaded = 1;
340
339
        load_ok = recursive_action("/proc", ACTION_RECURSE | ACTION_QUIET,
341
 
                                NULL, dir_act, NULL, 0);
 
340
                                NULL, dir_act, NULL);
342
341
        if (load_ok)
343
342
                return;
344
343