jdk/src/windows/native/java/net/NetworkInterface.c
changeset 12542 31190502e9e3
parent 10417 947e9a7bf244
child 13245 7ab3ef5b9520
equal deleted inserted replaced
12541:de11282aa666 12542:31190502e9e3
   176     ULONG size;
   176     ULONG size;
   177     DWORD ret;
   177     DWORD ret;
   178     int count;
   178     int count;
   179     netif *netifP;
   179     netif *netifP;
   180     DWORD i;
   180     DWORD i;
   181     int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, net=0;
   181     int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, wlan=0, net=0;
   182 
   182 
   183     /*
   183     /*
   184      * Ask the IP Helper library to enumerate the adapters
   184      * Ask the IP Helper library to enumerate the adapters
   185      */
   185      */
   186     size = sizeof(MIB_IFTABLE);
   186     size = sizeof(MIB_IFTABLE);
   216          * Generate a name for the device as Windows doesn't have any
   216          * Generate a name for the device as Windows doesn't have any
   217          * real concept of a device name.
   217          * real concept of a device name.
   218          */
   218          */
   219         switch (ifrowP->dwType) {
   219         switch (ifrowP->dwType) {
   220             case MIB_IF_TYPE_ETHERNET:
   220             case MIB_IF_TYPE_ETHERNET:
   221                 sprintf(dev_name, "eth%d", eth++);
   221                 _snprintf_s(dev_name, 8, _TRUNCATE, "eth%d", eth++);
   222                 break;
   222                 break;
   223 
   223 
   224             case MIB_IF_TYPE_TOKENRING:
   224             case MIB_IF_TYPE_TOKENRING:
   225                 sprintf(dev_name, "tr%d", tr++);
   225                 _snprintf_s(dev_name, 8, _TRUNCATE, "tr%d", tr++);
   226                 break;
   226                 break;
   227 
   227 
   228             case MIB_IF_TYPE_FDDI:
   228             case MIB_IF_TYPE_FDDI:
   229                 sprintf(dev_name, "fddi%d", fddi++);
   229                 _snprintf_s(dev_name, 8, _TRUNCATE, "fddi%d", fddi++);
   230                 break;
   230                 break;
   231 
   231 
   232             case MIB_IF_TYPE_LOOPBACK:
   232             case MIB_IF_TYPE_LOOPBACK:
   233                 /* There should only be only IPv4 loopback address */
   233                 /* There should only be only IPv4 loopback address */
   234                 if (lo > 0) {
   234                 if (lo > 0) {
   235                     continue;
   235                     continue;
   236                 }
   236                 }
   237                 strcpy(dev_name, "lo");
   237                 strncpy_s(dev_name, 8, "lo", _TRUNCATE);
   238                 lo++;
   238                 lo++;
   239                 break;
   239                 break;
   240 
   240 
   241             case MIB_IF_TYPE_PPP:
   241             case MIB_IF_TYPE_PPP:
   242                 sprintf(dev_name, "ppp%d", ppp++);
   242                 _snprintf_s(dev_name, 8, _TRUNCATE, "ppp%d", ppp++);
   243                 break;
   243                 break;
   244 
   244 
   245             case MIB_IF_TYPE_SLIP:
   245             case MIB_IF_TYPE_SLIP:
   246                 sprintf(dev_name, "sl%d", sl++);
   246                 _snprintf_s(dev_name, 8, _TRUNCATE, "sl%d", sl++);
   247                 break;
   247                 break;
   248 
   248 
       
   249             case IF_TYPE_IEEE80211:
       
   250                 _snprintf_s(dev_name, 8, _TRUNCATE, "wlan%d", wlan++);
       
   251                 break;
       
   252 
   249             default:
   253             default:
   250                 sprintf(dev_name, "net%d", net++);
   254                 _snprintf_s(dev_name, 8, _TRUNCATE, "net%d", net++);
   251         }
   255         }
   252 
   256 
   253         /*
   257         /*
   254          * Allocate a netif structure and space for the name and
   258          * Allocate a netif structure and space for the name and
   255          * display name (description in this case).
   259          * display name (description in this case).
   380             switch (netifP->ifType) {
   384             switch (netifP->ifType) {
   381             case MIB_IF_TYPE_ETHERNET:
   385             case MIB_IF_TYPE_ETHERNET:
   382             case MIB_IF_TYPE_TOKENRING:
   386             case MIB_IF_TYPE_TOKENRING:
   383             case MIB_IF_TYPE_FDDI:
   387             case MIB_IF_TYPE_FDDI:
   384             case MIB_IF_TYPE_LOOPBACK:
   388             case MIB_IF_TYPE_LOOPBACK:
       
   389             case IF_TYPE_IEEE80211:
   385               /**
   390               /**
   386                * Contrary to what it seems to indicate, dwBCastAddr doesn't
   391                * Contrary to what it seems to indicate, dwBCastAddr doesn't
   387                * contain the broadcast address but 0 or 1 depending on whether
   392                * contain the broadcast address but 0 or 1 depending on whether
   388                * the broadcast address should set the bits of the host part
   393                * the broadcast address should set the bits of the host part
   389                * to 0 or 1.
   394                * to 0 or 1.
   926     if (ifRowP != NULL) {
   931     if (ifRowP != NULL) {
   927       switch(ifRowP->dwType) {
   932       switch(ifRowP->dwType) {
   928       case MIB_IF_TYPE_ETHERNET:
   933       case MIB_IF_TYPE_ETHERNET:
   929       case MIB_IF_TYPE_TOKENRING:
   934       case MIB_IF_TYPE_TOKENRING:
   930       case MIB_IF_TYPE_FDDI:
   935       case MIB_IF_TYPE_FDDI:
       
   936       case IF_TYPE_IEEE80211:
   931         len = ifRowP->dwPhysAddrLen;
   937         len = ifRowP->dwPhysAddrLen;
   932         ret = (*env)->NewByteArray(env, len);
   938         ret = (*env)->NewByteArray(env, len);
   933         if (!IS_NULL(ret)) {
   939         if (!IS_NULL(ret)) {
   934           (*env)->SetByteArrayRegion(env, ret, 0, len, (jbyte *) ifRowP->bPhysAddr);
   940           (*env)->SetByteArrayRegion(env, ret, 0, len, (jbyte *) ifRowP->bPhysAddr);
   935         }
   941         }