[go: up one dir, main page]

File: route.c

package info (click to toggle)
libdumbnet 1.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,768 kB
  • sloc: ansic: 11,563; sh: 4,203; python: 261; makefile: 92
file content (33 lines) | stat: -rw-r--r-- 603 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// stripped down from tests/dnet/route.c

#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <dumbnet.h>

static int
print_route(const struct route_entry *entry, void *arg)
{
	printf("%-20s %-20s\n",
	    addr_ntoa(&entry->route_dst), addr_ntoa(&entry->route_gw));
	return (0);
}

int
main(int argc, char *argv[])
{
	route_t *r;

	if ((r = route_open()) == NULL)
		err(1, "route_open");

        printf("%-20s %-20s\n", "Destination", "Gateway");
        if (route_loop(r, print_route, NULL) < 0)
                err(1, "route_loop");
	
	route_close(r);
	
	exit(0);
}