Changeset View
Changeset View
Standalone View
Standalone View
head/sys/boot/i386/libi386/pxe.c
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
extern struct netif_stats pxe_st[]; | extern struct netif_stats pxe_st[]; | ||||
extern u_int16_t __bangpxeseg; | extern u_int16_t __bangpxeseg; | ||||
extern u_int16_t __bangpxeoff; | extern u_int16_t __bangpxeoff; | ||||
extern void __bangpxeentry(void); | extern void __bangpxeentry(void); | ||||
extern u_int16_t __pxenvseg; | extern u_int16_t __pxenvseg; | ||||
extern u_int16_t __pxenvoff; | extern u_int16_t __pxenvoff; | ||||
extern void __pxenventry(void); | extern void __pxenventry(void); | ||||
extern struct in_addr servip; | |||||
struct netif_dif pxe_ifs[] = { | struct netif_dif pxe_ifs[] = { | ||||
/* dif_unit dif_nsel dif_stats dif_private */ | /* dif_unit dif_nsel dif_stats dif_private */ | ||||
{0, 1, &pxe_st[0], 0} | {0, 1, &pxe_st[0], 0} | ||||
}; | }; | ||||
struct netif_stats pxe_st[NENTS(pxe_ifs)]; | struct netif_stats pxe_st[NENTS(pxe_ifs)]; | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | if (pxe_opens == 0) { | ||||
if (pxe_sock < 0) { | if (pxe_sock < 0) { | ||||
pxe_sock = netif_open(devname); | pxe_sock = netif_open(devname); | ||||
if (pxe_sock < 0) { | if (pxe_sock < 0) { | ||||
printf("pxe_open: netif_open() failed\n"); | printf("pxe_open: netif_open() failed\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
if (pxe_debug) | if (pxe_debug) | ||||
printf("pxe_open: netif_open() succeeded\n"); | printf("pxe_open: netif_open() succeeded\n"); | ||||
if (socktodesc(pxe_sock) == NULL) { | |||||
printf("pxe_open: bad socket %d\n", pxe_sock); | |||||
return (ENXIO); | |||||
} | } | ||||
} | |||||
if (rootip.s_addr == 0) { | if (rootip.s_addr == 0) { | ||||
/* | /* | ||||
* Do a bootp/dhcp request to find out where our | * Try to extract the RFC1048 data from PXE. | ||||
* If fail do a bootp/dhcp request to find out where our | |||||
* NFS/TFTP server is. Even if we dont get back | * NFS/TFTP server is. Even if we dont get back | ||||
* the proper information, fall back to the server | * the proper information, fall back to the server | ||||
* which brought us to life and a default rootpath. | * which brought us to life and a default rootpath. | ||||
*/ | */ | ||||
if (dhcp_try_rfc1048(bootplayer.vendor.d, BOOTP_DHCPVEND) < 0) { | |||||
if (pxe_debug) | |||||
printf("pxe_open: no RFC1048 data in PXE Cache\n"); | |||||
bootp(pxe_sock, BOOTP_PXE); | bootp(pxe_sock, BOOTP_PXE); | ||||
} else if (pxe_debug) { | |||||
printf("pxe_open: loaded RFC1048 data from PXE Cache\n"); | |||||
} | |||||
if (rootip.s_addr == 0) | if (rootip.s_addr == 0) | ||||
rootip.s_addr = bootplayer.sip; | rootip.s_addr = bootplayer.sip; | ||||
if (gateip.s_addr == 0) | |||||
gateip.s_addr = bootplayer.gip; | |||||
if (myip.s_addr == 0) | |||||
myip.s_addr = bootplayer.yip; | |||||
if (servip.s_addr == 0) | |||||
servip = rootip; | |||||
netproto = NET_NFS; | netproto = NET_NFS; | ||||
if (tftpip.s_addr != 0) { | if (tftpip.s_addr != 0) { | ||||
netproto = NET_TFTP; | netproto = NET_TFTP; | ||||
rootip.s_addr = tftpip.s_addr; | rootip.s_addr = tftpip.s_addr; | ||||
} | } | ||||
if (netproto == NET_NFS && !rootpath[0]) | if (netproto == NET_NFS && !rootpath[0]) | ||||
Show All 20 Lines | if (rootip.s_addr == 0) { | ||||
if (intf_mtu != 0) { | if (intf_mtu != 0) { | ||||
char mtu[16]; | char mtu[16]; | ||||
sprintf(mtu, "%u", intf_mtu); | sprintf(mtu, "%u", intf_mtu); | ||||
setenv("boot.netif.mtu", mtu, 1); | setenv("boot.netif.mtu", mtu, 1); | ||||
} | } | ||||
printf("pxe_open: server addr: %s\n", inet_ntoa(rootip)); | printf("pxe_open: server addr: %s\n", inet_ntoa(rootip)); | ||||
printf("pxe_open: server path: %s\n", rootpath); | printf("pxe_open: server path: %s\n", rootpath); | ||||
printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip)); | printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip)); | ||||
printf("pxe_open: my ip: %s\n", inet_ntoa(myip)); | |||||
printf("pxe_open: netmask: %s\n", intoa(netmask)); | |||||
printf("pxe_open: servip: %s\n", inet_ntoa(servip)); | |||||
if (netproto == NET_TFTP) { | if (netproto == NET_TFTP) { | ||||
setenv("boot.tftproot.server", inet_ntoa(rootip), 1); | setenv("boot.tftproot.server", inet_ntoa(rootip), 1); | ||||
setenv("boot.tftproot.path", rootpath, 1); | setenv("boot.tftproot.path", rootpath, 1); | ||||
} else if (netproto == NET_NFS) { | } else if (netproto == NET_NFS) { | ||||
setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); | setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); | ||||
setenv("boot.nfsroot.path", rootpath, 1); | setenv("boot.nfsroot.path", rootpath, 1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 391 Lines • Show Last 20 Lines |