This commit was manufactured by cvs2svn to create branch 'RELENG_6'.
This commit is contained in:
parent
403b2f3a00
commit
cd5e537b6a
54
contrib/openbsm/compat/clock_gettime.h
Normal file
54
contrib/openbsm/compat/clock_gettime.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 2006 Robert N. M. Watson
|
||||
* 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 THE AUTHOR 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 THE AUTHOR 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.
|
||||
*
|
||||
* $P4: //depot/projects/trustedbsd/openbsm/compat/clock_gettime.h#2 $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Compatibility routines for clock_gettime(CLOCK_REALTIME, ...) for systems
|
||||
* that don't have it. We don't use clockid_t in order to avoid conflicts
|
||||
* with the native OS if it has one but not clock_gettime(). We also assume
|
||||
* that the sys/time.h include has already happened at this point, so we have
|
||||
* access to gettimeofday().
|
||||
*/
|
||||
#include <errno.h>
|
||||
|
||||
#define CLOCK_REALTIME 0x2d4e1588
|
||||
|
||||
static inline int
|
||||
clock_gettime(int clock_id, struct timespec *ts)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (clock_id != CLOCK_REALTIME) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
if (gettimeofday(&tv, NULL) < 0)
|
||||
return (-1);
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
ts->tv_nsec = tv.tv_usec * 1000;
|
||||
return (0);
|
||||
}
|
BIN
contrib/openbsm/test/reference/process32ex_record-IPv4
Normal file
BIN
contrib/openbsm/test/reference/process32ex_record-IPv4
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process32ex_record-IPv6
Normal file
BIN
contrib/openbsm/test/reference/process32ex_record-IPv6
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process32ex_token-IPv4
Normal file
BIN
contrib/openbsm/test/reference/process32ex_token-IPv4
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process32ex_token-IPv6
Normal file
BIN
contrib/openbsm/test/reference/process32ex_token-IPv6
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process64_record
Normal file
BIN
contrib/openbsm/test/reference/process64_record
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process64_token
Normal file
BIN
contrib/openbsm/test/reference/process64_token
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process64ex_record-IPv4
Normal file
BIN
contrib/openbsm/test/reference/process64ex_record-IPv4
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process64ex_record-IPv6
Normal file
BIN
contrib/openbsm/test/reference/process64ex_record-IPv6
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process64ex_token-IPv4
Normal file
BIN
contrib/openbsm/test/reference/process64ex_token-IPv4
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/process64ex_token-IPv6
Normal file
BIN
contrib/openbsm/test/reference/process64ex_token-IPv6
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/zonename_record
Normal file
BIN
contrib/openbsm/test/reference/zonename_record
Normal file
Binary file not shown.
BIN
contrib/openbsm/test/reference/zonename_token
Normal file
BIN
contrib/openbsm/test/reference/zonename_token
Normal file
Binary file not shown.
28
etc/periodic/daily/480.status-ntpd
Normal file
28
etc/periodic/daily/480.status-ntpd
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
# If there is a global system configuration file, suck it in.
|
||||
#
|
||||
if [ -r /etc/defaults/periodic.conf ]
|
||||
then
|
||||
. /etc/defaults/periodic.conf
|
||||
source_periodic_confs
|
||||
fi
|
||||
|
||||
rc=0
|
||||
|
||||
case "$daily_status_ntpd_enable" in
|
||||
[Yy][Ee][Ss])
|
||||
echo ""
|
||||
echo "NTP status:"
|
||||
|
||||
synchronized=$(ntpq -p | tee /dev/stderr | grep '^\*')
|
||||
if [ -z "$synchronized" ]; then
|
||||
rc=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $rc
|
153
sbin/ifconfig/iflagg.c
Normal file
153
sbin/ifconfig/iflagg.c
Normal file
@ -0,0 +1,153 @@
|
||||
/*-
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_lagg.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "ifconfig.h"
|
||||
|
||||
static void
|
||||
setlaggport(const char *val, int d, int s, const struct afswtch *afp)
|
||||
{
|
||||
struct lagg_reqport rp;
|
||||
|
||||
bzero(&rp, sizeof(rp));
|
||||
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
|
||||
strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname));
|
||||
|
||||
if (ioctl(s, SIOCSLAGGPORT, &rp))
|
||||
err(1, "SIOCSLAGGPORT");
|
||||
}
|
||||
|
||||
static void
|
||||
unsetlaggport(const char *val, int d, int s, const struct afswtch *afp)
|
||||
{
|
||||
struct lagg_reqport rp;
|
||||
|
||||
bzero(&rp, sizeof(rp));
|
||||
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
|
||||
strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname));
|
||||
|
||||
if (ioctl(s, SIOCSLAGGDELPORT, &rp))
|
||||
err(1, "SIOCSLAGGDELPORT");
|
||||
}
|
||||
|
||||
static void
|
||||
setlaggproto(const char *val, int d, int s, const struct afswtch *afp)
|
||||
{
|
||||
struct lagg_protos tpr[] = LAGG_PROTOS;
|
||||
struct lagg_reqall ra;
|
||||
int i;
|
||||
|
||||
bzero(&ra, sizeof(ra));
|
||||
ra.ra_proto = LAGG_PROTO_MAX;
|
||||
|
||||
for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++) {
|
||||
if (strcmp(val, tpr[i].tpr_name) == 0) {
|
||||
ra.ra_proto = tpr[i].tpr_proto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ra.ra_proto == LAGG_PROTO_MAX)
|
||||
errx(1, "Invalid aggregation protocol: %s", val);
|
||||
|
||||
strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
|
||||
if (ioctl(s, SIOCSLAGG, &ra) != 0)
|
||||
err(1, "SIOCSLAGG");
|
||||
}
|
||||
|
||||
static void
|
||||
lagg_status(int s)
|
||||
{
|
||||
struct lagg_protos tpr[] = LAGG_PROTOS;
|
||||
struct lagg_reqport rp, rpbuf[LAGG_MAX_PORTS];
|
||||
struct lagg_reqall ra;
|
||||
const char *proto = "<unknown>";
|
||||
int i, isport = 0;
|
||||
|
||||
bzero(&rp, sizeof(rp));
|
||||
bzero(&ra, sizeof(ra));
|
||||
|
||||
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
|
||||
strlcpy(rp.rp_portname, name, sizeof(rp.rp_portname));
|
||||
|
||||
if (ioctl(s, SIOCGLAGGPORT, &rp) == 0)
|
||||
isport = 1;
|
||||
|
||||
strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
|
||||
ra.ra_size = sizeof(rpbuf);
|
||||
ra.ra_port = rpbuf;
|
||||
|
||||
if (ioctl(s, SIOCGLAGG, &ra) == 0) {
|
||||
for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++) {
|
||||
if (ra.ra_proto == tpr[i].tpr_proto) {
|
||||
proto = tpr[i].tpr_name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\tlagg: laggproto %s", proto);
|
||||
if (isport)
|
||||
printf(" laggdev %s", rp.rp_ifname);
|
||||
putchar('\n');
|
||||
|
||||
for (i = 0; i < ra.ra_ports; i++) {
|
||||
printf("\t\tlaggport %s ", rpbuf[i].rp_portname);
|
||||
printb("", rpbuf[i].rp_flags, LAGG_PORT_BITS);
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
if (0 /* XXX */) {
|
||||
printf("\tsupported aggregation protocols:\n");
|
||||
for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++)
|
||||
printf("\t\tlaggproto %s\n", tpr[i].tpr_name);
|
||||
}
|
||||
} else if (isport)
|
||||
printf("\tlagg: laggdev %s\n", rp.rp_ifname);
|
||||
}
|
||||
|
||||
static struct cmd lagg_cmds[] = {
|
||||
DEF_CMD_ARG("laggport", setlaggport),
|
||||
DEF_CMD_ARG("-laggport", unsetlaggport),
|
||||
DEF_CMD_ARG("laggproto", setlaggproto),
|
||||
};
|
||||
static struct afswtch af_lagg = {
|
||||
.af_name = "af_lagg",
|
||||
.af_af = AF_UNSPEC,
|
||||
.af_other_status = lagg_status,
|
||||
};
|
||||
|
||||
static __constructor void
|
||||
lagg_ctor(void)
|
||||
{
|
||||
#define N(a) (sizeof(a) / sizeof(a[0]))
|
||||
int i;
|
||||
|
||||
for (i = 0; i < N(lagg_cmds); i++)
|
||||
cmd_register(&lagg_cmds[i]);
|
||||
af_register(&af_lagg);
|
||||
#undef N
|
||||
}
|
174
share/man/man4/lagg.4
Normal file
174
share/man/man4/lagg.4
Normal file
@ -0,0 +1,174 @@
|
||||
.\" $OpenBSD: trunk.4,v 1.18 2006/06/09 13:53:34 jmc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this software for any
|
||||
.\" purpose with or without fee is hereby granted, provided that the above
|
||||
.\" copyright notice and this permission notice appear in all copies.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 17, 2007
|
||||
.Dt LAGG 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm lagg
|
||||
.Nd link aggregation and link failover interface
|
||||
.Sh SYNOPSIS
|
||||
To compile this driver into the kernel,
|
||||
place the following line in your
|
||||
kernel configuration file:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "device lagg"
|
||||
.Ed
|
||||
.Pp
|
||||
Alternatively, to load the driver as a
|
||||
module at boot time, place the following line in
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
if_lagg_load="YES"
|
||||
.Ed
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
interface allows aggregation of multiple network interfaces as one virtual
|
||||
.Nm
|
||||
interface for the purpose of providing fault-tolerance and high-speed links.
|
||||
.Pp
|
||||
A
|
||||
.Nm
|
||||
interface can be created using the
|
||||
.Ic ifconfig lagg Ns Ar N Ic create
|
||||
command.
|
||||
It can use different link aggregation protocols specified
|
||||
using the
|
||||
.Ic laggproto Ar proto
|
||||
option.
|
||||
Child interfaces can be added using the
|
||||
.Ic laggport Ar child-iface
|
||||
option and removed using the
|
||||
.Ic -laggport Ar child-iface
|
||||
option.
|
||||
.Pp
|
||||
The driver currently supports the aggregation protocols
|
||||
.Ic failover
|
||||
(the default),
|
||||
.Ic fec ,
|
||||
.Ic lacp ,
|
||||
.Ic loadbalance ,
|
||||
.Ic roundrobin ,
|
||||
and
|
||||
.Ic none .
|
||||
The protocols determine which ports are used for outgoing traffic
|
||||
and whether a specific port accepts incoming traffic.
|
||||
The interface link state is used to validate if the port is active or
|
||||
not.
|
||||
.Bl -tag -width loadbalance
|
||||
.It Ic failover
|
||||
Sends and receives traffic only through the master port.
|
||||
If the master port becomes unavailable,
|
||||
the next active port is used.
|
||||
The first interface added is the master port;
|
||||
any interfaces added after that are used as failover devices.
|
||||
.It Ic fec
|
||||
Supports Cisco EtherChannel.
|
||||
This is a static setup and does not negotiate aggregation with the peer or
|
||||
exchange frames to monitor the link.
|
||||
.It Ic lacp
|
||||
Supports the IEEE 802.3ad Link Aggregation Control Protocol (LACP) and the
|
||||
Marker Protocol.
|
||||
LACP will negotiate a set of aggregable links with the peer in to one or more
|
||||
Link Aggregated Groups.
|
||||
Each LAG is composed of ports of the same speed, set to full-duplex operation.
|
||||
The traffic will be balanced across the ports in the LAG with the greatest
|
||||
total speed, in most cases there will only be one LAG which contains all ports.
|
||||
In the event of changes in physical connectivity, Link Aggregation will quickly
|
||||
converge to a new configuration.
|
||||
.It Ic loadbalance
|
||||
Balances outgoing traffic across the active ports based on hashed
|
||||
protocol header information and accepts incoming traffic from
|
||||
any active port.
|
||||
This is a static setup and does not negotiate aggregation with the peer or
|
||||
exchange frames to monitor the link.
|
||||
The hash includes the Ethernet source and destination address, and, if
|
||||
available, the VLAN tag, and the IP source and destination address.
|
||||
.It Ic roundrobin
|
||||
Distributes outgoing traffic using a round-robin scheduler
|
||||
through all active ports and accepts incoming traffic from
|
||||
any active port.
|
||||
.It Ic none
|
||||
This protocol is intended to do nothing: it disables any traffic without
|
||||
disabling the
|
||||
.Nm
|
||||
interface itself.
|
||||
.El
|
||||
.Pp
|
||||
Each
|
||||
.Nm
|
||||
interface is created at runtime using interface cloning.
|
||||
This is
|
||||
most easily done with the
|
||||
.Xr ifconfig 8
|
||||
.Cm create
|
||||
command or using the
|
||||
.Va cloned_interfaces
|
||||
variable in
|
||||
.Xr rc.conf 5 .
|
||||
.Sh EXAMPLES
|
||||
Create a 802.3ad link aggregation using LACP with two
|
||||
.Xr bge 4
|
||||
Gigabit Ethernet interfaces:
|
||||
.Bd -literal -offset indent
|
||||
# ifconfig bge0 up
|
||||
# ifconfig bge1 up
|
||||
# ifconfig lagg0 laggproto lacp laggport bge0 laggport bge1 \e
|
||||
192.168.1.1 netmask 255.255.255.0
|
||||
.Ed
|
||||
.Pp
|
||||
The following example uses an active failover interface to set up roaming
|
||||
between wired and wireless networks using two network devices.
|
||||
Whenever the wired master interface is unplugged, the wireless failover
|
||||
device will be used:
|
||||
.Bd -literal -offset indent
|
||||
# ifconfig em0 up
|
||||
# ifconfig ath0 nwid my_net up
|
||||
# ifconfig lagg0 laggproto failover laggport em0 laggport ath0 \e
|
||||
192.168.1.1 netmask 255.255.255.0
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr ng_fec 4 ,
|
||||
.Xr ng_one2many 4 ,
|
||||
.Xr ifconfig 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device first appeared in
|
||||
.Fx 7.0 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
driver was written under the name
|
||||
.Nm trunk
|
||||
by
|
||||
.An Reyk Floeter Aq reyk@openbsd.org .
|
||||
The LACP implementation was written by
|
||||
.An YAMAMOTO Takashi
|
||||
for
|
||||
.Nx .
|
||||
.Sh BUGS
|
||||
There is no way to configure LACP administrative variables, including system
|
||||
and port priorities.
|
||||
The current implementation always performs active-mode LACP and uses 0x8000 as
|
||||
system and port priorities.
|
||||
.Pp
|
||||
WPA security does not currently work correctly with a wireless interface added
|
||||
to the lagg port.
|
249
share/man/man4/snd_hda.4
Normal file
249
share/man/man4/snd_hda.4
Normal file
@ -0,0 +1,249 @@
|
||||
.\" Copyright (c) 2006 Joel Dahl <joel@FreeBSD.org>
|
||||
.\" 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 THE AUTHOR 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 THE AUTHOR 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.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 5, 2007
|
||||
.Dt SND_HDA 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm snd_hda
|
||||
.Nd "Intel High Definition Audio bridge device driver"
|
||||
.Sh SYNOPSIS
|
||||
To compile this driver into the kernel, place the following lines in your
|
||||
kernel configuration file:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "device sound"
|
||||
.Cd "device snd_hda"
|
||||
.Ed
|
||||
.Pp
|
||||
Alternatively, to load the driver as a module at boot time, place the
|
||||
following line in
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
snd_hda_load="YES"
|
||||
.Ed
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
bridge device driver allows the generic audio driver,
|
||||
.Xr sound 4 ,
|
||||
to attach to Intel High Definition Audio devices.
|
||||
The
|
||||
.Nm
|
||||
driver supports hardware that conforms with revision 1.0 of the Intel High
|
||||
Definition Audio specification and tries to behave much like the Microsoft
|
||||
Universal Audio Architecture (UAA) draft (revision 0.7b) for handling audio
|
||||
devices.
|
||||
HDA acts like a primary bus, similar to
|
||||
.Xr miibus 4 ,
|
||||
for handling various child buses such as audio, modem and HDMI (High Definition
|
||||
Multimedia Interface).
|
||||
Only audio is implemented in the
|
||||
.Nm
|
||||
driver.
|
||||
.Pp
|
||||
The High Definition (HD) Audio specification was developed by Intel as the
|
||||
logical successor of the old AC'97 specification and has several advantages,
|
||||
such as higher bandwidth which allows more channels and more detailed formats,
|
||||
support for several logical audio devices, and general purpose DMA channels.
|
||||
.Pp
|
||||
The HDA specification defines the register-level interface, physical link
|
||||
characteristics, codec programming models, and codec architectural components.
|
||||
This specification is intended for both device driver developers and hardware
|
||||
component designers.
|
||||
.Ss Boot-time Configuration
|
||||
The following variables are available at boot-time through the
|
||||
.Xr device.hints 5
|
||||
file:
|
||||
.Bl -tag -width ".Va hint.pcm.%d.config" -offset indent
|
||||
.It Va hint.pcm.%d.config
|
||||
Configures a range of possible options.
|
||||
Possible values are:
|
||||
.Dq Li dmapos ,
|
||||
.Dq Li eapdinv ,
|
||||
.Dq Li gpio0 ,
|
||||
.Dq Li gpio1 ,
|
||||
.Dq Li gpio2 ,
|
||||
.Dq Li gpio3 ,
|
||||
.Dq Li gpio4 ,
|
||||
.Dq Li gpio5 ,
|
||||
.Dq Li gpio6 ,
|
||||
.Dq Li gpio7 ,
|
||||
.Dq Li gpioflush ,
|
||||
.Dq Li ivref ,
|
||||
.Dq Li ivref50 ,
|
||||
.Dq Li ivref80 ,
|
||||
.Dq Li ivref100 ,
|
||||
.Dq Li fixedrate ,
|
||||
.Dq Li forcestereo ,
|
||||
.Dq Li ovref ,
|
||||
.Dq Li ovref50 ,
|
||||
.Dq Li ovref80 ,
|
||||
.Dq Li ovref100 ,
|
||||
.Dq Li softpcmvol ,
|
||||
and
|
||||
.Dq Li vref .
|
||||
An option prefixed with
|
||||
.Dq Li no ,
|
||||
such as
|
||||
.Dq Li nofixedrate ,
|
||||
will do the opposite and takes precedence.
|
||||
Options can be separated by whitespace and commas.
|
||||
.El
|
||||
.Ss Runtime Configuration
|
||||
The following
|
||||
.Xr sysctl 8
|
||||
variables are available in addition to those available to all
|
||||
.Xr sound 4
|
||||
devices:
|
||||
.Bl -tag -width ".Va dev.pcm.%d.polling" -offset indent
|
||||
.It Va dev.pcm.%d.polling
|
||||
Experimental polling mode, where the driver operates by querying the device
|
||||
state on each tick using
|
||||
.Xr callout 9 .
|
||||
Polling is disabled by default.
|
||||
Do not enable it unless you are facing weird interrupt problems or if the
|
||||
device cannot generate interrupts at all.
|
||||
.El
|
||||
.Sh HARDWARE
|
||||
The
|
||||
.Nm
|
||||
driver supports the following audio chipsets:
|
||||
.Pp
|
||||
.Bl -bullet -compact
|
||||
.It
|
||||
ATI SB450
|
||||
.It
|
||||
ATI SB600
|
||||
.It
|
||||
Intel 631x/632xESB
|
||||
.It
|
||||
Intel 82801F
|
||||
.It
|
||||
Intel 82801G
|
||||
.It
|
||||
Intel 82801H
|
||||
.It
|
||||
nVidia MCP51
|
||||
.It
|
||||
nVidia MCP55
|
||||
.It
|
||||
nVidia MCP61A
|
||||
.It
|
||||
nVidia MCP61B
|
||||
.It
|
||||
nVidia MCP65A
|
||||
.It
|
||||
nVidia MCP65B
|
||||
.It
|
||||
SiS 966
|
||||
.It
|
||||
VIA VT8251/8237A
|
||||
.El
|
||||
.Pp
|
||||
Generic audio chipsets compatible with the Intel HDA specification should work,
|
||||
but have not been verified yet.
|
||||
The following codecs have been verified to work:
|
||||
.Pp
|
||||
.Bl -bullet -compact
|
||||
.It
|
||||
Analog Device AD1981HD
|
||||
.It
|
||||
Analog Device AD1983
|
||||
.It
|
||||
Analog Device AD1986A
|
||||
.It
|
||||
Analog Device AD1988
|
||||
.It
|
||||
CMedia CMI9880
|
||||
.It
|
||||
Conexant Venice
|
||||
.It
|
||||
Conexant Waikiki
|
||||
.It
|
||||
Realtek ALC260
|
||||
.It
|
||||
Realtek ALC262
|
||||
.It
|
||||
Realtek ALC861
|
||||
.It
|
||||
Realtek ALC861VD
|
||||
.It
|
||||
Realtek ALC880
|
||||
.It
|
||||
Realtek ALC882
|
||||
.It
|
||||
Realtek ALC883
|
||||
.It
|
||||
Realtek ALC885
|
||||
.It
|
||||
Realtek ALC888
|
||||
.It
|
||||
Sigmatel STAC9220
|
||||
.It
|
||||
Sigmatel STAC9220D/9223D
|
||||
.It
|
||||
Sigmatel STAC9221
|
||||
.It
|
||||
Sigmatel STAC9221D
|
||||
.It
|
||||
Sigmatel STAC9227
|
||||
.It
|
||||
Sigmatel STAC9271D
|
||||
.It
|
||||
VIA VT1708
|
||||
.It
|
||||
VIA VT1709
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr sound 4 ,
|
||||
.Xr device.hints 5 ,
|
||||
.Xr loader.conf 5 ,
|
||||
.Xr sysctl 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Fx 7.0 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
driver was written by
|
||||
.An Stephane E. Potvin Aq sepotvin@videotron.ca
|
||||
and
|
||||
.An Ariff Abdullah Aq ariff@FreeBSD.org .
|
||||
This manual page was written by
|
||||
.An Joel Dahl Aq joel@FreeBSD.org .
|
||||
.Sh BUGS
|
||||
There are a couple of missing features, such as support for Digital
|
||||
S/PDIF and multichannel output.
|
||||
.Pp
|
||||
A few Hardware/OEM vendors tend to screw up BIOS settings, thus
|
||||
rendering the
|
||||
.Nm
|
||||
driver useless, which usually results in a state where the
|
||||
.Nm
|
||||
driver seems to attach and work, but without any sound.
|
58
sys/crypto/camellia/camellia-api.c
Normal file
58
sys/crypto/camellia/camellia-api.c
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2006
|
||||
* NTT (Nippon Telegraph and Telephone Corporation) . 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 as
|
||||
* the first lines of this file unmodified.
|
||||
* 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 NTT ``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 NTT 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef _KERNEL
|
||||
#include <sys/systm.h>
|
||||
#endif
|
||||
#include <crypto/camellia/camellia.h>
|
||||
|
||||
void
|
||||
camellia_set_key(camellia_ctx *ctx, const u_char *key, int bits)
|
||||
{
|
||||
|
||||
Camellia_Ekeygen(bits, key, ctx->subkey);
|
||||
ctx->bits = bits;
|
||||
}
|
||||
|
||||
void
|
||||
camellia_decrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst)
|
||||
{
|
||||
|
||||
Camellia_DecryptBlock(ctx->bits, src, ctx->subkey, dst);
|
||||
}
|
||||
|
||||
void
|
||||
camellia_encrypt(const camellia_ctx *ctx, const u_char *src, u_char *dst)
|
||||
{
|
||||
|
||||
Camellia_EncryptBlock(ctx->bits, src, ctx->subkey, dst);
|
||||
}
|
1332
sys/crypto/camellia/camellia.c
Normal file
1332
sys/crypto/camellia/camellia.c
Normal file
File diff suppressed because it is too large
Load Diff
69
sys/crypto/camellia/camellia.h
Normal file
69
sys/crypto/camellia/camellia.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* camellia.h ver 1.1.0
|
||||
*
|
||||
* Copyright (c) 2006
|
||||
* NTT (Nippon Telegraph and Telephone Corporation) . 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 as
|
||||
* the first lines of this file unmodified.
|
||||
* 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 NTT ``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 NTT 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _CAMELLIA_H
|
||||
#define _CAMELLIA_H
|
||||
|
||||
#define CAMELLIA_BLOCK_SIZE 16
|
||||
#define CAMELLIA_SUBKEYWORD 68 /* (34*8/4) */
|
||||
|
||||
typedef struct {
|
||||
int bits; /* key-length */
|
||||
uint32_t subkey[CAMELLIA_SUBKEYWORD]; /* encrypt/decrypt key schedule */
|
||||
} camellia_ctx;
|
||||
|
||||
void camellia_set_key(camellia_ctx *, const u_char *, int);
|
||||
void camellia_decrypt(const camellia_ctx *, const u_char *, u_char *);
|
||||
void camellia_encrypt(const camellia_ctx *, const u_char *, u_char *);
|
||||
|
||||
|
||||
void Camellia_Ekeygen(const int keyBitLength,
|
||||
const unsigned char *rawKey,
|
||||
uint32_t *subkey);
|
||||
|
||||
void Camellia_EncryptBlock(const int keyBitLength,
|
||||
const unsigned char *plaintext,
|
||||
const uint32_t *subkey,
|
||||
unsigned char *cipherText);
|
||||
|
||||
void Camellia_DecryptBlock(const int keyBitLength,
|
||||
const unsigned char *cipherText,
|
||||
const uint32_t *subkey,
|
||||
unsigned char *plaintext);
|
||||
|
||||
void camellia_setup128(const unsigned char *key, uint32_t *subkey);
|
||||
void camellia_setup192(const unsigned char *key, uint32_t *subkey);
|
||||
void camellia_setup256(const unsigned char *key, uint32_t *subkey);
|
||||
void camellia_encrypt128(const uint32_t *subkey, uint32_t *io);
|
||||
void camellia_encrypt256(const uint32_t *subkey, uint32_t *io);
|
||||
void camellia_decrypt128(const uint32_t *subkey, uint32_t *io);
|
||||
void camellia_decrypt256(const uint32_t *subkey, uint32_t *io);
|
||||
|
||||
|
||||
#endif /* _CAMELLIA_H */
|
2531
sys/dev/sound/pci/envy24.c
Normal file
2531
sys/dev/sound/pci/envy24.c
Normal file
File diff suppressed because it is too large
Load Diff
2541
sys/dev/sound/pci/envy24ht.c
Normal file
2541
sys/dev/sound/pci/envy24ht.c
Normal file
File diff suppressed because it is too large
Load Diff
6242
sys/dev/sound/pci/hda/hdac.c
Normal file
6242
sys/dev/sound/pci/hda/hdac.c
Normal file
File diff suppressed because it is too large
Load Diff
349
sys/dev/sound/pci/hda/hdac_private.h
Normal file
349
sys/dev/sound/pci/hda/hdac_private.h
Normal file
@ -0,0 +1,349 @@
|
||||
/*-
|
||||
* Copyright (c) 2006 Stephane E. Potvin <sepotvin@videotron.ca>
|
||||
* 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 THE AUTHOR 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 THE AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _HDAC_PRIVATE_H_
|
||||
#define _HDAC_PRIVATE_H_
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Miscellaneous defines
|
||||
****************************************************************************/
|
||||
#define HDAC_DMA_ALIGNMENT 128
|
||||
#define HDAC_CODEC_MAX 16
|
||||
|
||||
#define HDAC_MTX_NAME "hdac driver mutex"
|
||||
|
||||
/****************************************************************************
|
||||
* Helper Macros
|
||||
****************************************************************************/
|
||||
#define HDAC_READ_1(mem, offset) \
|
||||
bus_space_read_1((mem)->mem_tag, (mem)->mem_handle, (offset))
|
||||
#define HDAC_READ_2(mem, offset) \
|
||||
bus_space_read_2((mem)->mem_tag, (mem)->mem_handle, (offset))
|
||||
#define HDAC_READ_4(mem, offset) \
|
||||
bus_space_read_4((mem)->mem_tag, (mem)->mem_handle, (offset))
|
||||
#define HDAC_WRITE_1(mem, offset, value) \
|
||||
bus_space_write_1((mem)->mem_tag, (mem)->mem_handle, (offset), (value))
|
||||
#define HDAC_WRITE_2(mem, offset, value) \
|
||||
bus_space_write_2((mem)->mem_tag, (mem)->mem_handle, (offset), (value))
|
||||
#define HDAC_WRITE_4(mem, offset, value) \
|
||||
bus_space_write_4((mem)->mem_tag, (mem)->mem_handle, (offset), (value))
|
||||
|
||||
#define HDAC_ISDCTL(sc, n) (_HDAC_ISDCTL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_ISDSTS(sc, n) (_HDAC_ISDSTS((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_ISDPICB(sc, n) (_HDAC_ISDPICB((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_ISDCBL(sc, n) (_HDAC_ISDCBL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_ISDLVI(sc, n) (_HDAC_ISDLVI((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_ISDFIFOD(sc, n) (_HDAC_ISDFIFOD((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_ISDFMT(sc, n) (_HDAC_ISDFMT((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_ISDBDPL(sc, n) (_HDAC_ISDBDPL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_ISDBDPU(sc, n) (_HDAC_ISDBDPU((n), (sc)->num_iss, (sc)->num_oss))
|
||||
|
||||
#define HDAC_OSDCTL(sc, n) (_HDAC_OSDCTL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_OSDSTS(sc, n) (_HDAC_OSDSTS((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_OSDPICB(sc, n) (_HDAC_OSDPICB((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_OSDCBL(sc, n) (_HDAC_OSDCBL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_OSDLVI(sc, n) (_HDAC_OSDLVI((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_OSDFIFOD(sc, n) (_HDAC_OSDFIFOD((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_OSDBDPL(sc, n) (_HDAC_OSDBDPL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_OSDBDPU(sc, n) (_HDAC_OSDBDPU((n), (sc)->num_iss, (sc)->num_oss))
|
||||
|
||||
#define HDAC_BSDCTL(sc, n) (_HDAC_BSDCTL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_BSDSTS(sc, n) (_HDAC_BSDSTS((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_BSDPICB(sc, n) (_HDAC_BSDPICB((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_BSDCBL(sc, n) (_HDAC_BSDCBL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_BSDLVI(sc, n) (_HDAC_BSDLVI((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_BSDFIFOD(sc, n) (_HDAC_BSDFIFOD((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_BSDBDPL(sc, n) (_HDAC_BSDBDPL((n), (sc)->num_iss, (sc)->num_oss))
|
||||
#define HDAC_BSDBDPU(sc, n) (_HDAC_BSDBDPU((n), (sc)->num_iss, (sc)->num_oss))
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Custom hdac malloc type
|
||||
****************************************************************************/
|
||||
MALLOC_DECLARE(M_HDAC);
|
||||
|
||||
/****************************************************************************
|
||||
* struct hdac_mem
|
||||
*
|
||||
* Holds the resources necessary to describe the physical memory associated
|
||||
* with the device.
|
||||
****************************************************************************/
|
||||
struct hdac_mem {
|
||||
struct resource *mem_res;
|
||||
int mem_rid;
|
||||
bus_space_tag_t mem_tag;
|
||||
bus_space_handle_t mem_handle;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* struct hdac_irq
|
||||
*
|
||||
* Holds the resources necessary to describe the irq associated with the
|
||||
* device.
|
||||
****************************************************************************/
|
||||
struct hdac_irq {
|
||||
struct resource *irq_res;
|
||||
int irq_rid;
|
||||
void *irq_handle;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* struct hdac_dma
|
||||
*
|
||||
* This structure is used to hold all the information to manage the dma
|
||||
* states.
|
||||
****************************************************************************/
|
||||
struct hdac_dma {
|
||||
bus_dma_tag_t dma_tag;
|
||||
bus_dmamap_t dma_map;
|
||||
bus_addr_t dma_paddr;
|
||||
bus_size_t dma_size;
|
||||
caddr_t dma_vaddr;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* struct hdac_rirb
|
||||
*
|
||||
* Hold a response from a verb sent to a codec received via the rirb.
|
||||
****************************************************************************/
|
||||
struct hdac_rirb {
|
||||
uint32_t response;
|
||||
uint32_t response_ex;
|
||||
};
|
||||
|
||||
#define HDAC_RIRB_RESPONSE_EX_SDATA_IN_MASK 0x0000000f
|
||||
#define HDAC_RIRB_RESPONSE_EX_SDATA_IN_OFFSET 0
|
||||
#define HDAC_RIRB_RESPONSE_EX_UNSOLICITED 0x00000010
|
||||
|
||||
#define HDAC_RIRB_RESPONSE_EX_SDATA_IN(response_ex) \
|
||||
(((response_ex) & HDAC_RIRB_RESPONSE_EX_SDATA_IN_MASK) >> \
|
||||
HDAC_RIRB_RESPONSE_EX_SDATA_IN_OFFSET)
|
||||
|
||||
/****************************************************************************
|
||||
* struct hdac_command_list
|
||||
*
|
||||
* This structure holds the list of verbs that are to be sent to the codec
|
||||
* via the corb and the responses received via the rirb. It's allocated by
|
||||
* the codec driver and is owned by it.
|
||||
****************************************************************************/
|
||||
struct hdac_command_list {
|
||||
int num_commands;
|
||||
uint32_t *verbs;
|
||||
uint32_t *responses;
|
||||
};
|
||||
|
||||
typedef int nid_t;
|
||||
|
||||
struct hdac_softc;
|
||||
/****************************************************************************
|
||||
* struct hdac_codec
|
||||
*
|
||||
****************************************************************************/
|
||||
struct hdac_codec {
|
||||
int verbs_sent;
|
||||
int responses_received;
|
||||
nid_t cad;
|
||||
struct hdac_command_list *commands;
|
||||
struct hdac_softc *sc;
|
||||
};
|
||||
|
||||
struct hdac_bdle {
|
||||
volatile uint32_t addrl;
|
||||
volatile uint32_t addrh;
|
||||
volatile uint32_t len;
|
||||
volatile uint32_t ioc;
|
||||
} __packed;
|
||||
|
||||
#define HDA_MAX_CONNS 32
|
||||
#define HDA_MAX_NAMELEN 32
|
||||
|
||||
struct hdac_devinfo;
|
||||
|
||||
struct hdac_widget {
|
||||
nid_t nid;
|
||||
int type;
|
||||
int enable;
|
||||
int nconns, selconn;
|
||||
uint32_t pflags, ctlflags;
|
||||
nid_t conns[HDA_MAX_CONNS];
|
||||
char name[HDA_MAX_NAMELEN];
|
||||
struct hdac_devinfo *devinfo;
|
||||
struct {
|
||||
uint32_t widget_cap;
|
||||
uint32_t outamp_cap;
|
||||
uint32_t inamp_cap;
|
||||
uint32_t supp_stream_formats;
|
||||
uint32_t supp_pcm_size_rate;
|
||||
uint32_t eapdbtl;
|
||||
int outpath;
|
||||
} param;
|
||||
union {
|
||||
struct {
|
||||
uint32_t config;
|
||||
uint32_t cap;
|
||||
uint32_t ctrl;
|
||||
} pin;
|
||||
} wclass;
|
||||
};
|
||||
|
||||
struct hdac_audio_ctl {
|
||||
struct hdac_widget *widget, *childwidget;
|
||||
int enable;
|
||||
int index;
|
||||
int mute, step, size, offset;
|
||||
int left, right;
|
||||
uint32_t muted;
|
||||
int ossdev;
|
||||
uint32_t dir, ossmask, ossval;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* struct hdac_devinfo
|
||||
*
|
||||
* Holds all the parameters of a given codec function group. This is stored
|
||||
* in the ivar of each child of the hdac bus
|
||||
****************************************************************************/
|
||||
struct hdac_devinfo {
|
||||
device_t dev;
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint8_t revision_id;
|
||||
uint8_t stepping_id;
|
||||
uint8_t node_type;
|
||||
nid_t nid;
|
||||
nid_t startnode, endnode;
|
||||
int nodecnt;
|
||||
struct hdac_codec *codec;
|
||||
struct hdac_widget *widget;
|
||||
union {
|
||||
struct {
|
||||
uint32_t outamp_cap;
|
||||
uint32_t inamp_cap;
|
||||
uint32_t supp_stream_formats;
|
||||
uint32_t supp_pcm_size_rate;
|
||||
int ctlcnt, pcnt, rcnt;
|
||||
struct hdac_audio_ctl *ctl;
|
||||
uint32_t mvol;
|
||||
uint32_t quirks;
|
||||
uint32_t gpio;
|
||||
int ossidx;
|
||||
int playcnt, reccnt;
|
||||
int parsing_strategy;
|
||||
} audio;
|
||||
/* XXX undefined: modem, hdmi. */
|
||||
} function;
|
||||
};
|
||||
|
||||
struct hdac_chan {
|
||||
struct snd_dbuf *b;
|
||||
struct pcm_channel *c;
|
||||
struct pcmchan_caps caps;
|
||||
struct hdac_devinfo *devinfo;
|
||||
struct hdac_dma bdl_dma;
|
||||
uint32_t spd, fmt, fmtlist[8], pcmrates[16];
|
||||
uint32_t supp_stream_formats, supp_pcm_size_rate;
|
||||
uint32_t ptr, prevptr, blkcnt, blksz;
|
||||
uint32_t *dmapos;
|
||||
int active;
|
||||
int dir;
|
||||
int off;
|
||||
int sid;
|
||||
int bit16, bit32;
|
||||
nid_t io[16];
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* struct hdac_softc
|
||||
*
|
||||
* This structure holds the current state of the hdac driver.
|
||||
****************************************************************************/
|
||||
struct hdac_softc {
|
||||
device_t dev;
|
||||
device_t hdabus;
|
||||
struct mtx *lock;
|
||||
|
||||
struct intr_config_hook intrhook;
|
||||
|
||||
struct hdac_mem mem;
|
||||
struct hdac_irq irq;
|
||||
uint32_t pci_subvendor;
|
||||
|
||||
int nocache;
|
||||
|
||||
int num_iss;
|
||||
int num_oss;
|
||||
int num_bss;
|
||||
int support_64bit;
|
||||
int streamcnt;
|
||||
|
||||
int corb_size;
|
||||
struct hdac_dma corb_dma;
|
||||
int corb_wp;
|
||||
|
||||
int rirb_size;
|
||||
struct hdac_dma rirb_dma;
|
||||
int rirb_rp;
|
||||
|
||||
struct hdac_dma pos_dma;
|
||||
|
||||
struct hdac_chan play, rec;
|
||||
bus_dma_tag_t chan_dmat;
|
||||
int chan_size;
|
||||
int chan_blkcnt;
|
||||
|
||||
/*
|
||||
* Polling
|
||||
*/
|
||||
int polling;
|
||||
int poll_ticks;
|
||||
int poll_ival;
|
||||
struct callout poll_hda;
|
||||
struct callout poll_hdac;
|
||||
struct callout poll_jack;
|
||||
|
||||
#define HDAC_UNSOLQ_MAX 64
|
||||
#define HDAC_UNSOLQ_READY 0
|
||||
#define HDAC_UNSOLQ_BUSY 1
|
||||
int unsolq_rp;
|
||||
int unsolq_wp;
|
||||
int unsolq_st;
|
||||
uint32_t unsolq[HDAC_UNSOLQ_MAX];
|
||||
|
||||
struct hdac_codec *codecs[HDAC_CODEC_MAX];
|
||||
|
||||
int registered;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* struct hdac_command flags
|
||||
****************************************************************************/
|
||||
#define HDAC_COMMAND_FLAG_WAITOK 0x0000
|
||||
#define HDAC_COMMAND_FLAG_NOWAIT 0x0001
|
||||
|
||||
#endif
|
19
sys/modules/if_lagg/Makefile
Normal file
19
sys/modules/if_lagg/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.PATH: ${.CURDIR}/../../net
|
||||
KMOD= if_lagg
|
||||
SRCS= if_lagg.c ieee8023ad_lacp.c opt_inet.h opt_inet6.h
|
||||
|
||||
.if !defined(KERNBUILDDIR)
|
||||
opt_inet.h:
|
||||
echo "#define INET 1" > ${.TARGET}
|
||||
|
||||
.if ${MK_INET6_SUPPORT} != "no"
|
||||
opt_inet6.h:
|
||||
echo "#define INET6 1" > ${.TARGET}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.include <bsd.kmod.mk>
|
10
tools/regression/netinet6/inet6_rth/Makefile
Normal file
10
tools/regression/netinet6/inet6_rth/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# $FreeBSD$
|
||||
#
|
||||
PROG= inet6_rth-segments
|
||||
SRCS= test_subr.c inet6_rth-segments.c
|
||||
NO_MAN=
|
||||
|
||||
CFLAGS+= -Wall
|
||||
DEBUG_FLAGS= -g
|
||||
|
||||
.include <bsd.prog.mk>
|
336
tools/regression/netinet6/inet6_rth/inet6_rth-segments.c
Normal file
336
tools/regression/netinet6/inet6_rth/inet6_rth-segments.c
Normal file
@ -0,0 +1,336 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Michael Telahun Makonnen
|
||||
* 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 THE AUTHOR 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 THE AUTHOR 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip6.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test_subr.h"
|
||||
|
||||
static void init_hdrs(struct msghdr *, struct cmsghdr *, char *, size_t);
|
||||
static void test_cmsg_firsthdr();
|
||||
static void test_cmsg_nexthdr();
|
||||
static void test_rth_space();
|
||||
static void test_rth_segments();
|
||||
static void test_rth_add();
|
||||
static void test_rth_init();
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
/*
|
||||
* Initialize global variables.
|
||||
*/
|
||||
g_total = 0;
|
||||
g_pass = 0;
|
||||
g_fail = 0;
|
||||
memset(g_funcname, 0, sizeof(g_funcname));
|
||||
|
||||
/*
|
||||
* Start the tests.
|
||||
*/
|
||||
printf("Starting inet6_rth_* and cmsg macro regression tests...\n");
|
||||
|
||||
test_cmsg_firsthdr(); /* CMSG_FIRSTHDR */
|
||||
test_cmsg_nexthdr(); /* CMSG_NEXTHDR */
|
||||
test_rth_space(); /* inet6_rth_space */
|
||||
test_rth_segments(); /* inet6_rth_segments */
|
||||
test_rth_add(); /* inet6_rth_add */
|
||||
test_rth_init(); /* inet6_rth_space */
|
||||
|
||||
if (g_fail == 0)
|
||||
printf("OK. ");
|
||||
else
|
||||
printf("NOT OK. ");
|
||||
printf("Total: %d Pass: %d Fail: %d\n", g_total, g_pass, g_fail);
|
||||
|
||||
return (g_fail);
|
||||
}
|
||||
|
||||
void
|
||||
test_rth_init()
|
||||
{
|
||||
char buf[10240];
|
||||
char *pbuf;
|
||||
|
||||
set_funcname("test_rth_init", sizeof("test_rth_init\0"));
|
||||
|
||||
pbuf = inet6_rth_init((void *)buf, 10, IPV6_RTHDR_TYPE_0, 100);
|
||||
checkptr(NULL, pbuf, "buffer too small\0");
|
||||
|
||||
pbuf = inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 0);
|
||||
checkptr((caddr_t)&buf, pbuf, "0 segments\0");
|
||||
|
||||
pbuf = inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 127);
|
||||
checkptr((caddr_t)&buf, pbuf, "127 segments\0");
|
||||
|
||||
pbuf = inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, -1);
|
||||
checkptr(NULL, pbuf, "negative number of segments\0");
|
||||
|
||||
pbuf = inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 128);
|
||||
checkptr(NULL, pbuf, "128 segments\0");
|
||||
}
|
||||
|
||||
void
|
||||
test_rth_add()
|
||||
{
|
||||
int i, ret;
|
||||
char buf[10240];
|
||||
struct addrinfo *res;
|
||||
struct addrinfo hints;
|
||||
|
||||
set_funcname("test_rth_add", sizeof("test_rth_add\0"));
|
||||
|
||||
if (NULL == inet6_rth_init(buf, 10240, IPV6_RTHDR_TYPE_0, 127))
|
||||
abort();
|
||||
memset((void *)&hints, 0, sizeof(struct addrinfo));
|
||||
hints.ai_family = AF_INET6;
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
if (0 != getaddrinfo("::1", NULL, (const struct addrinfo *)&hints, &res))
|
||||
abort();
|
||||
for (i = 0; i < 127; i++)
|
||||
inet6_rth_add((void *)buf,
|
||||
&((struct sockaddr_in6 *)(res->ai_addr))->sin6_addr);
|
||||
checknum(127, ((struct ip6_rthdr0 *)buf)->ip6r0_segleft, 0,
|
||||
"add 127 segments\0");
|
||||
|
||||
ret = inet6_rth_add((void *)buf,
|
||||
&((struct sockaddr_in6 *)(res->ai_addr))->sin6_addr);
|
||||
checknum(-1, ret, 0, "add 128th segment to 127 segment header\0");
|
||||
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
|
||||
void
|
||||
test_rth_segments()
|
||||
{
|
||||
int seg;
|
||||
char buf[10240];
|
||||
|
||||
set_funcname("test_rth_segments", sizeof("test_rth_segments\0"));
|
||||
|
||||
/*
|
||||
* Test: invalid routing header type.
|
||||
*/
|
||||
if (NULL == inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 0))
|
||||
abort();
|
||||
((struct ip6_rthdr *)buf)->ip6r_type = ~IPV6_RTHDR_TYPE_0;
|
||||
seg = inet6_rth_segments((const void *)buf);
|
||||
checknum(-1, seg, 0, "invalid routing header type\0");
|
||||
|
||||
/*
|
||||
* Test: 0 segments.
|
||||
*/
|
||||
if (NULL == inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 0))
|
||||
abort();
|
||||
seg = inet6_rth_segments((const void *)buf);
|
||||
checknum(0, seg, 0, "0 segments\0");
|
||||
|
||||
/*
|
||||
* Test: 127 segments.
|
||||
*/
|
||||
if (NULL == inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 127))
|
||||
abort();
|
||||
seg = inet6_rth_segments((const void *)buf);
|
||||
checknum(127, seg, 0, "127 segments\0");
|
||||
|
||||
/*
|
||||
* Test: -1 segments.
|
||||
*/
|
||||
/*
|
||||
if (NULL == inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 0))
|
||||
abort();
|
||||
((struct ip6_rthdr0 *)buf)->ip6r0_len = -1 * 2;
|
||||
seg = inet6_rth_segments((const void *)buf);
|
||||
checknum(-1, seg, 0, "-1 segments\0");
|
||||
*/
|
||||
/*
|
||||
* Test: 128 segments.
|
||||
*/
|
||||
/*
|
||||
if (NULL == inet6_rth_init((void *)buf, 10240, IPV6_RTHDR_TYPE_0, 127))
|
||||
abort();
|
||||
((struct ip6_rthdr0 *)buf)->ip6r0_len = 128 * 2;
|
||||
seg = inet6_rth_segments((const void *)buf);
|
||||
checknum(-1, seg, 0, "128 segments\0");
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
test_rth_space()
|
||||
{
|
||||
socklen_t len;
|
||||
|
||||
set_funcname("test_rth_space", sizeof("test_rth_space\0"));
|
||||
|
||||
/*
|
||||
* Test: invalid routing header type.
|
||||
*/
|
||||
len = inet6_rth_space(~IPV6_RTHDR_TYPE_0, 0);
|
||||
checknum(0, len, 0, "invalid routing header type\0");
|
||||
|
||||
/*
|
||||
* Test: valid number of segments.
|
||||
*/
|
||||
len = inet6_rth_space(IPV6_RTHDR_TYPE_0, 0);
|
||||
checknum(0, len, 1, "0 segments\0");
|
||||
len = inet6_rth_space(IPV6_RTHDR_TYPE_0, 127);
|
||||
checknum(0, len, 1, "0 segments\0");
|
||||
|
||||
/*
|
||||
* Test: invalid number of segments.
|
||||
*/
|
||||
len = inet6_rth_space(IPV6_RTHDR_TYPE_0, -1);
|
||||
checknum(0, len, 0, "-1 segments\0");
|
||||
len = inet6_rth_space(IPV6_RTHDR_TYPE_0, 128);
|
||||
checknum(0, len, 0, "128 segments\0");
|
||||
}
|
||||
|
||||
void
|
||||
test_cmsg_nexthdr()
|
||||
{
|
||||
struct msghdr mh;
|
||||
struct cmsghdr cmh;
|
||||
struct cmsghdr *cmhp, *cmhnextp;
|
||||
char ancbuf[10240];
|
||||
char magic[] = "MAGIC";
|
||||
|
||||
set_funcname("test_cmsg_nexthdr", sizeof("test_cmsg_nexthdr"));
|
||||
|
||||
/*
|
||||
* Test: More than one cmsghdr
|
||||
*/
|
||||
init_hdrs(&mh, &cmh, ancbuf, sizeof(ancbuf));
|
||||
mh.msg_control = (caddr_t)ancbuf;
|
||||
mh.msg_controllen = CMSG_SPACE(0) * 2; /* 2 cmsghdr with no data */
|
||||
cmh.cmsg_len = CMSG_LEN(0);
|
||||
|
||||
/*
|
||||
* Copy the same instance of cmsghdr twice. Use a magic value
|
||||
* to id the second copy.
|
||||
*/
|
||||
bcopy((void *)&cmh, (void *)ancbuf, sizeof(cmh));
|
||||
strlcpy((char *)&cmh, (const char *)&magic, sizeof(magic));
|
||||
bcopy((void *)&cmh,
|
||||
(void *)((caddr_t)ancbuf + CMSG_SPACE(0)),
|
||||
sizeof(cmh));
|
||||
cmhp = CMSG_FIRSTHDR(&mh);
|
||||
cmhnextp = CMSG_NXTHDR(&mh, cmhp);
|
||||
checkstr((const char *)&magic, (const char *)cmhnextp, sizeof(magic),
|
||||
"more than one cmsghdr\0");
|
||||
|
||||
/*
|
||||
* Test: only one cmsghdr
|
||||
*/
|
||||
init_hdrs(&mh, &cmh, ancbuf, sizeof(ancbuf));
|
||||
mh.msg_control = (caddr_t)ancbuf;
|
||||
mh.msg_controllen = CMSG_SPACE(0);
|
||||
cmh.cmsg_len = CMSG_LEN(0);
|
||||
bcopy((void *)&cmh, (void *)ancbuf, sizeof(cmh));
|
||||
cmhp = CMSG_FIRSTHDR(&mh);
|
||||
cmhnextp = CMSG_NXTHDR(&mh, cmhp);
|
||||
checkptr(NULL, (caddr_t)cmhnextp, "only one cmsghdr\0");
|
||||
|
||||
/*
|
||||
* Test: NULL cmsg pointer
|
||||
*/
|
||||
init_hdrs(&mh, &cmh, ancbuf, sizeof(ancbuf));
|
||||
mh.msg_control = (caddr_t)ancbuf;
|
||||
mh.msg_controllen = sizeof(ancbuf);
|
||||
cmh.cmsg_len = sizeof(ancbuf);
|
||||
bcopy((void *)&cmh, (void *)ancbuf, sizeof(cmh));
|
||||
cmhp = CMSG_FIRSTHDR(&mh);
|
||||
cmhnextp = CMSG_NXTHDR(&mh, NULL);
|
||||
checkptr((caddr_t)cmhp, (caddr_t)cmhnextp, "null second argument\0");
|
||||
}
|
||||
|
||||
void
|
||||
test_cmsg_firsthdr()
|
||||
{
|
||||
struct msghdr mh;
|
||||
struct cmsghdr cmh;
|
||||
struct cmsghdr *cmhp;
|
||||
char ancbuf[1024];
|
||||
char magic[] = "MAGIC";
|
||||
|
||||
set_funcname("test_cmsg_firsthdr", sizeof("test_cmsg_firsthdr"));
|
||||
|
||||
/* CMSG_FIRSTHDR() where msg_control is NULL */
|
||||
init_hdrs(&mh, NULL, NULL, 0);
|
||||
mh.msg_control = NULL;
|
||||
cmhp = CMSG_FIRSTHDR(&mh);
|
||||
checkptr(NULL, (caddr_t)cmhp,
|
||||
"msg_control is NULL\0");
|
||||
|
||||
/* - where msg_controllen < sizeof cmsghdr */
|
||||
init_hdrs(&mh, NULL, NULL, 0);
|
||||
mh.msg_control = (caddr_t)&cmh;
|
||||
mh.msg_controllen = sizeof(cmh) - 1;
|
||||
cmhp = CMSG_FIRSTHDR(&mh);
|
||||
checkptr(NULL, (caddr_t)cmhp,
|
||||
"msg_controllen < sizeof cmsghdr\0");
|
||||
|
||||
/* - where msg_controllen == 0 */
|
||||
init_hdrs(&mh, NULL, NULL, 0);
|
||||
mh.msg_control = (caddr_t)&cmh;
|
||||
mh.msg_controllen = 0;
|
||||
cmhp = CMSG_FIRSTHDR(&mh);
|
||||
checkptr(NULL, (caddr_t)cmhp,
|
||||
"msg_controllen == 0\0");
|
||||
|
||||
/* no errors */
|
||||
init_hdrs(&mh, &cmh, ancbuf, sizeof(ancbuf));
|
||||
memset((void *)ancbuf, 0, sizeof(ancbuf));
|
||||
mh.msg_control = (caddr_t)ancbuf;
|
||||
mh.msg_controllen = sizeof(ancbuf);
|
||||
strlcpy((char *)&cmh, (const char *)&magic, sizeof(magic));
|
||||
bcopy((void *)&cmh, (void *)ancbuf, sizeof(cmh));
|
||||
cmhp = CMSG_FIRSTHDR(&mh);
|
||||
checkstr((const char *)&magic, (const char *)cmhp, sizeof(magic),
|
||||
"with payload\0");
|
||||
}
|
||||
|
||||
void
|
||||
init_hdrs(struct msghdr *mhp, struct cmsghdr *cmhp, char *bufp, size_t bufsize)
|
||||
{
|
||||
if (mhp != NULL)
|
||||
memset((void *)mhp, 0, sizeof(struct msghdr));
|
||||
if (cmhp != NULL)
|
||||
memset((void *)cmhp, 0, sizeof(struct cmsghdr));
|
||||
if (bufp != NULL)
|
||||
memset((void *)bufp, 0, bufsize);
|
||||
}
|
166
tools/regression/netinet6/inet6_rth/test_subr.c
Normal file
166
tools/regression/netinet6/inet6_rth/test_subr.c
Normal file
@ -0,0 +1,166 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Michael Telahun Makonnen
|
||||
* 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 THE AUTHOR 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 THE AUTHOR 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test_subr.h"
|
||||
|
||||
int g_total;
|
||||
int g_pass;
|
||||
int g_fail;
|
||||
char g_funcname[FUNCNAMESIZE];
|
||||
char g_testdesc[LINESIZE];
|
||||
char g_errbuf[LINESIZE];
|
||||
|
||||
void
|
||||
set_funcname(char *bufp, size_t bufsize)
|
||||
{
|
||||
strlcpy(g_funcname, bufp,
|
||||
bufsize < FUNCNAMESIZE ? bufsize : FUNCNAMESIZE);
|
||||
}
|
||||
|
||||
/*
|
||||
* desc is a NULL-terminated string.
|
||||
*/
|
||||
void
|
||||
checkptr(caddr_t expected, caddr_t got, const char *desc)
|
||||
{
|
||||
int len;
|
||||
int failed;
|
||||
char sbuf[LINESIZE];
|
||||
|
||||
memset((void *)sbuf, 0, LINESIZE);
|
||||
snprintf(g_testdesc, LINESIZE, desc);
|
||||
|
||||
failed = 1;
|
||||
g_total++;
|
||||
if (got == expected) {
|
||||
len = snprintf(sbuf, LINESIZE, "ok");
|
||||
g_pass++;
|
||||
failed = 0;
|
||||
} else {
|
||||
len = snprintf(sbuf, LINESIZE, "not ok");
|
||||
snprintf(g_errbuf, LINESIZE, " : Expected %#x, but got %#x",
|
||||
(unsigned int)expected, (unsigned int)got);
|
||||
g_fail++;
|
||||
}
|
||||
snprintf(sbuf + len, LINESIZE - len, " %d - %s (%s)",
|
||||
g_total, g_funcname, g_testdesc);
|
||||
printf(sbuf);
|
||||
if (failed)
|
||||
printf(g_errbuf);
|
||||
printf("\n");
|
||||
fflush(NULL);
|
||||
memset((void *)g_errbuf, 0, LINESIZE);
|
||||
memset((void *)g_testdesc, 0, LINESIZE);
|
||||
}
|
||||
|
||||
void
|
||||
checkstr(const char *expected, const char *got, size_t explen, const char *desc)
|
||||
{
|
||||
int len;
|
||||
int failed;
|
||||
char sbuf[LINESIZE];
|
||||
|
||||
memset((void *)sbuf, 0, LINESIZE);
|
||||
snprintf(g_testdesc, LINESIZE, desc);
|
||||
|
||||
failed = 1;
|
||||
g_total++;
|
||||
if (strncmp(expected, got, explen) == 0) {
|
||||
len = snprintf(sbuf, LINESIZE, "ok");
|
||||
g_pass++;
|
||||
failed = 0;
|
||||
} else {
|
||||
len = snprintf(sbuf, LINESIZE, "not ok");
|
||||
snprintf(g_errbuf, LINESIZE,
|
||||
" : Expected %s, but got %s", expected, got);
|
||||
g_fail++;
|
||||
}
|
||||
snprintf(sbuf + len, LINESIZE - len, " %d - %s (%s)",
|
||||
g_total, g_funcname, g_testdesc);
|
||||
printf(sbuf);
|
||||
if (failed)
|
||||
printf(g_errbuf);
|
||||
printf("\n");
|
||||
fflush(NULL);
|
||||
memset((void *)g_errbuf, 0, LINESIZE);
|
||||
memset((void *)g_testdesc, 0, LINESIZE);
|
||||
}
|
||||
|
||||
void
|
||||
checknum(int expected, int got, int cmp, const char *desc)
|
||||
{
|
||||
int len;
|
||||
int pass;
|
||||
int failed;
|
||||
char sbuf[LINESIZE];
|
||||
|
||||
memset((void *)sbuf, 0, LINESIZE);
|
||||
snprintf(g_testdesc, LINESIZE, desc);
|
||||
|
||||
failed = 1;
|
||||
pass = 0;
|
||||
g_total++;
|
||||
switch(cmp) {
|
||||
case 0:
|
||||
pass = (got == expected) ? 1 : 0;
|
||||
break;
|
||||
case 1:
|
||||
pass = (got > expected) ? 1 : 0;
|
||||
break;
|
||||
case -1:
|
||||
pass = (got < expected) ? 1 : 0;
|
||||
break;
|
||||
}
|
||||
if (pass != 0) {
|
||||
len = snprintf(sbuf, LINESIZE, "ok");
|
||||
g_pass++;
|
||||
failed = 0;
|
||||
} else {
|
||||
len = snprintf(sbuf, LINESIZE, "not ok");
|
||||
snprintf(g_errbuf, LINESIZE,
|
||||
" : Expected %d, but got %d", expected, got);
|
||||
g_fail++;
|
||||
}
|
||||
snprintf(sbuf + len, LINESIZE - len, " %d - %s (%s)",
|
||||
g_total, g_funcname, g_testdesc);
|
||||
printf(sbuf);
|
||||
if (failed)
|
||||
printf(g_errbuf);
|
||||
printf("\n");
|
||||
fflush(NULL);
|
||||
memset((void *)g_errbuf, 0, LINESIZE);
|
||||
memset((void *)g_testdesc, 0, LINESIZE);
|
||||
}
|
44
tools/regression/netinet6/inet6_rth/test_subr.h
Normal file
44
tools/regression/netinet6/inet6_rth/test_subr.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Michael Telahun Makonnen
|
||||
* 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 THE AUTHOR 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 THE AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define LINESIZE 256
|
||||
#define FUNCNAMESIZE 32
|
||||
|
||||
extern int g_total;
|
||||
extern int g_pass;
|
||||
extern int g_fail;
|
||||
extern char g_funcname[FUNCNAMESIZE];
|
||||
extern char g_testdesc[LINESIZE];
|
||||
extern char g_errbuf[LINESIZE];
|
||||
|
||||
void set_funcname(char *, size_t);
|
||||
void checkptr(caddr_t, caddr_t, const char *);
|
||||
void checkstr(const char *, const char *, size_t, const char*);
|
||||
void checknum(int, int, int, const char *);
|
Loading…
x
Reference in New Issue
Block a user