Example #1
0
File: main.go Project: 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
}
Example #2
0
func odpEthernetFlowKey(key PacketKey) FlowOp {
	fk := odp.NewEthernetFlowKey()
	fk.SetEthSrc(key.SrcMAC)
	fk.SetEthDst(key.DstMAC)
	return odpFlowKeyFlowOp{key: fk}
}