Changes in uspace/app/nic/nic.c [aa2f865:278fede] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nic/nic.c
raa2f865 r278fede 49 49 nic_cable_state_t link_state; 50 50 nic_channel_mode_t duplex; 51 nic_unicast_mode_t unicast_mode;52 nic_multicast_mode_t multicast_mode;53 nic_broadcast_mode_t broadcast_mode;54 51 int speed; 55 52 } nic_info_t; … … 63 60 printf("\taddr <mac_address> - set MAC address\n"); 64 61 printf("\tspeed <10|100|1000> - set NIC speed\n"); 65 printf("\tduplex <half|full|simplex> - set duplex mode\n"); 66 printf("\tauto - enable autonegotiation\n"); 67 printf("\tunicast <block|default|list|promisc> - set unicast receive filtering\n"); 68 printf("\tmulticast <block|list|promisc> - set multicast receive filtering\n"); 69 printf("\tbroadcast <block|allow> - block or allow incoming broadcast frames\n"); 62 printf("\tduplex <half|full> - set duplex mode\n"); 70 63 } 71 64 … … 151 144 } 152 145 153 rc = nic_unicast_get_mode(sess, &info->unicast_mode, 0, NULL, NULL);154 if (rc != EOK) {155 printf("Error gettinc NIC unicast receive mode.\n");156 rc = EIO;157 goto error;158 }159 160 rc = nic_multicast_get_mode(sess, &info->multicast_mode, 0, NULL, NULL);161 if (rc != EOK) {162 printf("Error gettinc NIC multicast receive mode.\n");163 rc = EIO;164 goto error;165 }166 167 rc = nic_broadcast_get_mode(sess, &info->broadcast_mode);168 if (rc != EOK) {169 printf("Error gettinc NIC broadcast receive mode.\n");170 rc = EIO;171 goto error;172 }173 146 174 147 return EOK; … … 193 166 case NIC_CM_HALF_DUPLEX: return "half-duplex"; 194 167 case NIC_CM_SIMPLEX: return "simplex"; 195 default: assert(false); return NULL;196 }197 }198 199 static const char *nic_unicast_mode_str(nic_unicast_mode_t mode)200 {201 switch (mode) {202 case NIC_UNICAST_UNKNOWN: return "unknown";203 case NIC_UNICAST_BLOCKED: return "blocked";204 case NIC_UNICAST_DEFAULT: return "default";205 case NIC_UNICAST_LIST: return "list";206 case NIC_UNICAST_PROMISC: return "promisc";207 default: assert(false); return NULL;208 }209 }210 211 static const char *nic_multicast_mode_str(nic_unicast_mode_t mode)212 {213 switch (mode) {214 case NIC_MULTICAST_UNKNOWN: return "unknown";215 case NIC_MULTICAST_BLOCKED: return "blocked";216 case NIC_MULTICAST_LIST: return "list";217 case NIC_MULTICAST_PROMISC: return "promisc";218 default: assert(false); return NULL;219 }220 }221 222 static const char *nic_broadcast_mode_str(nic_unicast_mode_t mode)223 {224 switch (mode) {225 case NIC_BROADCAST_UNKNOWN: return "unknown";226 case NIC_BROADCAST_BLOCKED: return "blocked";227 case NIC_BROADCAST_ACCEPTED: return "accepted";228 168 default: assert(false); return NULL; 229 169 } … … 266 206 } 267 207 268 printf("[ Index]: [Service Name]\n");208 printf("[Service Name]\n"); 269 209 for (i = 0; i < count; i++) { 270 210 rc = loc_service_get_name(nics[i], &svc_name); … … 285 225 } 286 226 287 printf("% zu: %s\n", i, svc_name);227 printf("%d: %s\n", i, svc_name); 288 228 printf("\tMAC address: %s\n", addr_str); 289 229 printf("\tVendor name: %s\n", … … 293 233 printf("\tLink state: %s\n", 294 234 nic_link_state_str(nic_info.link_state)); 295 printf("\tUnicast receive mode: %s\n",296 nic_unicast_mode_str(nic_info.unicast_mode));297 printf("\tMulticast receive mode: %s\n",298 nic_multicast_mode_str(nic_info.multicast_mode));299 printf("\tBroadcast receive mode: %s\n",300 nic_broadcast_mode_str(nic_info.broadcast_mode));301 235 302 236 if (nic_info.link_state == NIC_CS_PLUGGED) { … … 386 320 387 321 return nic_set_operation_mode(sess, oldspeed, duplex, oldrole); 388 }389 390 static int nic_set_autoneg(int i)391 {392 async_sess_t *sess;393 int rc;394 395 sess = get_nic_by_index(i);396 if (sess == NULL) {397 printf("Specified NIC doesn't exist or cannot connect to it.\n");398 return EINVAL;399 }400 401 rc = nic_autoneg_restart(sess);402 if (rc != EOK) {403 printf("Error restarting NIC autonegotiation.\n");404 return EIO;405 }406 407 return EOK;408 322 } 409 323 … … 434 348 435 349 return nic_set_address(sess, &addr); 436 }437 438 static int nic_set_rx_unicast(int i, char *str)439 {440 async_sess_t *sess;441 442 sess = get_nic_by_index(i);443 if (sess == NULL) {444 printf("Specified NIC doesn't exist or cannot connect to it.\n");445 return EINVAL;446 }447 448 if (!str_cmp(str, "block")) {449 nic_unicast_set_mode(sess, NIC_UNICAST_BLOCKED, NULL, 0);450 return EOK;451 }452 453 if (!str_cmp(str, "default")) {454 nic_unicast_set_mode(sess, NIC_UNICAST_DEFAULT, NULL, 0);455 return EOK;456 }457 458 if (!str_cmp(str, "list")) {459 nic_unicast_set_mode(sess, NIC_UNICAST_LIST, NULL, 0);460 return EOK;461 }462 463 if (!str_cmp(str, "promisc")) {464 nic_unicast_set_mode(sess, NIC_UNICAST_PROMISC, NULL, 0);465 return EOK;466 }467 468 469 printf("Invalid pameter - should be one of: block, default, promisc\n");470 return EINVAL;471 }472 473 static int nic_set_rx_multicast(int i, char *str)474 {475 async_sess_t *sess;476 477 sess = get_nic_by_index(i);478 if (sess == NULL) {479 printf("Specified NIC doesn't exist or cannot connect to it.\n");480 return EINVAL;481 }482 483 if (!str_cmp(str, "block")) {484 nic_multicast_set_mode(sess, NIC_MULTICAST_BLOCKED, NULL, 0);485 return EOK;486 }487 488 if (!str_cmp(str, "list")) {489 nic_multicast_set_mode(sess, NIC_MULTICAST_LIST, NULL, 0);490 return EOK;491 }492 493 if (!str_cmp(str, "promisc")) {494 nic_multicast_set_mode(sess, NIC_MULTICAST_PROMISC, NULL, 0);495 return EOK;496 }497 498 printf("Invalid pameter - should be one of: block, promisc\n");499 return EINVAL;500 }501 502 static int nic_set_rx_broadcast(int i, char *str)503 {504 async_sess_t *sess;505 506 sess = get_nic_by_index(i);507 if (sess == NULL) {508 printf("Specified NIC doesn't exist or cannot connect to it.\n");509 return EINVAL;510 }511 512 if (!str_cmp(str, "block")) {513 nic_broadcast_set_mode(sess, NIC_BROADCAST_BLOCKED);514 return EOK;515 }516 517 if (!str_cmp(str, "accept")) {518 nic_broadcast_set_mode(sess, NIC_BROADCAST_ACCEPTED);519 return EOK;520 }521 522 printf("Invalid pameter - should be 'block' or 'accept'\n");523 return EINVAL;524 350 } 525 351 … … 550 376 return nic_set_duplex(index, argv[3]); 551 377 552 if (!str_cmp(argv[2], "auto"))553 return nic_set_autoneg(index);554 555 if (!str_cmp(argv[2], "unicast"))556 return nic_set_rx_unicast(index, argv[3]);557 558 if (!str_cmp(argv[2], "multicast"))559 return nic_set_rx_multicast(index, argv[3]);560 561 if (!str_cmp(argv[2], "broadcast"))562 return nic_set_rx_broadcast(index, argv[3]);563 564 378 } else { 565 379 printf(NAME ": Invalid argument.\n");
Note:
See TracChangeset
for help on using the changeset viewer.