示例#1
0
文件: main.go 项目: awh/go-odp
func handleEthernetFlowKeyOptions(flow odp.FlowSpec, src string, dst string) error {
	var err error
	takeErr := func(key [ETH_ALEN]byte, mask [ETH_ALEN]byte,
		e error) ([ETH_ALEN]byte, [ETH_ALEN]byte) {
		err = e
		return key, mask
	}

	fk := odp.NewEthernetFlowKey()

	fk.SetMaskedEthSrc(takeErr(handleEthernetAddrOption(src)))
	fk.SetMaskedEthDst(takeErr(handleEthernetAddrOption(dst)))

	if err != nil {
		return err
	}

	flow.AddKey(fk)
	return nil
}
示例#2
0
func odpEthernetFlowKey(key PacketKey) FlowOp {
	fk := odp.NewEthernetFlowKey()
	fk.SetEthSrc(key.SrcMAC)
	fk.SetEthDst(key.DstMAC)
	return odpFlowKeyFlowOp{key: fk}
}