Changeset View
Changeset View
Standalone View
Standalone View
sys/nfs/bootp_subr.c
Show First 20 Lines • Show All 971 Lines • ▼ Show 20 Lines | bootpc_adjust_interface(struct bootpc_ifcontext *ifctx, | ||||
error = ifioctl(bootp_so, SIOCAIFADDR, (caddr_t)ifra, td); | error = ifioctl(bootp_so, SIOCAIFADDR, (caddr_t)ifra, td); | ||||
if (error != 0) | if (error != 0) | ||||
panic("%s: SIOCAIFADDR, error=%d", __func__, error); | panic("%s: SIOCAIFADDR, error=%d", __func__, error); | ||||
} | } | ||||
static void | static void | ||||
bootpc_add_default_route(struct bootpc_ifcontext *ifctx) | bootpc_add_default_route(struct bootpc_ifcontext *ifctx) | ||||
{ | { | ||||
struct rib_cmd_info rc = {}; | |||||
int error; | int error; | ||||
struct sockaddr_in defdst; | |||||
struct sockaddr_in defmask; | |||||
struct rt_addrinfo info; | |||||
struct rib_cmd_info rc; | |||||
if (ifctx->gw.sin_addr.s_addr == htonl(INADDR_ANY)) | if (ifctx->gw.sin_addr.s_addr == htonl(INADDR_ANY)) | ||||
return; | return; | ||||
clear_sinaddr(&defdst); | error = rib_add_default_route(RT_DEFAULT_FIB, AF_INET, | ||||
clear_sinaddr(&defmask); | ifctx->ifp, (struct sockaddr *)&ifctx->gw, &rc); | ||||
bzero((caddr_t)&info, sizeof(info)); | |||||
info.rti_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC; | |||||
info.rti_info[RTAX_DST] = (struct sockaddr *)&defdst; | |||||
info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&defmask; | |||||
info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&ifctx->gw; | |||||
error = rib_action(RT_DEFAULT_FIB, RTM_ADD, &info, &rc); | |||||
if (error != 0) { | if (error != 0) { | ||||
printf("%s: RTM_ADD, error=%d\n", __func__, error); | printf("%s: RTM_ADD, error=%d\n", __func__, error); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
bootpc_remove_default_route(struct bootpc_ifcontext *ifctx) | bootpc_remove_default_route(struct bootpc_ifcontext *ifctx) | ||||
{ | { | ||||
int error; | int error; | ||||
struct sockaddr_in defdst; | struct sockaddr_in dst; | ||||
struct sockaddr_in defmask; | |||||
struct rt_addrinfo info; | |||||
struct rib_cmd_info rc; | struct rib_cmd_info rc; | ||||
if (ifctx->gw.sin_addr.s_addr == htonl(INADDR_ANY)) | if (ifctx->gw.sin_addr.s_addr == htonl(INADDR_ANY)) | ||||
return; | return; | ||||
clear_sinaddr(&defdst); | clear_sinaddr(&dst); | ||||
clear_sinaddr(&defmask); | |||||
bzero((caddr_t)&info, sizeof(info)); | error = rib_del_route_px(RT_DEFAULT_FIB, (struct sockaddr *)&dst, 0, | ||||
info.rti_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC; | rib_match_gw, (struct sockaddr *)&ifctx->gw, 0, &rc); | ||||
info.rti_info[RTAX_DST] = (struct sockaddr *)&defdst; | |||||
info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&defmask; | |||||
info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&ifctx->gw; | |||||
error = rib_action(RT_DEFAULT_FIB, RTM_DELETE, &info, &rc); | |||||
if (error != 0) { | if (error != 0) { | ||||
printf("%s: RTM_DELETE, error=%d\n", __func__, error); | printf("%s: RTM_DELETE, error=%d\n", __func__, error); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
setfs(struct sockaddr_in *addr, char *path, char *p, | setfs(struct sockaddr_in *addr, char *path, char *p, | ||||
const struct in_addr *siaddr) | const struct in_addr *siaddr) | ||||
▲ Show 20 Lines • Show All 815 Lines • Show Last 20 Lines |