For Windows 2008R2/Windows 7 and earlier its Local Area Connection
 For Windows 8/2012 and later its Ethernet
195098
def network_device_name
      return @network_device_name if @network_device_name
      major, minor, build = ::RightScale::Platform.release.split(".").map(&:to_i)
      @network_device_name = (major == 6 && minor <= 1) ? "Local Area Connection" : "Ethernet" # http://msdn.microsoft.com/en-us/library/ms724834%28VS.85%29.aspx
    end
1095568
def dns_dhcp(name, interface='Local Area Connection'):
    '''
    
    '''
    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ''}

    # Check the config
    config = __salt__['win_dns_client.get_dns_config'](interface)
    if config == 'dhcp':
        ret['comment'] = '{0} already configured with DNS from DHCP'.format(
                interface)
        return ret
    else:
        ret['changes'] = {'dns': 'configured from DHCP'}

    if __opts__['test']:
        ret['result'] = None
        return ret

    # change the configuration
    ret['result'] = __salt__['win_dns_client.dns_dhcp'](interface)
    if not ret['result']:
        ret['changes'] = {}
        ret['comment'] = (
                'Could not configure "{0}" DNS servers from DHCP'
                ).format(interface)

    return ret
878577
def connect(self, driver):
        """"""
        #              0            1                              2                      3
        events = [ESCAPE_CHAR, driver.press_return_re, driver.standby_re, driver.username_re,
                  #            4                   5                  6                     7
                  driver.password_re, driver.more_re, self.device.prompt_re, driver.rommon_re,
                  #       8                              9              10            11              12
                  driver.unable_to_connect_re, driver.timeout_re, pexpect.TIMEOUT, PASSWORD_OK, driver.syntax_error_re]

        transitions = [
            (ESCAPE_CHAR, [0], 1, None, _C['esc_char_timeout']),
            (driver.syntax_error_re, [0], -1, CommandSyntaxError("Command syntax error"), 0),
            (driver.press_return_re, [0, 1], 1, a_send_newline, 10),
            (PASSWORD_OK, [0, 1], 1, a_send_newline, 10),
            (driver.standby_re, [0, 5], -1, partial(a_standby_console), 0),
            (driver.username_re, [0, 1, 5, 6], -1, partial(a_save_last_pattern, self), 0),
            (driver.password_re, [0, 1, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.more_re, [0, 5], 7, partial(a_send, "q"), 10),
            # router sends it again to delete
            (driver.more_re, [7], 8, None, 10),
            # (prompt, [0, 1, 5], 6, a_send_newline, 10),
            (self.device.prompt_re, [0, 1, 5], 0, None, 10),
            (self.device.prompt_re, [6, 8, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.rommon_re, [0, 1, 5], -1, partial(a_save_last_pattern, self), 0),
            (driver.unable_to_connect_re, [0, 1, 5], -1, a_unable_to_connect, 0),
            (driver.timeout_re, [0, 1, 5], -1, ConnectionTimeoutError("Connection Timeout", self.hostname), 0),
            (pexpect.TIMEOUT, [0, 1], 5, a_send_newline, 10),
            (pexpect.TIMEOUT, [5], -1, ConnectionTimeoutError("Connection timeout", self.hostname), 0)
        ]

        self.log("EXPECTED_PROMPT={}".format(pattern_to_str(self.device.prompt_re)))
        # setting max_transitions to large number to swallow prompt like strings from prompt
        fsm = FSM("TELNET-CONNECT", self.device, events, transitions, timeout=_C['connect_timeout'],
                  init_pattern=self.last_pattern, max_transitions=500)
        return fsm.run()
1156963
def _interface_to_service(iface):
    '''
    
    '''
    for _service in _get_services():
        service_info = pyconnman.ConnService(os.path.join(SERVICE_PATH, _service))
        if service_info.get_property('Ethernet')['Interface'] == iface:
            return _service
    return None
1225870
def serial_get(self):
		
		frmwk_c1218_settings = {
			'nbrpkts': self.advanced_options['C1218_MAX_PACKETS'],
			'pktsize': self.advanced_options['C1218_PACKET_SIZE']
		}

		frmwk_serial_settings = termineter.utilities.get_default_serial_settings()
		frmwk_serial_settings['baudrate'] = self.advanced_options['SERIAL_BAUD_RATE']
		frmwk_serial_settings['bytesize'] = self.advanced_options['SERIAL_BYTE_SIZE']
		frmwk_serial_settings['stopbits'] = self.advanced_options['SERIAL_STOP_BITS']

		self.logger.info('opening serial device: ' + self.options['SERIAL_CONNECTION'])
		try:
			self.serial_connection = c1218.connection.Connection(self.options['SERIAL_CONNECTION'], c1218_settings=frmwk_c1218_settings, serial_settings=frmwk_serial_settings, enable_cache=self.advanced_options['CACHE_TABLES'])
		except Exception as error:
			self.logger.error('could not open the serial device')
			raise error
		return self.serial_connection
578800
public function getNet()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Network Devices');
        }

        $return = array();
        $i = 0;

        if (version_compare($this->windows_version,'6.1.0000')>0) {
            $object = $this->wmi->ExecQuery('SELECT AdapterType, Name, NetConnectionStatus, GUID FROM Win32_NetworkAdapter WHERE PhysicalAdapter = TRUE');
        } else {
            $object = $this->wmi->ExecQuery('SELECT AdapterType, Name, NetConnectionStatus FROM Win32_NetworkAdapter WHERE NetConnectionStatus != NULL');
        }

        foreach ($object as $net) {
            // Save and get info for each
            $return[$net->Name] = array(
                'recieved' => array(
                    'bytes' => 0,
                    'errors' => 0,
                    'packets' => 0,
                ),
                'sent' => array(
                    'bytes' => 0,
                    'errors' => 0,
                    'packets' => 0,
                ),
                'state' => 0,
                'type' => $net->AdapterType,
            );
            switch ($net->NetConnectionStatus) {
                case 0:
                    $return[$net->Name]['state'] = 'down';
                    break;
                case 1:
                    $return[$net->Name]['state'] = 'Connecting';
                    break;
                case 2:
                    $return[$net->Name]['state'] = 'up';
                    break;
                case 3:
                    $return[$net->Name]['state'] = 'Disconnecting';
                    break;
                case 4:
                    $return[$net->Name]['state'] = 'down'; // MSDN 'Hardware not present'
                    break;
                case 5:
                    $return[$net->Name]['state'] = 'Hardware disabled';
                    break;
                case 6:
                    $return[$net->Name]['state'] = 'Hardware malfunction';
                    break;
                case 7:
                    $return[$net->Name]['state'] = 'Media disconnected';
                    break;
                case 8:
                    $return[$net->Name]['state'] = 'Authenticating';
                    break;
                case 9:
                    $return[$net->Name]['state'] = 'Authentication succeeded';
                    break;
                case 10:
                    $return[$net->Name]['state'] = 'Authentication failed';
                    break;
                case 11:
                    $return[$net->Name]['state'] = 'Invalid address';
                    break;
                case 12:
                    $return[$net->Name]['state'] = 'Credentials required';
                    break;
                default:
                    $return[$net->Name]['state'] = 'unknown';
                    break;
            }
            // @Microsoft: An index would be nice here indeed.
            if (version_compare($this->windows_version,'6.1.0000')>0) {
                $canonname = preg_replace('/[^A-Za-z0-9- ]/', '_', $net->Name);
                $canonname2 = str_replace(['(', ')'], ['[', ']'], $canonname);
                $isatapname = 'isatap.'.$net->GUID;

                $result = $this->wmi->ExecQuery("SELECT BytesReceivedPersec, PacketsReceivedErrors, PacketsReceivedPersec, BytesSentPersec, PacketsSentPersec FROM Win32_PerfRawData_Tcpip_NetworkInterface WHERE Name = '$canonname' OR Name = '$isatapname' OR Name = '$canonname2'");
            } else {
                $canonname = preg_replace('/[^A-Za-z0-9- ]/', '_', $net->Name);
                $result = $this->wmi->ExecQuery("SELECT BytesReceivedPersec, PacketsReceivedErrors, PacketsReceivedPersec, BytesSentPersec, PacketsSentPersec FROM Win32_PerfRawData_Tcpip_NetworkInterface WHERE Name = '$canonname'");
            }
            foreach ($result as $netspeed) {
                $return[$net->Name]['recieved'] = array(
                    'bytes' => (int) $netspeed->BytesReceivedPersec,
                    'errors' => (int) $netspeed->PacketsReceivedErrors,
                    'packets' => (int) $netspeed->PacketsReceivedPersec,
                );
                $return[$net->Name]['sent'] = array(
                    'bytes' => (int) $netspeed->BytesSentPersec,
                    'errors' => 0,
                    'packets' => (int) $netspeed->PacketsSentPersec,
                );
            }
            ++$i;
        }

        return $return;
    }
535890
def get_dns_config(interface='Local Area Connection'):
    '''
    
    '''
    # remove any escape characters
    interface = interface.split('\\')
    interface = ''.join(interface)

    with salt.utils.winapi.Com():
        c = wmi.WMI()
        for iface in c.Win32_NetworkAdapterConfiguration(IPEnabled=1):
            if interface == iface.Description:
                return iface.DHCPEnabled
1026400
def _assemble_devinfo(self):
        '''
        
        '''
        devtype = {}
        for p in pcap_devices():
            if p.isloop:
                devtype[p.name] = InterfaceType.Loopback
            else:
                if sys.platform == 'linux':
                    st,output = subprocess.getstatusoutput(["iwconfig", p.name])
                    if "no wireless extensions" in output:
                        devtype[p.name] = InterfaceType.Wired
                    else:
                        devtype[p.name] = InterfaceType.Wireless
                elif sys.platform == 'darwin':
                    devtype[p.name] = InterfaceType.Unknown
                else:
                    devtype[p.name] = InterfaceType.Unknown

        devinfo = {}
        ifinfo = net_if_addrs()
        for devname in self._devs:
            ifaddrs = ifinfo.get(devname, None)
            if ifaddrs is None:
                log_warn("Address info for interface {} not found! (skipping)".format(devname))

            if sys.platform == 'darwin':
                layer2addrfam = socket.AddressFamily.AF_LINK
            elif sys.platform == 'linux':
                layer2addrfam = socket.AddressFamily.AF_PACKET
            else:
                raise RuntimeException("Platform not supported")

            macaddr = "00:00:00:00:00:00"
            ipaddr = mask = "0.0.0.0"
            for addrinfo in ifaddrs:
                if addrinfo.family == socket.AddressFamily.AF_INET:
                    ipaddr = IPv4Address(addrinfo.address)
                    mask = IPv4Address(addrinfo.netmask)
                elif addrinfo.family == layer2addrfam:
                    macaddr = EthAddr(addrinfo.address)

            ifnum = socket.if_nametoindex(devname)
            devinfo[devname] = Interface(devname, macaddr, ipaddr, netmask=mask, ifnum=ifnum, iftype=devtype[devname])
        return devinfo
1156602
function(client, window, reconnectInterval) { 
		this._client = client;        	
		this._window = window;
		this._reconnectInterval = reconnectInterval*1000;
		
		var doTimeout = function (reconnector) {
			return function () {
				return doReconnect.apply(reconnector);
			};
		};
		
		/** @ignore */
		var doReconnect = function() { 
			if (this._client.connected) {
				this._client._trace("Reconnector.doReconnect", "ALREADY CONNECTED");
				this._window.clearTimeout(this.reconnectorTimer);
			} else {
				this._client._trace("Reconnector.doReconnect", "reconnecting");
				if (this._client.connectOptions.uris) {
					this._client.hostIndex = 0;
					this._client._doConnect(this._client.connectOptions.uris[0]);  
				} else {
					this._client._doConnect(this._client.uri);
				}
				this.reconnectorTimer = this._window.setTimeout(doTimeout(this), this._reconnectInterval);
			}
		}
		
		this.reset = function() {
			this._window.clearTimeout(this.reconnectorTimer);
			this.reconnectorTimer = this._window.setTimeout(doTimeout(this), this._reconnectInterval);
		}

		this.cancel = function() {
			this._window.clearTimeout(this.reconnectorTimer);
		}
	 }
1365411
def get_default_net_device():
    
    with open('/proc/net/route') as fh:
        for line in fh:
            iface, dest, _ = line.split(None, 2)
            if dest == '00000000':
                return iface
    return None
426701
def _setup_network():
    """"""
    global wlan
    global secret

    if sys.platform in PYCOM:
        # Update secret as tuple with wlan mode for PyCom port.
        wlan = network.WLAN(network.WLAN.STA)
        secret = (network.WLAN.WPA2, settings.WIFI_PASSWORD)
    else:
        # default micropython wlan settings
        wlan = network.WLAN(network.STA_IF)
        secret = settings.WIFI_PASSWORD
1334642
def receive_connection():
    
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server.bind(("localhost", 8080))
    server.listen(1)
    client = server.accept()[0]
    server.close()
    return client
529138
public synchronized CuratorFramework getLocalConnection() throws IOException
    {
        if ( localConnection == null )
        {
            CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
                .connectString("localhost:" + configManager.getConfig().getInt(IntConfigs.CLIENT_PORT))
                .sessionTimeoutMs(arguments.connectionTimeOutMs * 10)
                .connectionTimeoutMs(arguments.connectionTimeOutMs)
                .retryPolicy(new ExponentialBackoffRetry(1000, 3));

            if ( arguments.aclProvider != null )
            {
                builder = builder.aclProvider(arguments.aclProvider);
            }

            localConnection = builder.build();
            localConnection.start();
        }
        return localConnection;
    }
1205568
def create_rflink_connection(port=None, host=None, baud=57600, protocol=RflinkProtocol,
                             packet_callback=None, event_callback=None,
                             disconnect_callback=None, ignore=None, loop=None):
    """"""
    # use default protocol if not specified
    protocol = partial(
        protocol,
        loop=loop if loop else asyncio.get_event_loop(),
        packet_callback=packet_callback,
        event_callback=event_callback,
        disconnect_callback=disconnect_callback,
        ignore=ignore if ignore else [],
    )

    # setup serial connection if no transport specified
    if host:
        conn = loop.create_connection(protocol, host, port)
    else:
        baud = baud
        conn = create_serial_connection(loop, protocol, port, baud)

    return conn
1106810
def wploader(self):
        ''''''
        if self.target_system not in self.wploader_by_sysid:
            self.wploader_by_sysid[self.target_system] = mavwp.MAVWPLoader()
        return self.wploader_by_sysid[self.target_system]
969062
@Nullable
    public Peer connectToLocalHost() {
        lock.lock();
        try {
            final PeerAddress localhost = PeerAddress.localhost(params);
            backoffMap.put(localhost, new ExponentialBackoff(peerBackoffParams));
            return connectTo(localhost, true, vConnectTimeoutMillis);
        } finally {
            lock.unlock();
        }
    }
958545
function findSystemPortRange() {
  if (systemRange) {
    return systemRange;
  }
  var range = process.platform === 'win32' ?
      findWindowsPortRange() : findUnixPortRange();
  return systemRange = range.thenCatch(function() {
    return DEFAULT_IANA_RANGE;
  });
}