func doHandleEchoRequest(req of.Header, res of.Header, c *ofConn) error { glog.V(2).Infof("Received echo request from %v", c.node) res.SetXid(req.Xid()) err := c.WriteHeaders([]of.Header{res}) if err != nil { return err } c.Flush() glog.V(2).Infof("Sent echo reply to %v", c.node) return nil }
func (d *of10Driver) handlePkt(pkt of.Header, c *ofConn) error { pkt10, err := of10.ToHeader10(pkt) if err != nil { return err } switch { case of10.IsEchoRequest(pkt10): return d.handleEchoRequest(of10.NewEchoRequestWithBuf(pkt10.Buf), c) case of10.IsFeaturesReply(pkt10): return d.handleFeaturesReply(of10.NewFeaturesReplyWithBuf(pkt10.Buf), c) case of10.IsPacketIn(pkt10): return d.handlePacketIn(of10.NewPacketInWithBuf(pkt10.Buf), c) case of10.IsErrorMsg(pkt10): return d.handleErrorMsg(of10.NewErrorMsgWithBuf(pkt10.Buf), c) case of10.IsStatsReply(pkt10): return d.handleStatsReply(of10.NewStatsReplyWithBuf(pkt10.Buf), c) default: return fmt.Errorf("Received unsupported packet: %v", pkt.Type()) } }
func (d *of12Driver) handlePkt(pkt of.Header, c *ofConn) error { pkt12, err := of12.ToHeader12(pkt) if err != nil { return err } switch { case of12.IsEchoRequest(pkt12): return d.handleEchoRequest(of12.NewEchoRequestWithBuf(pkt12.Buf), c) case of12.IsFeaturesReply(pkt12): return d.handleFeaturesReply(of12.NewFeaturesReplyWithBuf(pkt12.Buf), c) case of12.IsPacketIn(pkt12): return d.handlePacketIn(of12.NewPacketInWithBuf(pkt12.Buf), c) case of12.IsErrorMsg(pkt12): return d.handleErrorMsg(of12.NewErrorMsgWithBuf(pkt12.Buf), c) case of12.IsStatsReply(pkt12): return d.handleStatsReply(of12.NewStatsReplyWithBuf(pkt12.Buf), c) case of12.IsRoleReply(pkt12): return d.handleRoleReply(of12.NewRoleReplyWithBuf(pkt12.Buf), c) default: glog.Errorf("received unsupported packet: %v", pkt.Type()) return nil } }