hodu/packet.go

59 lines
2.0 KiB
Go
Raw Normal View History

package hodu
func MakeRouteStartPacket(route_id uint32, proto ROUTE_PROTO, addr string) *Packet {
return &Packet{
Kind: PACKET_KIND_ROUTE_START,
U: &Packet_Route{Route: &RouteDesc{RouteId: route_id, Proto: proto, AddrStr: addr}}}
}
2024-11-24 11:39:51 +00:00
func MakeRouteStopPacket(route_id uint32, proto ROUTE_PROTO, addr string) *Packet {
return &Packet{
Kind: PACKET_KIND_ROUTE_STOP,
U: &Packet_Route{Route: &RouteDesc{RouteId: route_id, Proto: proto, AddrStr: addr}}}
}
func MakeRouteStartedPacket(route_id uint32, proto ROUTE_PROTO, addr string) *Packet {
// the connection from a peer to the server has been established
return &Packet{Kind: PACKET_KIND_ROUTE_STARTED,
U: &Packet_Route{Route: &RouteDesc{RouteId: route_id, Proto: proto, AddrStr: addr}}}
}
func MakeRouteStoppedPacket(route_id uint32, proto ROUTE_PROTO) *Packet {
// the connection from a peer to the server has been established
return &Packet{Kind: PACKET_KIND_ROUTE_STOPPED,
U: &Packet_Route{Route: &RouteDesc{RouteId: route_id, Proto: proto}}}
}
2024-11-19 15:48:02 +00:00
func MakePeerStartedPacket(route_id uint32, peer_id uint32) *Packet {
// the connection from a peer to the server has been established
return &Packet{Kind: PACKET_KIND_PEER_STARTED,
2024-11-19 15:48:02 +00:00
U: &Packet_Peer{Peer: &PeerDesc{RouteId: route_id, PeerId: peer_id}},
}
}
2024-11-19 15:48:02 +00:00
func MakePeerStoppedPacket(route_id uint32, peer_id uint32) *Packet {
return &Packet{Kind: PACKET_KIND_PEER_STOPPED,
2024-11-19 15:48:02 +00:00
U: &Packet_Peer{Peer: &PeerDesc{RouteId: route_id, PeerId: peer_id},
}}
}
2024-11-19 15:48:02 +00:00
func MakePeerAbortedPacket(route_id uint32, peer_id uint32) *Packet {
return &Packet{Kind: PACKET_KIND_PEER_ABORTED,
U: &Packet_Peer{Peer: &PeerDesc{RouteId: route_id, PeerId: peer_id},
}}
}
func MakePeerEofPacket(route_id uint32, peer_id uint32) *Packet {
2024-11-18 13:25:59 +00:00
return &Packet{Kind: PACKET_KIND_PEER_EOF,
2024-11-19 15:48:02 +00:00
U: &Packet_Peer{Peer: &PeerDesc{RouteId: route_id, PeerId: peer_id},
}}
}
2024-11-19 15:48:02 +00:00
func MakePeerDataPacket(route_id uint32, peer_id uint32, data []byte) *Packet {
return &Packet{Kind: PACKET_KIND_PEER_DATA,
2024-11-19 15:48:02 +00:00
U: &Packet_Data{Data: &PeerData{RouteId: route_id, PeerId: peer_id, Data: data},
}}
}