Exemplo n.º 1
0
 def __insert_atoms(self, p_atom, child=[]):
     child.reverse() # reverse child atoms order, due to Block.insert()
     debug(self.dbg, 3, '(MPEG4) p_atom %s index in Block: %s' \
           % (p_atom.type, p_atom.get_index()))
     debug(self.dbg, 3, '(MPEG4) inserting: %s' % [c.type for c in child])
     for atom in child:
         self.insert(p_atom.get_index()+1, atom)
         self[p_atom.get_index()+1].atomic = False
         self[p_atom.get_index()+1].hierarchy = p_atom.hierarchy+1
Exemplo n.º 2
0
 def __insert_atoms(self, p_atom, child=[]):
     child.reverse()  # reverse child atoms order, due to Block.insert()
     debug(self.dbg, 3, '(MPEG4) p_atom %s index in Block: %s' \
           % (p_atom.type, p_atom.get_index()))
     debug(self.dbg, 3, '(MPEG4) inserting: %s' % [c.type for c in child])
     for atom in child:
         self.insert(p_atom.get_index() + 1, atom)
         self[p_atom.get_index() + 1].atomic = False
         self[p_atom.get_index() + 1].hierarchy = p_atom.hierarchy + 1
Exemplo n.º 3
0
 def map(self, s=''):
     # this is to adapt DIB header size to common most applications
     self.DIBHeaderSize
     expected_size = self.DIBHeaderSize()
     self[0].map(s[:4])
     real_size = self.DIBHeaderSize()
     # remove last values from the header structure
     if real_size < expected_size:
         to_remove = (expected_size-real_size)/4
         for i in range(to_remove):
             self.remove(self[-1])
     elif real_size > expected_size:
         debug(self.dbg, 2, 'DIB header not long enough: not standard')
     Layer.map(self, s)
Exemplo n.º 4
0
 def map(self, s=''):
     # this is to adapt DIB header size to common most applications
     self.DIBHeaderSize
     expected_size = self.DIBHeaderSize()
     self[0].map(s[:4])
     real_size = self.DIBHeaderSize()
     # remove last values from the header structure
     if real_size < expected_size:
         to_remove = (expected_size - real_size) / 4
         for i in range(to_remove):
             self.remove(self[-1])
     elif real_size > expected_size:
         debug(self.dbg, 2, 'DIB header not long enough: not standard')
     Layer.map(self, s)
Exemplo n.º 5
0
 def get_child(self, p_atom):
     if int(p_atom.size) <= 8:
         return []
     s = str(p_atom.data)
     child_atoms = []
     while len(s) > 0:
         child_atoms.append(atom())
         child_atoms[-1].map(s)
         debug(self.dbg, 3, '(MPEG4) child_atoms:\n%s\n' % child_atoms)
         s = s[len(child_atoms[-1]):]
     if sum([int(c_atom.size) for c_atom in child_atoms]) == \
        int(p_atom.size)-8:
         return child_atoms
     else:
         return []
Exemplo n.º 6
0
 def get_child(self, p_atom):
     if int(p_atom.size) <= 8:
         return []
     s = str(p_atom.data)
     child_atoms = []
     while len(s) > 0:
         child_atoms.append(atom())
         child_atoms[-1].map(s)
         debug(self.dbg, 3, '(MPEG4) child_atoms:\n%s\n' % child_atoms)
         s=s[len(child_atoms[-1]):] 
     if sum([int(c_atom.size) for c_atom in child_atoms]) == \
        int(p_atom.size)-8:
         return child_atoms
     else:
         return []
Exemplo n.º 7
0
 def parse(self, s=""):
     # parse initial header
     self.map(s[:19])
     s = s[19:]
     # control BGP marker
     if self[-1].marker() != 16 * "\xFF":
         debug(self.dbg, 1, "bad BGP marker in header")
     # then
     # iteratively parse successive payloads and headers
     while len(s) > 0:
         # append BGP payload
         if isinstance(self[-1], HEADER):
             pay_type = self[-1].type()
             pay_len = self[-1].len() - 19
             if pay_type in MsgCall.keys():
                 # BGP payload is recognized: youpi!!!!
                 self << MsgCall[pay_type]()
                 # print('%s' % self[-1].show())
                 self[-1].map(s)
                 # control payload length
                 if len(self[-1]) != pay_len:
                     debug(self.dbg, 1, "inconsistent length between BGP " "header and payload")
             else:
                 # unknown payload
                 self << RawLayer()
                 self[-1].map(s[:pay_len])
         # append more BGP headers
         else:
             self.append(HEADER())
             self[-1].map(s)
             # control BGP marker
             if self[-1].marker() != 16 * "\xFF":
                 debug(self.dbg, 1, "bad BGP marker in header")
         # truncate string buffer, and iterate
         s = s[len(self[-1]) :]
Exemplo n.º 8
0
 def parse(self, s=''):
     # parse initial header
     self.map(s[:19])
     s = s[19:]
     # control BGP marker
     if self[-1].marker() != 16 * '\xFF':
         debug(self.dbg, 1, 'bad BGP marker in header')
     # then
     # iteratively parse successive payloads and headers
     while len(s) > 0:
         # append BGP payload
         if isinstance(self[-1], HEADER):
             pay_type = self[-1].type()
             pay_len = self[-1].len() - 19
             if pay_type in MsgCall.keys():
                 # BGP payload is recognized: youpi!!!!
                 self << MsgCall[pay_type]()
                 #print('%s' % self[-1].show())
                 self[-1].map(s)
                 # control payload length
                 if len(self[-1]) != pay_len:
                     debug(self.dbg, 1, 'inconsistent length between BGP '\
                     'header and payload')
             else:
                 # unknown payload
                 self << RawLayer()
                 self[-1].map(s[:pay_len])
         # append more BGP headers
         else:
             self.append(HEADER())
             self[-1].map(s)
             # control BGP marker
             if self[-1].marker() != 16 * '\xFF':
                 debug(self.dbg, 1, 'bad BGP marker in header')
         # truncate string buffer, and iterate
         s = s[len(self[-1]):]