Network netmask derived from subnet size, as long.

        >>> localnet = Network('127.0.0.1/8')
        >>> print(localnet.netmask_long())
        4278190080
169021
def netmask_long(self):
        
        if self.version() == 4:
            return (MAX_IPV4 >> (32 - self.mask)) << (32 - self.mask)
        else:
            return (MAX_IPV6 >> (128 - self.mask)) << (128 - self.mask)
484617
def netmask_to_cidr (dq):
  
  if isinstance(dq, str):
    dq = IPv4Address(dq)
  v = int(dq)
  c = 0
  while v & 0x80000000:
    c += 1
    v <<= 1
  v = v & 0xffFFffFF
  if v != 0:
    raise RuntimeError("Netmask %s is not CIDR-compatible" % (dq,))
  return c
1047237
def _split_optional_netmask(address):
    """"""
    addr = str(address).split('/')
    if len(addr) > 2:
        raise AddressValueError("Only one '/' permitted in %r" % address)
    return addr
524042
def natural_ipv4_netmask(ip, fmt='prefixlen'):
    '''
    
    '''
    bits = _ipv4_to_bits(ip)

    if bits.startswith('11'):
        mask = '24'
    elif bits.startswith('1'):
        mask = '16'
    else:
        mask = '8'

    if fmt == 'netmask':
        return cidr_to_ipv4_netmask(mask)
    else:
        return '/' + mask
320308
def _split_optional_netmask(address):
    """"""
    addr = _compat_str(address).split('/')
    if len(addr) > 2:
        raise AddressValueError("Only one '/' permitted in %r" % address)
    return addr
956789
def prefixlen_to_mask(prefixlen):
    
    prefixlen = prefixlen or '32'
    addr = '0.0.0.0/%s' % prefixlen
    return str(netaddr.IPNetwork(addr).netmask)
773696
def local_address(self):
        
        if not self._local_address:
            self._local_address = self.proto.reader._transport.get_extra_info('sockname')
            if len(self._local_address) == 4:
                self._local_address = self._local_address[:2]
        return self._local_address
486501
def nth_subnet(prefix_len,index)
			count = self.subnet_count(prefix_len)
			if (count == 0 || index >= count)
				return nil
			end
			sub0 = IPv6Net.new(self.network, Mask128.new(prefix_len))
			return sub0.nth_next_sib(index)
		end
783581
def local_port_range(self):
        
        if self._local_port_range is None:
            with open('/proc/sys/net/ipv4/ip_local_port_range', 'r') as f:
                self._local_port_range = tuple(map(int, f.read().split('\t')))
        return self._local_port_range
1256437
def getdilatedmask(self, size=3):
        
        if size == 3:
            dilmask = ndimage.morphology.binary_dilation(self.mask, structure=growkernel, iterations=1, mask=None, output=None, border_value=0, origin=0, brute_force=False)
        elif size == 5:
            dilmask = ndimage.morphology.binary_dilation(self.mask, structure=dilstruct, iterations=1, mask=None, output=None, border_value=0, origin=0, brute_force=False)
        else:
            dismask = self.mask.copy()
        
        return dilmask
889811
function ip() {
    let network = os.networkInterfaces(),
        keys = Object.keys(network),
        ips = [];

    for (let key of keys) {
        network[key].forEach(ip => {
            ip.family === 'IPv4' && !ip.internal && ips.push(ip.address);
        });
    }

    return ips.length ? ips[0] : '127.0.0.1';
}
340995
def __ipv6_netmask(value):
    ''''''
    valid, errmsg = False, 'IPv6 netmask (0->128)'
    valid, value, _ = __int(value)
    valid = (valid and 0 <= value <= 128)
    return (valid, value, errmsg)
1076325
def write_longlong(self, n):
        
        if (n < 0) or (n >= (2**64)):
            raise ValueError('Octet out of range 0..2**64-1')
        self._flushbits()
        self.out.write(pack('>Q', n))
643918
public static int getNetworkSegmentIndex(int networkPrefixLength, int bytesPerSegment, int bitsPerSegment) {
		if(bytesPerSegment > 1) {
			if(bytesPerSegment == 2) {
				return (networkPrefixLength - 1) >> 4;//note this is intentionally a signed shift and not >>> so that networkPrefixLength of 0 returns -1
			}
			return (networkPrefixLength - 1) / bitsPerSegment;
		}
		return (networkPrefixLength - 1) >> 3;
	}
415271
def masked(self):
        """"""
        return IPNetwork('%s/%d' % (self.network, self._prefixlen),
                         version=self._version)
1354539
def get_netloc(self):
        
        if self.proxy:
            scheme = self.proxytype
            host = self.proxyhost
            port = self.proxyport
        else:
            scheme = self.scheme
            host = self.host
            port = self.port
        return (scheme, host, port)
304339
def resolve_network_cidr(ip_address):
    '''
    
    '''
    netmask = get_netmask_for_address(ip_address)
    return str(netaddr.IPNetwork("%s/%s" % (ip_address, netmask)).cidr)