Permalink
Browse files

import from ALTQ 1.2

  • Loading branch information...
1 parent e8a9424 commit ed3bc419971ee19ad3dab1aa0ec96df3a9aea619 itojun committed Jul 11, 1999
Showing with 199 additions and 0 deletions.
  1. +50 −0 usr.sbin/pvcsif/pvcsif.8
  2. +149 −0 usr.sbin/pvcsif/pvcsif.c
View
@@ -0,0 +1,50 @@
+.Dd December 29, 1997
+.Dt PVCSIF 8
+.Os BSD
+.Sh NAME
+.Nm pvcsif
+.Nd configure ATM PVC sub interfaces
+.Sh SYNOPSIS
+.Nm pvcsif
+.Ar interface
+.Op Fl s
+.Nm pvcsif
+.Fl a
+.Sh DESCRIPTION
+.Nm
+creates a sub interface for an ATM PVC.
+A sub interface
+.Xr pvc 4
+is dynamically created.
+The created interface is bound to
+.Ar interface
+but at this point no VC is assigned. To assign a VC,
+.Xr pvctxctl 8
+should be used later.
+.Pp
+A PVC sub interface is intended to use an ATM PVC as an alternative
+serial connection, and to be allocated per PVC basis.
+A PVC sub interface looks as a point-to-point interface
+and is multicast capable, as opposed to the NBMA
+(NonBroadcast Multiple Access) model that requires a MARS server.
+A point-to-point interface is useful to run MBone or protocols
+requiring multicast, such as RSVP and IPv6, over a PVC WAN
+connection.
+.Pp
+Note that a sub interface is not a full-fledged interface but just
+an indirect reference to the real interface.
+.Pp
+The options are as follows:
+.Bl -tag -width Fl
+.It Fl s
+For use with a shell, it prints the created interface name.
+.It Fl a
+Lists the existing sub interfaces.
+.El
+.Sh CAVEATS
+Currently, there is no way to remove a sub interface.
+
+.Sh SEE ALSO
+.Xr pvctxctl 8 ,
+.Xr ifconfig 8 ,
+.Xr en 4
View
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 1998
+ * Sony Computer Science Laboratory Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: pvcsif.c,v 1.1.1.1 1999/07/11 17:28:28 itojun Exp $
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <err.h>
+
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+
+#include <net/if_atm.h>
+
+#include "if_nameindex.h"
+
+void list_all(void);
+
+void usage(void)
+{
+ fprintf(stderr, "usage: pvcsif -a\n");
+ fprintf(stderr, " pvcsif interface [-s]\n");
+ exit(1);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct ifreq ifr;
+ int shell_mode = 0;
+ int s, ch;
+
+ if (argc < 2)
+ usage();
+
+ if (strncmp(argv[1], "-a", 2) == 0) {
+ list_all();
+ return (0);
+ }
+
+ ifr.ifr_name[IFNAMSIZ-1] = '\0';
+ strncpy(ifr.ifr_name, argv[1], IFNAMSIZ-1);
+
+ optind = 2;
+ while ((ch = getopt(argc, argv, "s")) != EOF) {
+ switch (ch) {
+ case 's':
+ shell_mode = 1;
+ break;
+ }
+ }
+
+ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ err(1, "can't open socket");
+
+ if (ioctl(s, SIOCSPVCSIF, &ifr) < 0)
+ err(1, "SIOCSPVCSIF");
+
+ close(s);
+
+ if (shell_mode)
+ printf("%s", ifr.ifr_name);
+ else
+ printf("created a pvc subinterface %s (bound to %s)\n",
+ ifr.ifr_name, argv[1]);
+
+ return (0);
+}
+
+void
+list_all(void)
+{
+ struct if_nameindex *ifn_list, *ifnp;
+ struct pvctxreq pvcreq;
+ int pcr, s;
+
+ if ((ifn_list = if_nameindex()) == NULL)
+ err(1, "if_nameindex failed");
+
+ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ err(1, "can't open socket");
+
+ for (ifnp = ifn_list; ifnp->if_name != NULL; ifnp++) {
+ if (strncmp(ifnp->if_name, "pvc", 3) == 0) {
+
+ bzero(&pvcreq, sizeof(pvcreq));
+ strncpy(pvcreq.pvc_ifname, ifnp->if_name, IFNAMSIZ-1);
+ if (ioctl(s, SIOCGPVCTX, &pvcreq) < 0)
+ err(1, "SIOCSPVCTX");
+
+ /*
+ * print info
+ */
+ pcr = pvcreq.pvc_pcr;
+ printf(" %s (bound to %s): vci:[%d:%d] (",
+ ifnp->if_name, pvcreq.pvc_ifname,
+ ATM_PH_VPI(&pvcreq.pvc_aph),
+ ATM_PH_VCI(&pvcreq.pvc_aph));
+ if (ATM_PH_FLAGS(&pvcreq.pvc_aph) & ATM_PH_AAL5)
+ printf("AAL5");
+ if (ATM_PH_FLAGS(&pvcreq.pvc_aph) & ATM_PH_LLCSNAP)
+ printf("/LLCSNAP");
+ printf(") ");
+ if (pcr < 0)
+ printf("(invalid)\n");
+ else if (pcr == 0)
+ printf("pcr:%d(full speed)\n", pcr);
+ else if (pcr < 1000)
+ printf("pcr:%d(%dbps)\n",
+ pcr, pcr * 48 * 8);
+ else if (pcr < 1000000)
+ printf("pcr:%d(%dKbps)\n",
+ pcr, pcr * 48 * 8 / 1000);
+ else
+ printf("pcr:%d(%dMbps)\n",
+ pcr, pcr * 48 * 8 / 1000000);
+ }
+ }
+
+ close(s);
+ if_freenameindex(ifn_list);
+}

0 comments on commit ed3bc41

Please sign in to comment.