Changeset 7493e7b in mainline for uspace/app/nic/nic.c
- Timestamp:
- 2014-07-13T22:59:27Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 07e647a
- Parents:
- af2a76c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nic/nic.c
raf2a76c r7493e7b 45 45 46 46 typedef struct { 47 nic_device_info_t device_info; 47 48 nic_address_t address; 48 49 nic_cable_state_t link_state; 50 nic_channel_mode_t duplex; 51 int speed; 49 52 } nic_info_t; 50 53 … … 59 62 { 60 63 async_sess_t *sess; 64 nic_role_t role; 61 65 int rc; 62 66 … … 75 79 } 76 80 81 rc = nic_get_device_info(sess, &info->device_info); 82 if (rc != EOK) { 83 printf("Error getting NIC device info.\n"); 84 rc = EIO; 85 goto error; 86 } 87 77 88 rc = nic_get_cable_state(sess, &info->link_state); 78 89 if (rc != EOK) { … … 81 92 goto error; 82 93 } 94 95 rc = nic_get_operation_mode(sess, &info->speed, &info->duplex, &role); 96 if (rc != EOK) { 97 printf("Error getting NIC speed and duplex mode.\n"); 98 rc = EIO; 99 goto error; 100 } 101 83 102 84 103 return EOK; … … 93 112 case NIC_CS_PLUGGED: return "up"; 94 113 case NIC_CS_UNPLUGGED: return "down"; 114 default: assert(false); return NULL; 115 } 116 } 117 118 static const char *nic_duplex_mode_str(nic_channel_mode_t mode) 119 { 120 switch (mode) { 121 case NIC_CM_FULL_DUPLEX: return "full-duplex"; 122 case NIC_CM_HALF_DUPLEX: return "half-duplex"; 95 123 default: assert(false); return NULL; 96 124 } … … 133 161 } 134 162 135 printf("[Address] [ Link State] [Service Name]\n");163 printf("[Address] [Service Name]\n"); 136 164 for (i = 0; i < count; i++) { 137 165 rc = loc_service_get_name(nics[i], &svc_name); … … 152 180 } 153 181 154 printf("%s %s %s\n", addr_str, 155 nic_link_state_str(nic_info.link_state), svc_name); 182 printf("%s %s\n", addr_str, svc_name); 183 printf("\tVendor name: %s\n", 184 nic_info.device_info.vendor_name); 185 printf("\tModel name: %s\n", 186 nic_info.device_info.model_name); 187 printf("\tLink state: %s\n", 188 nic_link_state_str(nic_info.link_state)); 189 190 if (nic_info.link_state == NIC_CS_PLUGGED) { 191 printf("\tSpeed: %dMbps %s\n", nic_info.speed, 192 nic_duplex_mode_str(nic_info.duplex)); 193 } 156 194 157 195 free(svc_name);
Note:
See TracChangeset
for help on using the changeset viewer.