MCPcopy Create free account
hub / github.com/F-Stack/f-stack / newroute

Function newroute

tools/route/route.c:874–1191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

872#define F_INTERFACE 0x10
873
874static void
875newroute(int argc, char **argv)
876{
877 struct sigaction sa;
878 struct hostent *hp;
879 struct fibl *fl;
880 char *cmd;
881 const char *dest, *gateway, *errmsg;
882 int key, error, flags, nrflags, fibnum;
883
884 if (uid != 0 && !debugonly && !tflag)
885 errx(EX_NOPERM, "must be root to alter routing table");
886 dest = NULL;
887 gateway = NULL;
888 flags = RTF_STATIC;
889 nrflags = 0;
890 hp = NULL;
891 TAILQ_INIT(&fibl_head);
892
893 sigemptyset(&sa.sa_mask);
894 sa.sa_flags = 0;
895 sa.sa_handler = stopit;
896 if (sigaction(SIGALRM, &sa, 0) == -1)
897 warn("sigaction SIGALRM");
898
899 cmd = argv[0];
900 if (*cmd != 'g' && *cmd != 's')
901 shutdown(s, SHUT_RD); /* Don't want to read back our messages */
902 while (--argc > 0) {
903 if (**(++argv)== '-') {
904 switch (key = keyword(1 + *argv)) {
905 case K_LINK:
906 af = AF_LINK;
907 aflen = sizeof(struct sockaddr_dl);
908 break;
909#ifdef INET
910 case K_4:
911 case K_INET:
912 af = AF_INET;
913 aflen = sizeof(struct sockaddr_in);
914 break;
915#endif
916#ifdef INET6
917 case K_6:
918 case K_INET6:
919 af = AF_INET6;
920 aflen = sizeof(struct sockaddr_in6);
921 break;
922#endif
923 case K_SA:
924 af = PF_ROUTE;
925 aflen = sizeof(struct sockaddr_storage);
926 break;
927 case K_IFACE:
928 case K_INTERFACE:
929 nrflags |= F_INTERFACE;
930 break;
931 case K_NOSTATIC:

Callers 1

route.cFile · 0.85

Calls 12

shutdownFunction · 0.85
keywordFunction · 0.85
fiboptlist_csvFunction · 0.85
prefixlenFunction · 0.85
set_metricFunction · 0.85
memsetFunction · 0.85
newroute_fibFunction · 0.85
ff_ipc_exitFunction · 0.85
sigactionClass · 0.70
usageFunction · 0.70
getaddrFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected