code: func (p *Packet) MarshalBinary() ([]byte, error) {
  	b := uio.NewBigEndianBuffer(make([]byte, 0, minPacketLen))
  	b.Write8(uint8(p.Op))
  	b.Write8(p.HType)
  
  	// HLen
  	b.Write8(uint8(len(p.CHAddr)))
  	b.Write8(p.Hops)
  	b.WriteBytes(p.TransactionID[:])
  	b.Write16(p.Secs)
  
  	var flags uint16
  	if p.Broadcast {
  		flags |= flagBroadcast
  	}
  	b.Write16(flags)
  
  	writeIP(b, p.CIAddr)
  	writeIP(b, p.YIAddr)
  	writeIP(b, p.SIAddr)
  	writeIP(b, p.GIAddr)
  	copy(b.WriteN(chaddrLen), p.CHAddr)
  
  	var sname [64]byte
  	copy(sname[:], []byte(p.ServerName))
  	sname[len(p.ServerName)] = 0
  	b.WriteBytes(sname[:])
  
  	var file [128]byte
  	copy(file[:], []byte(p.BootFile))
  	file[len(p.BootFile)] = 0
  	b.WriteBytes(file[:])
  
  	// The magic cookie.
  	b.WriteBytes(magicCookie[:])
  
  	p.Options.Marshal(b)
  	// TODO pad to 272 bytes for really old crap.
  	return b.Data(), nil
  }
docs: // MarshalBinary writes the packet to binary.