From f07586a12e57cd995fbfaf135dc770187ce696b9 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Mon, 30 Sep 2013 09:26:07 +0200 Subject: [PATCH] isIncomingDataPacket should be struct function --- listener/raw_tcp_listener.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/listener/raw_tcp_listener.go b/listener/raw_tcp_listener.go index fc810fe..81e9ed8 100644 --- a/listener/raw_tcp_listener.go +++ b/listener/raw_tcp_listener.go @@ -83,7 +83,7 @@ func (t *RAWTCPListener) readRAWSocket() { } func (t *RAWTCPListener) parsePacket(buf []byte) { - if isIncomingDataPacket(buf, t.port) { + if t.isIncomingDataPacket(buf) { new_buf := make([]byte, len(buf)) copy(new_buf, buf) @@ -91,13 +91,13 @@ func (t *RAWTCPListener) parsePacket(buf []byte) { } } -func isIncomingDataPacket(buf []byte, port int) bool { +func (t *RAWTCPListener) isIncomingDataPacket(buf []byte) bool { // To avoid full packet parsing every time, we manually parsing values needed for packet filtering // http://en.wikipedia.org/wiki/Transmission_Control_Protocol dest_port := binary.BigEndian.Uint16(buf[2:4]) // Because RAW_SOCKET can't be bound to port, we have to control it by ourself - if int(dest_port) == port { + if int(dest_port) == t.port { // Check TCPPacket code for more description flags := binary.BigEndian.Uint16(buf[12:14]) & 0x1FF