1 /* $OpenBSD: main.c,v 1.6 2019/06/24 12:33:36 visa Exp $ */ 2 3 /* 4 * Copyright (c) 2015 Martin Pieuchot 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #include "srp_compat.h" 20 21 #include <sys/socket.h> 22 #include <net/route.h> 23 24 #include <err.h> 25 #include <stdio.h> 26 #include <stdlib.h> 27 28 #include "util.h" 29 30 #ifdef ART 31 #include <net/rtable.h> 32 #include <net/art.h> 33 34 #include <assert.h> 35 36 extern void *rtable_get(unsigned int, sa_family_t); 37 #endif /* ART */ 38 39 __dead void 40 usage(void) 41 { 42 extern const char *__progname; 43 fprintf(stderr, "Usage: %s <file>\n", __progname); 44 exit(1); 45 } 46 47 int 48 main(int argc, char *argv[]) 49 { 50 char *filename; 51 52 if (argc != 2) 53 usage(); 54 55 filename = argv[1]; 56 57 rtable_init(); 58 59 do_from_file(0, AF_INET6, filename, route_insert); 60 61 rtable_walk(0, AF_INET6, NULL, rtentry_delete, NULL); 62 63 rtable_walk(0, AF_INET6, NULL, rtentry_dump, NULL); 64 65 #ifdef ART 66 struct art_root *ar; 67 ar = rtable_get(0, AF_INET6); 68 assert(ar != NULL); 69 assert(ar->ar_root.ref == NULL); 70 #endif /* ART */ 71 72 return (0); 73 } 74