コード例 #1
0
func (fs *FrameSender) Send(hdr *aoe.Header) (int, error) {
	hdr.Version = 1
	hdr.FlagResponse = true
	hdr.Major = fs.major
	hdr.Minor = fs.minor
	hdr.Tag = fs.orig.Tag

	hbuf, err := hdr.MarshalBinary()
	if err != nil {
		panic(err)
	}

	frame := &ethernet.Frame{
		Destination: fs.dst,
		Source:      fs.src,
		EtherType:   aoe.EtherType,
		Payload:     hbuf,
	}

	ebuf, err := frame.MarshalBinary()
	if err != nil {
		panic(err)
	}

	clog.Debugf("send %d %s %+v", len(ebuf), fs.dst, hdr)
	//clog.Debugf("send arg %+v", hdr.Arg)

	return fs.conn.WriteTo(ebuf, &raw.Addr{HardwareAddr: fs.dst})
}