Commit 19ddf571 authored by Leigh Stoller's avatar Leigh Stoller

Some PXE related stuff.

parent 37d79f28
INSTALL_BINDIR = /usr/testbed/bin
INSTALL = /usr/bin/install -c
CFLAGS = -g -DSOLARIS -DHAVE_SOCKADDR_SA_LEN -DUSE_RECVMSG
INCS = -I//n/moab/z/stoller/oskit-debug/install/include/oskit/boot
all: proxydhcp bootinfo
proxydhcp: proxydhcp.c
cc $(CFLAGS) -o proxydhcp proxydhcp.c $(LFLAGS)
bootinfo: bootinfo.c
cc $(CFLAGS) $(INCS) -o bootinfo bootinfo.c $(LFLAGS)
install: all
-mkdir $(INSTALL_BINDIR)
-mkdir $(INSTALL_BINDIR)/pxe
$(INSTALL) proxydhcp $(INSTALL_BINDIR)/pxe
$(INSTALL) -m 444 proxydhcp.conf $(INSTALL_BINDIR)/pxe
$(INSTALL) -m 755 proxydhcp.restart $(INSTALL_BINDIR)/pxe
$(INSTALL) bootinfo $(INSTALL_BINDIR)/pxe
$(INSTALL) -m 755 bootinfo.restart $(INSTALL_BINDIR)/pxe
clean:
rm proxydhcp bootinfo
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include "bootwhat.h"
/*
* For now, hardwired.
*/
#define NETBOOT "/tftpboot/netboot"
main()
{
int sock, length, data, i, mlen;
struct sockaddr_in name, client;
boot_info_t boot_info;
boot_what_t *boot_whatp = (boot_what_t *) &boot_info.data;
/* Create socket from which to read. */
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
perror("opening datagram socket");
exit(1);
}
/* Create name. */
name.sin_family = AF_INET;
name.sin_addr.s_addr = INADDR_ANY;
name.sin_port = htons(BOOTWHAT_DSTPORT);
if (bind(sock, (struct sockaddr *) &name, sizeof(name))) {
perror("binding datagram socket");
exit(1);
}
/* Find assigned port value and print it out. */
length = sizeof(name);
if (getsockname(sock, (struct sockaddr *) &name, &length)) {
perror("getting socket name");
exit(1);
}
printf("Socket has port #%d\n", ntohs(name.sin_port));
while (1) {
if ((mlen = recvfrom(sock, &boot_info, sizeof(boot_info),
0, (struct sockaddr *)&client, &length))
< 0) {
perror("receiving datagram packet");
exit(1);
}
printf("Datagram of %d bytes received from %s\n",
mlen, inet_ntoa(client.sin_addr));
if (boot_info.opcode != BIOPCODE_BOOTWHAT_REQUEST) {
printf("Throwing away invalid packet\n");
continue;
}
boot_info.opcode = BIOPCODE_BOOTWHAT_REPLY;
boot_info.status = BISTAT_SUCCESS;
#if 0
boot_whatp->type = BIBOOTWHAT_TYPE_MB;
boot_whatp->what.mb.tftp_ip.s_addr = 0;
strcpy(boot_whatp->what.mb.filename, NETBOOT);
#else
boot_whatp->type = BIBOOTWHAT_TYPE_SYSID;
boot_whatp->what.sysid = 165; /* BSD */
#endif
client.sin_family = AF_INET;
client.sin_port = htons(BOOTWHAT_SRCPORT);
if (sendto(sock, (char *)&boot_info, sizeof(boot_info), 0,
(struct sockaddr *)&client, sizeof(client)) < 0)
perror("sendto");
}
close(sock);
}
#!/bin/sh
DIR=/usr/testbed/bin/pxe
killall bootinfo
${DIR}/bootinfo > /dev/null 2>&1 &
This diff is collapsed.
# This is a comment.
# Client IP TFTPD IP File to boot
#
155.99.214.101 155.99.214.74 /tftpboot/pxeboot
155.99.214.102 155.99.214.74 /tftpboot/pxeboot
155.99.214.103 155.99.214.74 /tftpboot/pxeboot
155.99.214.104 155.99.214.74 /tftpboot/pxeboot
155.99.214.105 155.99.214.74 /tftpboot/pxeboot
155.99.214.106 155.99.214.74 /tftpboot/pxeboot
155.99.214.107 155.99.214.74 /tftpboot/pxeboot
155.99.214.109 155.99.214.74 /tftpboot/pxeboot
155.99.214.110 155.99.214.74 /tftpboot/pxeboot
155.99.214.111 155.99.214.74 /tftpboot/pxeboot
155.99.214.112 155.99.214.74 /tftpboot/pxeboot
155.99.214.113 155.99.214.74 /tftpboot/pxeboot
155.99.214.114 155.99.214.74 /tftpboot/pxeboot
155.99.214.115 155.99.214.74 /tftpboot/pxeboot
155.99.214.116 155.99.214.74 /tftpboot/pxeboot
155.99.214.117 155.99.214.74 /tftpboot/pxeboot
155.99.214.118 155.99.214.74 /tftpboot/pxeboot
155.99.214.119 155.99.214.74 /tftpboot/pxeboot
155.99.214.120 155.99.214.74 /tftpboot/pxeboot
155.99.214.121 155.99.214.74 /tftpboot/pxeboot
155.99.214.122 155.99.214.74 /tftpboot/pxeboot
155.99.214.123 155.99.214.74 /tftpboot/pxeboot
155.99.214.124 155.99.214.74 /tftpboot/pxeboot
155.99.214.125 155.99.214.74 /tftpboot/pxeboot
155.99.214.126 155.99.214.74 /tftpboot/pxeboot
155.99.214.127 155.99.214.74 /tftpboot/pxeboot
155.99.214.128 155.99.214.74 /tftpboot/pxeboot
155.99.214.129 155.99.214.74 /tftpboot/pxeboot
155.99.214.130 155.99.214.74 /tftpboot/pxeboot
155.99.214.131 155.99.214.74 /tftpboot/pxeboot
155.99.214.132 155.99.214.74 /tftpboot/pxeboot
155.99.214.133 155.99.214.74 /tftpboot/pxeboot
155.99.214.134 155.99.214.74 /tftpboot/pxeboot
155.99.214.135 155.99.214.74 /tftpboot/pxeboot
155.99.214.136 155.99.214.74 /tftpboot/pxeboot
155.99.214.137 155.99.214.74 /tftpboot/pxeboot
155.99.214.138 155.99.214.74 /tftpboot/pxeboot
155.99.214.139 155.99.214.74 /tftpboot/pxeboot
155.99.214.140 155.99.214.74 /tftpboot/pxeboot
#!/bin/sh
DIR=/usr/testbed/bin/pxe
killall proxydhcp
${DIR}/proxydhcp ${DIR}/proxydhcp.conf > /dev/null 2>&1 &
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment