hodu/packet.go

47 lines
1.6 KiB
Go
Raw Normal View History

package main
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}}}
}
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}}}
}
func MakePeerStartedPacket(route_id uint32, pts_id uint32) *Packet {
// the connection from a peer to the server has been established
return &Packet{Kind: PACKET_KIND_PEER_STARTED,
U: &Packet_Peer{Peer: &PeerDesc{RouteId: route_id, PeerId: pts_id}},
}
}
func MakePeerStoppedPacket(route_id uint32, pts_id uint32) *Packet {
return &Packet{Kind: PACKET_KIND_PEER_STOPPED,
U: &Packet_Peer{Peer: &PeerDesc{RouteId: route_id, PeerId: pts_id},
}}
}
2024-11-18 13:25:59 +00:00
func MakePeerEofPacket(route_id uint32, pts_id uint32) *Packet {
return &Packet{Kind: PACKET_KIND_PEER_EOF,
U: &Packet_Peer{Peer: &PeerDesc{RouteId: route_id, PeerId: pts_id},
}}
}
func MakePeerDataPacket(route_id uint32, pts_id uint32, data []byte) *Packet {
return &Packet{Kind: PACKET_KIND_PEER_DATA,
U: &Packet_Data{Data: &PeerData{RouteId: route_id, PeerId: pts_id, Data: data},
}}
}