]> git.saurik.com Git - apple/network_cmds.git/blame_incremental - ifconfig.tproj/nexus.c
network_cmds-606.100.3.tar.gz
[apple/network_cmds.git] / ifconfig.tproj / nexus.c
... / ...
CommitLineData
1/*
2 * Copyright (c) 2017 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23/*
24 * nexus.c
25 * - report information about attached nexus
26 */
27
28/*
29 * Modification History:
30 *
31 * April 10, 2017 Dieter Siegmund (dieter@apple.com)
32 * - created
33 */
34
35#include <sys/param.h>
36#include <sys/ioctl.h>
37#include <sys/socket.h>
38
39#include <stdlib.h>
40#include <unistd.h>
41
42#include <net/ethernet.h>
43#include <net/if.h>
44#include <net/if_var.h>
45#include <net/if_fake_var.h>
46
47#include <net/route.h>
48
49#include <ctype.h>
50#include <stdio.h>
51#include <string.h>
52#include <stdlib.h>
53#include <unistd.h>
54#include <err.h>
55#include <errno.h>
56
57#include "ifconfig.h"
58
59static void
60nexus_status(int s)
61{
62 struct if_nexusreq ifnr;
63 uuid_string_t flowswitch;
64 uuid_string_t netif;
65
66 if (!verbose) {
67 return;
68 }
69 bzero((char *)&ifnr, sizeof(ifnr));
70 strlcpy(ifnr.ifnr_name, ifr.ifr_name, sizeof(ifnr.ifnr_name));
71 if (ioctl(s, SIOCGIFNEXUS, &ifnr) < 0) {
72 return;
73 }
74 if (uuid_is_null(ifnr.ifnr_netif)) {
75 /* technically, this shouldn't happen */
76 return;
77 }
78 uuid_unparse_upper(ifnr.ifnr_netif, netif);
79 printf("\tnetif: %s\n", netif);
80 if (uuid_is_null(ifnr.ifnr_flowswitch) == 0) {
81 uuid_unparse_upper(ifnr.ifnr_flowswitch, flowswitch);
82 printf("\tflowswitch: %s\n", flowswitch);
83 }
84 return;
85}
86
87static struct afswtch af_fake = {
88 .af_name = "af_fake",
89 .af_af = AF_UNSPEC,
90 .af_other_status = nexus_status,
91};
92
93static __constructor void
94fake_ctor(void)
95{
96 af_register(&af_fake);
97}
98