示例#1
0
文件: main.go 项目: awh/go-odp
func printFlowActions(as []odp.Action, dp odp.DatapathHandle) error {
	outputs := make([]string, 0)

	sort.Sort(ActionSlice(as))

	for _, a := range as {
		switch a := a.(type) {
		case odp.OutputAction:
			name, err := dp.LookupVportName(a.VportID())
			if err != nil {
				return err
			}

			outputs = append(outputs, name)
			break

		case odp.SetTunnelAction:
			printSetTunnelOptions(a)
			break

		default:
			fmt.Printf("%v", a)
			break
		}
	}

	if len(outputs) > 0 {
		fmt.Printf(" --output=%s", strings.Join(outputs, ","))
	}

	return nil
}
示例#2
0
文件: main.go 项目: yangzhares/go-odp
func printFlowKeys(fks odp.FlowKeys, dp odp.DatapathHandle) error {
	for _, fk := range fks {
		if fk.Ignored() {
			continue
		}

		switch fk := fk.(type) {
		case odp.InPortFlowKey:
			name, err := dp.LookupVportName(fk.VportID())
			if err != nil {
				return err
			}

			fmt.Printf(" --in-port=%s", name)
			break

		case odp.EthernetFlowKey:
			k := fk.Key()
			m := fk.Mask()
			printEthAddrOption("eth-src", k.EthSrc[:], m.EthSrc[:])
			printEthAddrOption("eth-dst", k.EthDst[:], m.EthDst[:])
			break

		case odp.TunnelFlowKey:
			printTunnelOptions(fk, "tunnel-")
			break

		default:
			fmt.Printf(" %T:%v", fk, fk)
			break
		}
	}

	return nil
}