Changeset 3138
- Timestamp:
- 07/11/08 14:15:55 (5 years ago)
- Location:
- branch/UMPA/umpa/protocols
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
branch/UMPA/umpa/protocols/IP.py
r3136 r3138 26 26 27 27 class HIHL(base.Field): 28 _bits = 4 28 29 def fillout(self): 29 30 pass 30 31 31 32 class HTotalLength(base.Field): 33 _bits = 16 32 34 def fillout(self): 33 35 pass 34 36 35 37 class HIdentification(base.Field): 38 _bits = 16 36 39 def fillout(self): 37 40 pass 38 41 39 42 class HFragmentOffset(base.Field): 43 _bits = 13 40 44 def fillout(self): 41 45 pass 42 46 43 47 class HProtocol(base.Field): 48 _bits = 8 44 49 def fillout(self): 45 50 pass 46 51 47 52 class HHeaderChecksum(base.Field): 48 def fillout(self): 49 pass 50 51 class HSourceAddress(base.Field): 52 def fillout(self): 53 pass 54 55 class HDestinationAddress(base.Field): 53 _bits = 16 56 54 def fillout(self): 57 55 pass 58 56 59 57 class HPadding(base.Field): 58 _bits = 0 60 59 def fillout(self): 61 60 pass … … 77 76 flags = ('reserved', 'df', 'mf') 78 77 79 fields_list = [ Field(4, 4, auto=True), HIHL( 4,auto=True),80 Flags(tos, auto=False), HTotalLength( 16,auto=True),81 HIdentification( 16,auto=True),78 fields_list = [ Field(4, 4, auto=True), HIHL(auto=True), 79 Flags(tos, auto=False), HTotalLength(auto=True), 80 HIdentification(auto=True), 82 81 Flags(flags, auto=False, reserved=0), 83 HFragmentOffset(13, auto=True), Field(8, 255), 84 HProtocol(8, auto=True), 85 HHeaderChecksum(16, auto=True), 82 HFragmentOffset(auto=True), Field(255, 8), 83 HProtocol(auto=True), HHeaderChecksum(auto=True), 86 84 Field(16), Field(16), Flags((), auto=True), 87 HPadding( 0,auto=True) ]85 HPadding(auto=True) ] 88 86 89 87 # we pack objects of header's fields to the dict -
branch/UMPA/umpa/protocols/base.py
r3137 r3138 23 23 24 24 class Field(object): 25 def __init__(self, bits, value=None, auto=False):25 def __init__(self, value=None, bits=None, auto=False): 26 26 """Set auto if you wish to take care about the field 27 27 by the library. Then you will have to write how 28 28 to manage the field. 29 29 """ 30 self._bits = bits 30 if bits is not None: 31 self._bits = bits 31 32 self._auto = auto 32 33 self._value = value … … 129 130 """ 130 131 # XXX: what if there is more than one Flags field in the protocol? 132 flag_field = None 131 133 for obj in self._fields: 132 134 if type(obj) == Flags:
