dladm.c (98f3797ebaef8d89cea9767b7d3c49a9b5885065) | dladm.c (e6c4e893c6a9849a441fddbb31ea45dc6814ec6b) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 12 unchanged lines hidden (view full) --- 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright 2016 Nexenta Systems, Inc. 25 * Copyright (c) 2015 Joyent, Inc. All rights reserved. 26 * Copyright 2020 Peter Tribble. 27 * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. 28 * Copyright 2021 RackTop Systems, Inc. | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 12 unchanged lines hidden (view full) --- 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright 2016 Nexenta Systems, Inc. 25 * Copyright (c) 2015 Joyent, Inc. All rights reserved. 26 * Copyright 2020 Peter Tribble. 27 * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. 28 * Copyright 2021 RackTop Systems, Inc. |
29 * Copyright 2024 H. William Welliver <william@welliver.org> |
|
29 */ 30 31#include <stdio.h> 32#include <ctype.h> 33#include <dlfcn.h> 34#include <locale.h> 35#include <signal.h> 36#include <stdarg.h> --- 5412 unchanged lines hidden (view full) --- 5449} 5450 5451static void 5452do_create_simnet(int argc, char *argv[], const char *use) 5453{ 5454 uint32_t flags; 5455 char *altroot = NULL; 5456 char *media = NULL; | 30 */ 31 32#include <stdio.h> 33#include <ctype.h> 34#include <dlfcn.h> 35#include <locale.h> 36#include <signal.h> 37#include <stdarg.h> --- 5412 unchanged lines hidden (view full) --- 5450} 5451 5452static void 5453do_create_simnet(int argc, char *argv[], const char *use) 5454{ 5455 uint32_t flags; 5456 char *altroot = NULL; 5457 char *media = NULL; |
5458 char *maddr = NULL; |
|
5457 uint32_t mtype = DL_ETHER; 5458 int option; 5459 dladm_status_t status; 5460 char name[MAXLINKNAMELEN]; 5461 5462 name[0] = '\0'; 5463 flags = DLADM_OPT_ACTIVE | DLADM_OPT_PERSIST; 5464 5465 opterr = 0; | 5459 uint32_t mtype = DL_ETHER; 5460 int option; 5461 dladm_status_t status; 5462 char name[MAXLINKNAMELEN]; 5463 5464 name[0] = '\0'; 5465 flags = DLADM_OPT_ACTIVE | DLADM_OPT_PERSIST; 5466 5467 opterr = 0; |
5466 while ((option = getopt_long(argc, argv, ":tR:m:", | 5468 while ((option = getopt_long(argc, argv, ":tR:m:u:", |
5467 simnet_lopts, NULL)) != -1) { 5468 switch (option) { 5469 case 't': 5470 flags &= ~DLADM_OPT_PERSIST; 5471 break; 5472 case 'R': 5473 altroot = optarg; 5474 break; 5475 case 'm': 5476 media = optarg; 5477 break; | 5469 simnet_lopts, NULL)) != -1) { 5470 switch (option) { 5471 case 't': 5472 flags &= ~DLADM_OPT_PERSIST; 5473 break; 5474 case 'R': 5475 altroot = optarg; 5476 break; 5477 case 'm': 5478 media = optarg; 5479 break; |
5480 case 'u': 5481 maddr = optarg; 5482 break; |
|
5478 default: 5479 die_opterr(optopt, option, use); 5480 } 5481 } | 5483 default: 5484 die_opterr(optopt, option, use); 5485 } 5486 } |
5482 | |
5483 /* the simnet id is the required operand */ 5484 if (optind != (argc - 1)) 5485 usage(); 5486 5487 if (strlcpy(name, argv[optind], MAXLINKNAMELEN) >= MAXLINKNAMELEN) | 5487 /* the simnet id is the required operand */ 5488 if (optind != (argc - 1)) 5489 usage(); 5490 5491 if (strlcpy(name, argv[optind], MAXLINKNAMELEN) >= MAXLINKNAMELEN) |
5488 die("link name too long '%s'", argv[optind]); | 5492 die_dlerr(DLADM_STATUS_LINKINVAL, 5493 "link name too long '%s'", argv[optind]); |
5489 5490 if (!dladm_valid_linkname(name)) | 5494 5495 if (!dladm_valid_linkname(name)) |
5491 die("invalid link name '%s'", name); | 5496 die_dlerr(DLADM_STATUS_LINKINVAL, 5497 "invalid link name '%s'", name); |
5492 5493 if (media != NULL) { 5494 mtype = dladm_str2media(media); 5495 if (mtype != DL_ETHER && mtype != DL_WIFI) | 5498 5499 if (media != NULL) { 5500 mtype = dladm_str2media(media); 5501 if (mtype != DL_ETHER && mtype != DL_WIFI) |
5496 die("media type '%s' is not supported", media); | 5502 die_dlerr(DLADM_STATUS_NOTSUP, 5503 "media type '%s' is not supported", media); |
5497 } 5498 5499 if (altroot != NULL) 5500 altroot_cmd(altroot, argc, argv); 5501 | 5504 } 5505 5506 if (altroot != NULL) 5507 altroot_cmd(altroot, argc, argv); 5508 |
5502 status = dladm_simnet_create(handle, name, mtype, flags); | 5509 status = dladm_simnet_create(handle, name, mtype, maddr, flags); 5510 |
5503 if (status != DLADM_STATUS_OK) 5504 die_dlerr(status, "simnet creation failed"); 5505} 5506 5507static void 5508do_delete_simnet(int argc, char *argv[], const char *use) 5509{ 5510 int option; --- 5075 unchanged lines hidden --- | 5511 if (status != DLADM_STATUS_OK) 5512 die_dlerr(status, "simnet creation failed"); 5513} 5514 5515static void 5516do_delete_simnet(int argc, char *argv[], const char *use) 5517{ 5518 int option; --- 5075 unchanged lines hidden --- |