Beispiel #1
0
func (r *Match) InPort() (wildcard bool, inport openflow.InPort) {
	r.mutex.Lock()
	defer r.mutex.Unlock()

	v, ok := r.m[OFPXMT_OFB_IN_PORT]
	if ok {
		inport = openflow.NewInPort()
		inport.SetValue(v.(uint32))
		return false, inport
	}

	return true, openflow.NewInPort()
}
Beispiel #2
0
func (r *flooder) flood(ingress *network.Port, packet []byte) error {
	f := ingress.Device().Factory()

	inPort := openflow.NewInPort()
	inPort.SetValue(ingress.Number())

	outPort := openflow.NewOutPort()
	outPort.SetFlood()

	action, err := f.NewAction()
	if err != nil {
		return err
	}
	action.SetOutPort(outPort)

	out, err := f.NewPacketOut()
	if err != nil {
		return err
	}
	out.SetInPort(inPort)
	out.SetAction(action)
	out.SetData(packet)

	return ingress.Device().SendMessage(out)
}
Beispiel #3
0
func sendLLDP(deviceID string, f openflow.Factory, w trans.Writer, p openflow.Port) error {
	lldp, err := newLLDPEtherFrame(deviceID, p)
	if err != nil {
		return err
	}

	outPort := openflow.NewOutPort()
	outPort.SetValue(p.Number())

	// Packet out to the port
	action, err := f.NewAction()
	if err != nil {
		return err
	}
	action.SetOutPort(outPort)

	out, err := f.NewPacketOut()
	if err != nil {
		return err
	}
	// From controller
	out.SetInPort(openflow.NewInPort())
	out.SetAction(action)
	out.SetData(lldp)

	return w.Write(out)
}
Beispiel #4
0
func (r *Device) SendARPAnnouncement(ip net.IP, mac net.HardwareAddr) error {
	// Write lock
	r.mutex.Lock()
	defer r.mutex.Unlock()

	if r.closed {
		return ErrClosedDevice
	}

	announcement, err := makeARPAnnouncement(ip, mac)
	if err != nil {
		return err
	}

	inPort := openflow.NewInPort()
	inPort.SetController()

	action, err := r.factory.NewAction()
	if err != nil {
		return err
	}
	// Flood
	action.SetOutPort(openflow.NewOutPort())

	out, err := r.factory.NewPacketOut()
	if err != nil {
		return err
	}
	out.SetInPort(inPort)
	out.SetAction(action)
	out.SetData(announcement)

	return r.session.Write(out)
}
Beispiel #5
0
func (r *BaseProcessor) PacketOut(egress *network.Port, packet []byte) error {
	f := egress.Device().Factory()

	inPort := openflow.NewInPort()
	inPort.SetController()

	outPort := openflow.NewOutPort()
	outPort.SetValue(egress.Number())

	action, err := f.NewAction()
	if err != nil {
		return err
	}
	action.SetOutPort(outPort)

	out, err := f.NewPacketOut()
	if err != nil {
		return err
	}
	out.SetInPort(inPort)
	out.SetAction(action)
	out.SetData(packet)

	return egress.Device().SendMessage(out)
}
Beispiel #6
0
func (r *Match) InPort() (wildcard bool, inport openflow.InPort) {
	v := openflow.NewInPort()
	v.SetValue(uint32(r.inPort))
	return r.wildcards.InPort, v
}