Exemple #1
0
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
}
Exemple #2
0
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
}
Exemple #3
0
func printVports(dpname string, dp odp.DatapathHandle) bool {
	vports, err := dp.EnumerateVports()
	if err != nil {
		return printErr("%s", err)
	}

	for _, vport := range vports {
		printVport("", dpname, vport)
	}

	return true
}