Repopulates the transient fields based on the IP and prefix
420883
private void recache()
	{
		// If we've already cached the values then don't bother recalculating; we
		// assume a mask of 0 means a recompute is needed (unless prefix is also 0)
		// We skip the computation completely is prefix is 0 - this is fine, since
		// the mask and maskedNetwork for prefix 0 result in 0, the default values.

		// We need to special-case /0 because our mask generation code doesn't work for
		// prefix=0 (since -1 << 32 != 0)
		if (mask == 0 && prefix != 0)
		{
			this.mask = -1 << (32 - prefix);
			this.maskedNetwork = IpHelper.aton(network) & mask;
		}
	}
1013526
def get_inputs(node, kwargs):
    """"""
    name = node["name"]
    proc_nodes = kwargs["proc_nodes"]
    index_lookup = kwargs["index_lookup"]
    inputs = node["inputs"]
    attrs = node.get("attrs", {})

    input_nodes = []
    for ip in inputs:
        input_node_id = index_lookup[ip[0]]
        input_nodes.append(proc_nodes[input_node_id].name)

    return name, input_nodes, attrs
726279
def handle_fields(definitions, fields, prefix, offset, multiplier):
  
  items = []
  for f in fields:
    if f.type_id == "array" and f.options['fill'].value in CONSTRUCT_CODE:
      prefix_name = '.'.join([prefix, f.identifier]) if prefix else f.identifier
      n_with_values = f.options['n_with_values'].value
      bitfields = f.options['fields'].value if n_with_values > 0 else None
      if 'size' in f.options:
        name = "%s[%s]" % (f.options['fill'].value, str(f.options['size'].value))
        size = field_sizes[f.options['fill'].value] * f.options['size'].value
        item = FieldItem(prefix_name, name, offset, size,
                         str(f.units), f.desc, n_with_values, bitfields)
        items.append(item)
        offset += size
      else:
        name = "%s[%s]" % (f.options['fill'].value, "N")
        multiplier = field_sizes[f.options['fill'].value]
        size = field_sizes[f.options['fill'].value] * 1
        item = FieldItem(prefix_name, name, offset, "N",
                         str(f.units), f.desc, n_with_values, bitfields)
        items.append(item)
        offset += size
    elif f.type_id == "string":
      prefix_name = '.'.join([prefix, f.identifier]) if prefix else f.identifier
      n_with_values = f.options['n_with_values'].value
      bitfields = f.options['fields'].value if n_with_values > 0 else None
      if 'size' in f.options:
        name = "string"
        size = field_sizes['u8'] * f.options['size'].value
        item = FieldItem(prefix_name, name, offset, size,
                         str(f.units), f.desc, n_with_values, bitfields)
        items.append(item)
        offset += size
      else:
        name = "string"
        size = field_sizes['u8']
        multiplier = 1
        item = FieldItem(prefix_name, name, offset, "N",
                         str(f.units), f.desc, n_with_values, bitfields)
        items.append(item)
        offset += size
    elif f.type_id == "array":
      name = f.options['fill'].value
      definition = next(d for d in definitions if name == d.identifier)
      prefix_name = '.'.join([prefix, f.identifier]) if prefix else f.identifier
      (new_items, new_offset, new_multiplier) \
        = handle_fields(definitions,
                        definition.fields,
                        prefix_name + "[N]",
                        offset,
                        multiplier)
      multiplier = new_offset - offset
      (newer_items, newer_offset, newer_multiplier) \
        = handle_fields(definitions,
                        definition.fields,
                        prefix_name + "[N]", offset,
                        multiplier)
      items += newer_items
      offset = newer_offset
    elif f.type_id not in CONSTRUCT_CODE:
      name = f.type_id
      definition = next(d for d in definitions if name == d.identifier)
      prefix_name = '.'.join([prefix, f.identifier]) if prefix else f.identifier
      (new_items, new_offset, new_multiplier) \
        = handle_fields(definitions,
                        definition.fields,
                        prefix_name,
                        offset,
                        multiplier)
      items += new_items
      offset = new_offset
      multiplier = new_multiplier
    else:
      size = field_sizes[f.type_id]
      name = f.type_id
      adj_offset = "%dN+%d" % (multiplier, offset) if multiplier else offset
      prefix_name = '.'.join([prefix, f.identifier]) if prefix else f.identifier
      n_with_values = f.options['n_with_values'].value
      bitfields = f.options['fields'].value if n_with_values > 0 else None
      item = FieldItem(prefix_name, name, adj_offset, size, str(f.units), f.desc, n_with_values, bitfields)
      items.append(item)
      offset += size
  return (items, offset, multiplier)
243873
def _remap_fields(cls, kwargs):
        """"""
        mapped = {}
        for key in kwargs:
            if key in cls._remap:
                mapped[cls._remap[key]] = kwargs[key]
            else:
                mapped[key] = kwargs[key]
        return mapped
987573
def i2m(self, pkt, i):
        """""""  # noqa: E501
        mask, ip = i
        ip = pton_ntop.inet_pton(socket.AF_INET6, ip)
        return struct.pack(">B", mask) + ip[:self.mask2iplen(mask)]
284215
def from_dict(cls, connector, ip_dict):
        
        mapping = cls._global_field_processing.copy()
        mapping.update(cls._custom_field_processing)
        # Process fields that require building themselves as objects
        for field in mapping:
            if field in ip_dict:
                ip_dict[field] = mapping[field](ip_dict[field])
        return cls(connector, **ip_dict)
279388
def imm_transient(imm):
    '''
    
    '''
    if not is_imm(imm):
        raise ValueError('Non-immutable given to imm_transient')
    # make a duplicate immutable that is in the transient state
    dup = copy.copy(imm)
    if _imm_is_init(imm):
        # this is an initial-state immutable...
        _imm_init_to_trans(dup)
    elif _imm_is_persist(imm):
        # it's persistent; re-transient-ize this new one
        dd = object.__getattribute__(dup, '__dict__')
        dd['_pimms_immutable_is_trans'] = True
    return dup
1030568
static void updateNetworkVariables( Map<String,String> instanceExports, String ipAddress ) {

		// Find the keys to update ( xxx.ip )
		Set<String> keysToUpdate = new HashSet<> ();
		for( Map.Entry<String,String> entry : instanceExports.entrySet()) {
			String suffix = parseVariableName( entry.getKey()).getValue();
			if( Constants.SPECIFIC_VARIABLE_IP.equalsIgnoreCase( suffix ))
				keysToUpdate.add( entry.getKey());
		}

		// Update them
		for( String key : keysToUpdate )
			instanceExports.put( key, ipAddress );
	}
26696
def assignrepr(self, prefix):
        """"""
        caller = 'Timegrids('
        blanks = ' ' * (len(prefix) + len(caller))
        prefix = f'{prefix}{caller}'
        lines = [f'{self.init.assignrepr(prefix)},']
        if self.sim != self.init:
            lines.append(f'{self.sim.assignrepr(blanks)},')
        lines[-1] = lines[-1][:-1] + ')'
        return '\n'.join(lines)
1178703
public <D, V> void iput(FieldId<D, V> fieldId, Local<? extends D> instance, Local<? extends V> source) {
        addInstruction(new ThrowingCstInsn(Rops.opPutField(source.type.ropType), sourcePosition,
                RegisterSpecList.make(source.spec(), instance.spec()), catches, fieldId.constant));
    }
1189957
def create_transient(self, input_stream, original_name, length=None):
        ''''''
        ext = os.path.splitext(original_name)[1]
        transient = self.new_transient(ext)
        if not os.path.isdir(self.transient_root):
            os.makedirs(self.transient_root)

        self._copy_file(input_stream, transient.path, length=length)
        return transient
948459
def _field_controller_generator(self):
        
        # Local variable, to avoid messing with "self"
        stored_instance = self._ipopo_instance

        def get_value(self, name):
            # pylint: disable=W0613
            """
            Retrieves the controller value, from the iPOPO dictionaries

            :param name: The property name
            :return: The property value
            """
            return stored_instance.get_controller_state(name)

        def set_value(self, name, new_value):
            # pylint: disable=W0613
            """
            Sets the property value and trigger an update event

            :param name: The property name
            :param new_value: The new property value
            """
            # Get the previous value
            old_value = stored_instance.get_controller_state(name)
            if new_value != old_value:
                # Update the controller state
                stored_instance.set_controller_state(name, new_value)

            return new_value

        return get_value, set_value
1283880
def _ip_string_from_prefix(self, prefixlen=None):
        
        if not prefixlen:
            prefixlen = self._prefixlen
        return self._string_from_ip_int(self._ip_int_from_prefix(prefixlen))
708418
def write_field_repr(self, name, out, visited):
        '''
        
        '''
        field_obj = self.pyop_field(name)
        field_obj.write_repr(out, visited)
690950
def populate(self, priority, address, rtr, data):
        
        assert isinstance(data, bytes)
        self.needs_no_rtr(rtr)
        self.needs_data(data, 7)
        self.set_attributes(priority, address, rtr)
        self.channel = (data[0] & 0x03) +1 
        self.pulses = (data[0] >> 2) * 100
        self.counter = (data[1] << 24) + (data[2] << 16) + (data[3] << 8) + data[4]
        self.delay = (data[5] << 8) + data[6]
456425
def _update_field(self, natvalue):
        
        updated = False
        if natvalue.element and natvalue.element != self.element:
            self.update(element=natvalue.element)
            self.pop('ip_descriptor', None)
            updated = True
        elif natvalue.ip_descriptor and self.ip_descriptor and \
            natvalue.ip_descriptor != self.ip_descriptor:
            self.update(ip_descriptor=natvalue.ip_descriptor)
            self.pop('element', None)
            updated = True

        for port in ('min_port', 'max_port'):
            _port = getattr(natvalue, port, None)
            if _port is not None and getattr(self, port, None) != _port:
                self[port] = _port
                updated = True
    
        return updated
60738
def inet_ntop(af, addr):
    """"""
    if af == socket.AF_INET:
        return inet_ntoa(addr)
    elif af == socket.AF_INET6:
        # IPv6 addresses have 128bits (16 bytes)
        if len(addr) != 16:
            raise Exception("Illegal syntax for IP address")
        parts = []
        for left in [0, 2, 4, 6, 8, 10, 12, 14]:
            try: 
                value = struct.unpack("!H", addr[left:left+2])[0]
                hexstr = hex(value)[2:]
            except TypeError:
                raise Exception("Illegal syntax for IP address")
            parts.append(hexstr.lstrip("0").lower())
        result = b":".join(parts)
        while b":::" in result:
            result = result.replace(b":::", b"::")
        # Leaving out leading and trailing zeros is only allowed with ::
        if result.endswith(b":") and not result.endswith(b"::"):
            result = result + b"0"
        if result.startswith(b":") and not result.startswith(b"::"):
            result = b"0" + result
        return result
    else:
        raise Exception("Address family not supported yet")