Changeset aa2f865 in mainline
- Timestamp:
- 2014-08-18T14:08:40Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 320bd52
- Parents:
- 2ff9876
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nic/nic.c
r2ff9876 raa2f865 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; 51 54 int speed; 52 55 } nic_info_t; … … 62 65 printf("\tduplex <half|full|simplex> - set duplex mode\n"); 63 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"); 64 70 } 65 71 … … 145 151 } 146 152 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 } 147 173 148 174 return EOK; … … 167 193 case NIC_CM_HALF_DUPLEX: return "half-duplex"; 168 194 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"; 169 228 default: assert(false); return NULL; 170 229 } … … 234 293 printf("\tLink state: %s\n", 235 294 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)); 236 301 237 302 if (nic_info.link_state == NIC_CS_PLUGGED) { … … 369 434 370 435 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; 371 524 } 372 525 … … 400 553 return nic_set_autoneg(index); 401 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 402 564 } else { 403 565 printf(NAME ": Invalid argument.\n");
Note:
See TracChangeset
for help on using the changeset viewer.