コード例 #1
0
ファイル: TS24007.py プロジェクト: eerimoq/pycrate
 def _from_char(self, char):
     if self[-1]._name != 'V':
         # restore the std buffer for handling the value
         self.unset_IE()
     Envelope._from_char(self, char)
     # in case self._IE is defined, use it to decode char instead of V
     if self.DECODE_INNER and self._IE_stat is not None:
         if self._IE is None:
             self._IE = self._IE_stat.clone()
         iebl = self[-1].get_bl()
         ccur, clen = char._cur, char._len_bit
         char._cur -= iebl
         char._len_bit = char._cur + iebl
         try:
             self._IE._from_char(char)
         except:
             log('%s, _from_char: unable to decode IE, %s'\
                 % (self._name, self._IE._name))
         else:
             if char.len_bit() > 0:
                 log('%s, _from_char: uncorrect decoding for IE, %s'\
                     % (self._name, self._IE._name))
             else:
                 # replace V with the IE structure
                 self.replace(self[-1], self._IE)
         char._cur, char._len_bit = ccur, clen
コード例 #2
0
ファイル: TS24007.py プロジェクト: eerimoq/pycrate
 def _from_char(self, char):
     # in case some optional IE are set (with transparency enabled)
     # they are decoded as much as the char buffer allows it
     # 1) decode mandatory part
     Envelope._from_char(self, char)
     # 2) decode optional part
     opts = self._opts[:]
     while char.len_bit() >= 8:
         T4, T8, dec = char.to_uint(4), char.to_uint(8), False
         for i, opt in enumerate(opts):
             # check the list of optional IEs in order
             # opt[0] is the tag length: 4 or 8
             # opt[1] is the tag value: 0 <= T <= 255
             if (opt[0] == 4 and opt[1] == T4) or opt[1] == T8:
                 opt[2]._trans = False
                 opt[2]._from_char(char)
                 dec = True
                 del opts[i]
                 break
         if not dec:
             # unknown IEI
             if self.DEC_BREAK_ON_UNK_IE:
                 log('%s, unknown IE remaining, not decoded' % self._name)
                 break
             else:
                 char._cur += 8
                 self._dec_unk_ie(T8, char)
コード例 #3
0
ファイル: TS24007.py プロジェクト: gteissier/pycrate
 def _from_char(self, char):
     Envelope._from_char(self, char)
     # in case self._IE is defined, use it to decode char instead of V
     if self._IE is not None:
         iebl = self[-1].get_bl()
         char_cur = char._cur
         char_lb = char._len_bit
         char._cur -= iebl
         char._len_bit = char._cur + iebl
         try:
             self._IE._from_char(char)
         except:
             log('%s, _from_char: unable to decode IE, %s'\
                 % (self._name, self._IE._name))
         else:
             if char.len_bit() > 0:
                 log('%s, _from_char: uncorrect decoding for IE, %s'\
                     % (self._name, self._IE._name))
             else:
                 # save the V buffer
                 self._V = self[-1]
                 # replace it with the IE structure
                 self.replace(self[-1], self._IE)
                 if self[-2]._name == 'L':
                     # Type4 and Type6
                     self[-2].set_valauto(self[-1].get_len)
         char._cur = char_cur
         char._len_bit = char_lb
コード例 #4
0
ファイル: TS24007.py プロジェクト: terry2012/pycrate
 def _from_char(self, char):
     if self[0]._name != 'V':
         # restore the std buffer for handling the value
         self.unset_IE()
     #
     # TODO: investigate the cause to have this dirty patch within some pcaps
     # and remove it as soon as possible
     robl, chbl = self[0]._blauto(), char.len_bit()
     if chbl < robl:
         log('%s, _from_char: buffer not long enough, requests %i, max %i'\
             % (self._name, robl, chbl))
         char.append_bytes(b'\x2b' * ((robl - chbl) >> 3))
     #
     Envelope._from_char(self, char)
     # in case self._IE is defined, use it to decode char instead of V
     if self.DECODE_INNER and self._IE_stat is not None:
         if self._IE is None:
             self._IE = self._IE_stat.clone()
         iebl = self[-1].get_bl()
         ccur, clen = char._cur, char._len_bit
         char._cur -= iebl
         char._len_bit = char._cur + iebl
         try:
             self._IE._from_char(char)
         except:
             log('%s, _from_char: unable to decode IE, %s'\
                 % (self._name, self._IE._name))
         else:
             if char.len_bit() > 0:
                 log('%s, _from_char: uncorrect decoding for IE, %s'\
                     % (self._name, self._IE._name))
             else:
                 # replace V with the IE structure
                 self.replace(self[-1], self._IE)
         char._cur, char._len_bit = ccur, clen
コード例 #5
0
ファイル: IP.py プロジェクト: yifili09/pycrate
 def _from_char(self, char):
     Envelope._from_char(self, char)
     opts_buf = self[18].get_val()
     if opts_buf:
         opts = IPv4Options()
         opts.from_bytes(opts_buf)
         if opts.to_bytes() == opts_buf:
             self.replace(self[18], opts)
コード例 #6
0
ファイル: TS24501_IE.py プロジェクト: catenacyber/pycrate
 def _from_char(self, char):
     l = char.len_bit()
     if l <= 32:
         # disable all elements after bit l
         self.disable_from(l)
     elif l > 32:
         # enables some spare bits at the end
         self[-1]._bl = l-32
     Envelope._from_char(self, char)
コード例 #7
0
ファイル: TS24007.py プロジェクト: gteissier/pycrate
 def _from_char(self, char):
     # in case some optional IE are set (with transparency enabled)
     # they are decoded as much as the char buffer allows it
     # 1) decode mandatory part
     Envelope._from_char(self, char)
     # 2) decode optional part
     opts = self._opts[:]
     while char.len_bit() >= 8:
         T4, T8, dec = char.to_uint(4), char.to_uint(8), False
         for i, opt in enumerate(opts):
             # check the list of optional IEs in order
             if opt[1] in (T4, T8):
                 opt[2]._trans = False
                 opt[2]._from_char(char)
                 dec = True
                 del opts[i]
                 break
         if not dec:
             # unknown IEI
             char._cur += 8
             self._dec_unk_ie(T8, char)
コード例 #8
0
ファイル: TS24501_IE.py プロジェクト: catenacyber/pycrate
 def _from_char(self, char):
     if not self.get_trans():
         # get the type and set the appropriate content
         type = char.to_uint(8) & 0x7
         self._set_content(type)
         Envelope._from_char(self, char)