Changeset 3221
- Timestamp:
- 07/26/08 03:30:11 (5 years ago)
- Location:
- branch/UMPA/umpa/protocols
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
branch/UMPA/umpa/protocols/IP.py
r3219 r3221 134 134 pass 135 135 136 class HPadding( IntField):136 class HPadding(PaddingField): 137 137 """The internet header padding is used to ensure that the internet header 138 138 ends on a 32 bit boundary. … … 142 142 bits = 0 143 143 auto = True 144 def _generate_value(self): 145 pass 144 145 def __init__(self, *args, **kwds): 146 super(HIHL, self).__init__(*args, **kwds) 147 self._temp_value = 0 148 149 def _generate_value(self): 150 return (32 - (self._temp_value % 32)) % 32 146 151 147 152 # main IP class … … 216 221 raw_value = 0 217 222 223 # Padding 224 self._fields['_padding']._temp_value = self._fields['options'].bits 225 218 226 # IHL 219 227 # we store sum of option and padding bits in the _temp_value -
branch/UMPA/umpa/protocols/_.py
r3220 r3221 93 93 """Check if a value is not bigger than expected. 94 94 """ 95 95 96 if 2**self.bits > val: 96 97 return True … … 131 132 return raw 132 133 134 class PaddingField(IntField): 135 def _is_valid(self, val): 136 if isinstance(val, int): 137 return True 138 return False 139 140 def fillout(self): 141 self._pre_fillout() 142 143 if not self._value: 144 self.bits = self._generate_value() 145 else: 146 self.bits = self._value 147 return self._raw_value() 148 149 def _raw_value(self): 150 return 0 133 151 134 152 class Flags(Field):
