1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2024 Oxide Computer Company 14 */ 15 16 #include <fcntl.h> 17 #include <libdladm.h> 18 #include <libdllink.h> 19 20 #include "viona_suite.h" 21 22 int open_viona(void)23open_viona(void) 24 { 25 return (open(VIONA_DEV, O_RDWR)); 26 } 27 28 /* Convenience helper to get datalink_id_t from an interface name */ 29 dladm_status_t query_dlid(const char * name,datalink_id_t * dlid)30query_dlid(const char *name, datalink_id_t *dlid) 31 { 32 dladm_handle_t hdl; 33 dladm_status_t err; 34 35 err = dladm_open(&hdl); 36 if (err != DLADM_STATUS_OK) { 37 dladm_close(hdl); 38 return (err); 39 } 40 41 err = dladm_name2info(hdl, name, dlid, NULL, NULL, NULL); 42 dladm_close(hdl); 43 44 return (err); 45 } 46