/usr/lib/python2.7/dist-packages/framework/cxnet/tcp.py is in fso-frameworkd 0.9.5.9+git20110512-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | """
TCP protocol primitives
"""
# Copyright (c) 2008 Peter V. Saveliev
#
# This file is part of Connexion project.
#
# Connexion is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Connexion is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Connexion; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from ctypes import *
from cxnet.generic import *
from cxnet.common import csum, csum_words, csum_complement
class tcphdr(BigEndianStructure):
_fields_ = [
("sport", c_uint16),
("dport", c_uint16),
("seq_num", c_uint32), # Sequence number
("ack_num", c_uint32), # Acknoledge number
("hdrlen", c_uint16, 4),
("reserved", c_uint16, 6),
("f_urg", c_uint16, 1), # TCP flags
("f_ack", c_uint16, 1), #
("f_psh", c_uint16, 1), #
("f_rst", c_uint16, 1), #
("f_syn", c_uint16, 1), #
("f_fin", c_uint16, 1), #
("window", c_uint16),
("chksum", c_uint16),
("urgptr", c_uint16),
]
class tcp_f_hdr(BigEndianStructure):
_fields_ = [
("daddr", c_uint32),
("saddr", c_uint32),
("reserved", c_uint8),
("protocol", c_uint8),
("tot_len", c_uint16),
]
def __init__(self):
BigEndianStructure.__init__(self)
self.protocol = 6
class tcp_f_comp(Structure):
_fields_ = [
("pseudo_hdr", tcp_f_hdr),
("real_hdr", tcphdr),
]
class TCPProtocol(GenericProtocol):
seq = None
p_hdr = None
inack = None
def __init__(self,p_hdr,hdr):
GenericProtocol.__init__(self,hdr)
self.p_hdr = p_hdr
self.inack = True
def seq(self):
self.hdr.seq_num += 1
def post(self,msg):
self.p_hdr.tot_len = sizeof(msg)
msg.hdr.hdrlen = sizeof(msg.hdr) / 4
msg.hdr.chksum = 0
#msg.hdr.chksum = csum(self.p_hdr,sizeof(self.p_hdr)) + csum(msg,sizeof(msg))
msg.hdr.chksum = csum_complement(csum_words(self.p_hdr,sizeof(self.p_hdr)) + csum_words(msg,sizeof(msg)))
return msg
|