コード例 #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})
}
コード例 #2
0
// headersEqual compares a response and request AoE header for equality, but
// does not factor in their Arg fields.
func headersEqual(res, req aoe.Header) bool {
	if !res.FlagResponse {
		panic("response AoE header did not have FlagResponse set, please verify parameter order")
	}

	// Set request's response flag for comparison
	req.FlagResponse = true

	// Clear arguments of both request and response so we can compare the
	// headers, and because the arguments are compared separately
	req.Arg = nil
	res.Arg = nil

	return reflect.DeepEqual(res, req)
}