original_docstring: 
          Indicate a new DAO was received.
          This function parses the received packet, and if valid, updates the information needed to compute source routes.
          
docstring: Indicate a new DAO was received.
  This function parses the received packet, and if valid, updates the information needed to compute source routes.
docstring_tokens: Indicate a new DAO was received . This function parses the received packet and if valid updates the information needed to compute source routes .
code: def _indicate_dao(self, tup):
          """
          Indicate a new DAO was received.
          This function parses the received packet, and if valid, updates the information needed to compute source routes.
          """
          dao = []
          # retrieve source and destination
          try:
              source = tup[0]
              if len(source) > 8:
                  source = source[len(source) - 8:]
              dao = tup[1]
          except IndexError:
              log.warning("DAO too short ({0} bytes), no space for destination and source".format(len(dao)))
              return
  
          # log
          output = []
          output += ['received DAO:']
          output += ['- source :      {0}'.format(format_addr(source))]
          output += ['- dao :         {0}'.format(format_buf(dao))]
          output = '\n'.join(output)
          log.debug(output)
  
          # retrieve DAO header
          dao_header = {}
          dao_transit_information = {}
          dao_target_information = {}
  
          try:
              # rpl header
              dao_header['RPL_InstanceID'] = dao[0]
              dao_header['RPL_flags'] = dao[1]
              dao_header['RPL_Reserved'] = dao[2]
              dao_header['RPL_DAO_Sequence'] = dao[3]
              # DODAGID
              dao_header['DODAGID'] = dao[4:20]
  
              dao = dao[20:]
              # retrieve transit information header and parents
              parents = []
              children = []
  
              while len(dao) > 0:
                  if dao[0] == self._TRANSIT_INFORMATION_TYPE:
                      # transit information option
                      dao_transit_information['Transit_information_type'] = dao[0]
                      dao_transit_information['Transit_information_length'] = dao[1]
                      dao_transit_information['Transit_information_flags'] = dao[2]
                      dao_transit_information['Transit_information_path_control'] = dao[3]
                      dao_transit_information['Transit_information_path_sequence'] = dao[4]
                      dao_transit_information['Transit_information_path_lifetime'] = dao[5]
                      # address of the parent
                      _ = dao[6:14]  # prefix
                      parents += [dao[14:22]]
                      dao = dao[22:]
                  elif dao[0] == self._TARGET_INFORMATION_TYPE:
                      dao_target_information['Target_information_type'] = dao[0]
                      dao_target_information['Target_information_length'] = dao[1]
                      dao_target_information['Target_information_flags'] = dao[2]
                      dao_target_information['Target_information_prefix_length'] = dao[3]
                      # address of the child
                      _ = dao[4:12]  # prefix
                      children += [dao[12:20]]
                      dao = dao[20:]
                  else:
                      log.warning("DAO with wrong Option {0}. Neither Transit nor Target.".format(dao[0]))
                      return
          except IndexError:
              log.warning("DAO too short ({0} bytes), no space for DAO header".format(len(dao)))
              return
  
          # log
          output = []
          output += [
              'received RPL DAO from {0}:{1}'.format(format_ipv6_addr(self.network_prefix), format_ipv6_addr(source))]
          output += ['- parents:']
          for p in parents:
              output += ['   {0}:{1}'.format(format_ipv6_addr(self.network_prefix), format_ipv6_addr(p))]
          output += ['- children:']
          for p in children:
              output += ['   {0}:{1}'.format(format_ipv6_addr(self.network_prefix), format_ipv6_addr(p))]
          output = '\n\t'.join(output)
          log.info(output)
  
          node = format_ipv6_addr(source)
          if not (node in self.parents_dao_seq.keys()):
              self.parents_dao_seq[node] = [dao_header['RPL_DAO_Sequence']]
          else:
              self.parents_dao_seq[node].append(dao_header['RPL_DAO_Sequence'])
  
          try:
              with open(os.path.join(user_data_dir('openvisualizer'), 'dao_sequence.txt'), 'a') as f:
                  f.write(str(self.parents_dao_seq) + '\n')
          except IOError as err:
              log.error("Permission error: {}".format(err))
  
          # if you get here, the DAO was parsed correctly
  
          # update parents information with parents collected -- calls topology module.
          self.dispatch(signal='updateParents', data=(tuple(source), parents))
  
          # with self.data_lock:
          #    self.parents.update({tuple(source):parents})
code_tokens: def _indicate_dao ( self , tup ) : dao = [ ] try : source = tup [ 0 ] if len ( source ) > 8 : source = source [ len ( source ) - 8 : ] dao = tup [ 1 ] except IndexError : log . warning ( "DAO too short ({0} bytes), no space for destination and source" . format ( len ( dao ) ) ) return output = [ ] output += [ 'received DAO:' ] output += [ '- source :      {0}' . format ( format_addr ( source ) ) ] output += [ '- dao :         {0}' . format ( format_buf ( dao ) ) ] output = '\n' . join ( output ) log . debug ( output ) dao_header = { } dao_transit_information = { } dao_target_information = { } try : dao_header [ 'RPL_InstanceID' ] = dao [ 0 ] dao_header [ 'RPL_flags' ] = dao [ 1 ] dao_header [ 'RPL_Reserved' ] = dao [ 2 ] dao_header [ 'RPL_DAO_Sequence' ] = dao [ 3 ] dao_header [ 'DODAGID' ] = dao [ 4 : 20 ] dao = dao [ 20 : ] parents = [ ] children = [ ] while len ( dao ) > 0 : if dao [ 0 ] == self . _TRANSIT_INFORMATION_TYPE : dao_transit_information [ 'Transit_information_type' ] = dao [ 0 ] dao_transit_information [ 'Transit_information_length' ] = dao [ 1 ] dao_transit_information [ 'Transit_information_flags' ] = dao [ 2 ] dao_transit_information [ 'Transit_information_path_control' ] = dao [ 3 ] dao_transit_information [ 'Transit_information_path_sequence' ] = dao [ 4 ] dao_transit_information [ 'Transit_information_path_lifetime' ] = dao [ 5 ] _ = dao [ 6 : 14 ] parents += [ dao [ 14 : 22 ] ] dao = dao [ 22 : ] elif dao [ 0 ] == self . _TARGET_INFORMATION_TYPE : dao_target_information [ 'Target_information_type' ] = dao [ 0 ] dao_target_information [ 'Target_information_length' ] = dao [ 1 ] dao_target_information [ 'Target_information_flags' ] = dao [ 2 ] dao_target_information [ 'Target_information_prefix_length' ] = dao [ 3 ] _ = dao [ 4 : 12 ] children += [ dao [ 12 : 20 ] ] dao = dao [ 20 : ] else : log . warning ( "DAO with wrong Option {0}. Neither Transit nor Target." . format ( dao [ 0 ] ) ) return except IndexError : log . warning ( "DAO too short ({0} bytes), no space for DAO header" . format ( len ( dao ) ) ) return output = [ ] output += [ 'received RPL DAO from {0}:{1}' . format ( format_ipv6_addr ( self . network_prefix ) , format_ipv6_addr ( source ) ) ] output += [ '- parents:' ] for p in parents : output += [ '   {0}:{1}' . format ( format_ipv6_addr ( self . network_prefix ) , format_ipv6_addr ( p ) ) ] output += [ '- children:' ] for p in children : output += [ '   {0}:{1}' . format ( format_ipv6_addr ( self . network_prefix ) , format_ipv6_addr ( p ) ) ] output = '\n\t' . join ( output ) log . info ( output ) node = format_ipv6_addr ( source ) if not ( node in self . parents_dao_seq . keys ( ) ) : self . parents_dao_seq [ node ] = [ dao_header [ 'RPL_DAO_Sequence' ] ] else : self . parents_dao_seq [ node ] . append ( dao_header [ 'RPL_DAO_Sequence' ] ) try : with open ( os . path . join ( user_data_dir ( 'openvisualizer' ) , 'dao_sequence.txt' ) , 'a' ) as f : f . write ( str ( self . parents_dao_seq ) + '\n' ) except IOError as err : log . error ( "Permission error: {}" . format ( err ) ) self . dispatch ( signal = 'updateParents' , data = ( tuple ( source ) , parents ) )
short_docstring: Indicate a new DAO was received.
short_docstring_tokens: Indicate a new DAO was received .
comment: """
          Indicate a new DAO was received.
          This function parses the received packet, and if valid, updates the information needed to compute source routes.
          """$SEP$# retrieve source and destination$SEP$# log$SEP$# retrieve DAO header$SEP$# rpl header$SEP$# DODAGID$SEP$# retrieve transit information header and parents$SEP$# transit information option$SEP$# address of the parent$SEP$# prefix$SEP$# address of the child$SEP$# prefix$SEP$# log$SEP$# if you get here, the DAO was parsed correctly$SEP$# update parents information with parents collected -- calls topology module.$SEP$# with self.data_lock:$SEP$#    self.parents.update({tuple(source):parents})