1 /* $OpenBSD: main.c,v 1.4 2016/07/19 10:52:56 mpi 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 if (rtable_add(0)) 59 errx(1, "can't add rtable\n"); 60 61 do_from_file(0, AF_INET6, filename, route_insert); 62 63 rtable_walk(0, AF_INET6, rtentry_delete, NULL); 64 65 rtable_walk(0, AF_INET6, rtentry_dump, NULL); 66 67 #ifdef ART 68 struct art_root *ar; 69 ar = rtable_get(0, AF_INET6); 70 assert(ar != NULL); 71 assert(ar->ar_root.ref == NULL); 72 #endif /* ART */ 73 74 return (0); 75 } 76