Changeset 3173

Show
Ignore:
Timestamp:
07/19/08 13:01:24 (5 years ago)
Author:
getxsick
Message:

Example for gpolo of new IP.py

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/UMPA/umpa/protocols/IP.py

    r3169 r3173  
    2020# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  
    2121 
    22 import base 
    23  
    24 from base import Field, Flags 
     22from base import * 
    2523from umpa.utils.my_exceptions import UMPAAttributeException 
    2624 
    27 class HIHL(base.Field): 
    28     _bits = 4 
     25class HIHL(IntField): 
     26    bits = 4 
     27    def generate_value(self): 
     28        pass 
     29        # FIXME: how to get length of every fields in this scope? 
     30 
     31class HTotalLength(Field): 
     32    bits = 16 
    2933    def fillout(self): 
    3034        pass 
    3135 
    32 class HTotalLength(base.Field): 
    33     _bits = 16 
     36class HIdentification(Field): 
     37    bits = 16 
    3438    def fillout(self): 
    3539        pass 
    3640 
    37 class HIdentification(base.Field): 
    38     _bits = 16 
     41class HFragmentOffset(Field): 
     42    bits = 13 
    3943    def fillout(self): 
    4044        pass 
    4145 
    42 class HFragmentOffset(base.Field): 
    43     _bits = 13 
     46class HProtocol(Field): 
     47    bits = 8 
    4448    def fillout(self): 
    4549        pass 
    4650 
    47 class HProtocol(base.Field): 
    48     _bits = 8 
     51class HHeaderChecksum(Field): 
     52    bits = 16 
    4953    def fillout(self): 
    5054        pass 
    5155 
    52 class HHeaderChecksum(base.Field): 
    53     _bits = 16 
    54     def fillout(self): 
    55         pass 
    56  
    57 class HPadding(base.Field): 
    58     _bits = 0 
     56class HPadding(Field): 
     57    bits = 0 
    5958    def fillout(self): 
    6059        pass 
     
    6261# main IP class 
    6362 
    64 class IP(base.Protocol): 
     63class IP(Protocol): 
    6564    """This is Internet Protocol. 
    6665    The main protocol in third layer of OSI model. 
     
    7473 
    7574    def __init__(self, **kw): 
    76         base.Protocol.__init__(self, kw) 
     75        Protocol.__init__(self, kw) 
    7776 
    7877 
     
    8180        flags = ('reserved', 'df', 'mf') 
    8281 
    83         fields_list = [ Field(4, 4), HIHL(), Flags(tos), HTotalLength(), 
     82        fields_list = [ IntField(4, 4), HIHL(), Flags(tos), HTotalLength(), 
    8483                        HIdentification(), Flags(flags, reserved=0), 
    8584                        HFragmentOffset(), Field(255, 8), HProtocol(),