mirror of
https://github.com/danderson/netboot.git
synced 2025-08-12 17:47:18 +02:00
Added bootipv6 command
This commit is contained in:
parent
3a5808cb30
commit
cb79b8eaa4
@ -16,30 +16,28 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go.universe.tf/netboot/pixiecore"
|
"go.universe.tf/netboot/pixiecore"
|
||||||
// "go.universe.tf/netboot/pixiecore/cli"
|
"go.universe.tf/netboot/pixiecore/cli"
|
||||||
// "go.universe.tf/netboot/third_party/ipxe"
|
"go.universe.tf/netboot/third_party/ipxe"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// qemu-system-x86_64 -L . --bios /usr/share/edk2-firmware/ipv6/OVMF.fd -netdev bridge,br=br1,id=net0 -device virtio-net-pci,netdev=net0
|
// qemu-system-x86_64 -L . --bios /usr/share/edk2-firmware/ipv6/OVMF.fd -netdev bridge,br=br1,id=net0 -device virtio-net-pci,netdev=net0
|
||||||
func main() {
|
func main() {
|
||||||
/*cli.Ipxe[pixiecore.FirmwareX86PC] = ipxe.MustAsset("undionly.kpxe")
|
cli.Ipxe[pixiecore.FirmwareX86PC] = ipxe.MustAsset("undionly.kpxe")
|
||||||
cli.Ipxe[pixiecore.FirmwareEFI32] = ipxe.MustAsset("ipxe-i386.efi")
|
cli.Ipxe[pixiecore.FirmwareEFI32] = ipxe.MustAsset("ipxe-i386.efi")
|
||||||
cli.Ipxe[pixiecore.FirmwareEFI64] = ipxe.MustAsset("ipxe-x86_64.efi")
|
cli.Ipxe[pixiecore.FirmwareEFI64] = ipxe.MustAsset("ipxe-x86_64.efi")
|
||||||
cli.Ipxe[pixiecore.FirmwareEFIBC] = ipxe.MustAsset("ipxe-x86_64.efi")
|
cli.Ipxe[pixiecore.FirmwareEFIBC] = ipxe.MustAsset("ipxe-x86_64.efi")
|
||||||
cli.Ipxe[pixiecore.FirmwareX86Ipxe] = ipxe.MustAsset("ipxe.pxe")
|
cli.Ipxe[pixiecore.FirmwareX86Ipxe] = ipxe.MustAsset("ipxe.pxe")
|
||||||
cli.CLI()
|
cli.CLI()
|
||||||
*/
|
|
||||||
|
|
||||||
log := func(subsystem, msg string) { fmt.Printf("[%s] %s", subsystem, msg) }
|
//log := func(subsystem, msg string) { fmt.Printf("[%s] %s", subsystem, msg) }
|
||||||
s := pixiecore.ServerV6{
|
//s := pixiecore.ServerV6{
|
||||||
Address: "2001:db8:f00f:cafe::4/64",
|
// Address: "2001:db8:f00f:cafe::4/64",
|
||||||
Log: log,
|
// Log: log,
|
||||||
Debug: log,
|
// Debug: log,
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
err := s.Serve()
|
//err := s.Serve()
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
fmt.Printf("Error: %s", err)
|
// fmt.Printf("Error: %s", err)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,14 @@ type Conn struct {
|
|||||||
listenPort string
|
listenPort string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConn(addr string) (*Conn, error) {
|
func NewConn(addr, port string) (*Conn, error) {
|
||||||
ifi, err := InterfaceIndexByAddress(addr)
|
ifi, err := InterfaceIndexByAddress(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
group := net.ParseIP("ff02::1:2")
|
group := net.ParseIP("ff02::1:2")
|
||||||
c, err := net.ListenPacket("udp6", "[::]:547")
|
c, err := net.ListenPacket("udp6", "[::]:" + port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ func NewConn(addr string) (*Conn, error) {
|
|||||||
group: group,
|
group: group,
|
||||||
ifi: ifi,
|
ifi: ifi,
|
||||||
listenAddress: addr,
|
listenAddress: addr,
|
||||||
listenPort: "547",
|
listenPort: port,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +164,8 @@ func (p *Packet) ShouldDiscard(serverDuid []byte) error {
|
|||||||
return ShouldDiscardRequest(p, serverDuid)
|
return ShouldDiscardRequest(p, serverDuid)
|
||||||
case MsgInformationRequest:
|
case MsgInformationRequest:
|
||||||
return ShouldDiscardInformationRequest(p, serverDuid)
|
return ShouldDiscardInformationRequest(p, serverDuid)
|
||||||
|
case MsgRelease:
|
||||||
|
return nil // FIX ME!
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unknown packet")
|
return fmt.Errorf("Unknown packet")
|
||||||
}
|
}
|
||||||
|
56
pixiecore/cli/bootipv6cmd.go
Normal file
56
pixiecore/cli/bootipv6cmd.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"go.universe.tf/netboot/pixiecore"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var bootIPv6Cmd = &cobra.Command{
|
||||||
|
Use: "bootipv6",
|
||||||
|
Short: "Boot a kernel and optional init ramdisks over IPv6",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
addr, err := cmd.Flags().GetString("listen-addr")
|
||||||
|
if err != nil {
|
||||||
|
fatalf("Error reading flag: %s", err)
|
||||||
|
}
|
||||||
|
ipxeUrl, err := cmd.Flags().GetString("ipxe-url")
|
||||||
|
if err != nil {
|
||||||
|
fatalf("Error reading flag: %s", err)
|
||||||
|
}
|
||||||
|
httpBootUrl, err := cmd.Flags().GetString("httpboot-url")
|
||||||
|
if err != nil {
|
||||||
|
fatalf("Error reading flag: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
s := pixiecore.NewServerV6()
|
||||||
|
|
||||||
|
if addr == "" {
|
||||||
|
fatalf("Please specify address to listen on")
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
if ipxeUrl == "" {
|
||||||
|
fatalf("Please specify ipxe config file url")
|
||||||
|
}
|
||||||
|
if httpBootUrl == "" {
|
||||||
|
fatalf("Please specify httpboot url")
|
||||||
|
}
|
||||||
|
|
||||||
|
s.Address = addr
|
||||||
|
s.IPxeUrl = ipxeUrl
|
||||||
|
s.HttpbootUrl = httpBootUrl
|
||||||
|
|
||||||
|
fmt.Println(s.Serve())
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func serverv6ConfigFlags(cmd *cobra.Command) {
|
||||||
|
cmd.Flags().StringP("listen-addr", "", "", "IPv6 address to listen on")
|
||||||
|
cmd.Flags().StringP("ipxe-url", "", "", "IPXE config file url, e.g. http://[2001:db8:f00f:cafe::4]/script.ipxe")
|
||||||
|
cmd.Flags().StringP("httpboot-url", "", "", "HTTPBoot url, e.g. http://[2001:db8:f00f:cafe::4]/bootx64.efi")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(bootIPv6Cmd)
|
||||||
|
serverv6ConfigFlags(bootIPv6Cmd)
|
||||||
|
}
|
@ -13,6 +13,8 @@ type ServerV6 struct {
|
|||||||
Address string
|
Address string
|
||||||
Port string
|
Port string
|
||||||
Duid []byte
|
Duid []byte
|
||||||
|
IPxeUrl string
|
||||||
|
HttpbootUrl string
|
||||||
|
|
||||||
errs chan error
|
errs chan error
|
||||||
|
|
||||||
@ -23,10 +25,20 @@ type ServerV6 struct {
|
|||||||
Debug func(subsystem, msg string)
|
Debug func(subsystem, msg string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewServerV6() *ServerV6 {
|
||||||
|
log := func(subsystem, msg string) { fmt.Printf("[%s] %s", subsystem, msg) }
|
||||||
|
ret := &ServerV6{
|
||||||
|
Port: "547",
|
||||||
|
Log: log,
|
||||||
|
Debug: log,
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ServerV6) Serve() error {
|
func (s *ServerV6) Serve() error {
|
||||||
s.log("dhcp", "starting...")
|
s.log("dhcp", "starting...")
|
||||||
|
|
||||||
dhcp, err := dhcp6.NewConn(s.Address)
|
dhcp, err := dhcp6.NewConn(s.Address, s.Port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user