ifconfig/wlan, expat, lib80211: Port to RTEMS.

This commit is contained in:
Christian Mauderer 2016-11-16 16:29:17 +01:00
parent 23895395ec
commit 5c3223f138
10 changed files with 195 additions and 29 deletions

View File

@ -176,6 +176,7 @@ def includes():
'-Ifreebsd/sys/contrib/pf',
'-Ifreebsd/sys/net',
'-Ifreebsd/include',
'-Ifreebsd/lib',
'-Ifreebsd/lib/libc/include',
'-Ifreebsd/lib/libc/isc/include',
'-Ifreebsd/lib/libc/resolv',
@ -183,6 +184,7 @@ def includes():
'-Ifreebsd/lib/libkvm',
'-Ifreebsd/lib/libmemstat',
'-Ifreebsd/lib/libipsec',
'-Ifreebsd/contrib/expat/lib',
'-Ifreebsd/contrib/libpcap',
'-Ifreebsd/contrib/libxo',
'-Irtemsbsd/sys',

View File

@ -28,6 +28,15 @@
static const char rcsid[] = "$FreeBSD$";
#endif /* not lint */
#ifdef __rtems__
/* We need some functions from kernel name space */
#define sbuf_bcat _bsd_sbuf_bcat
#define sbuf_finish _bsd_sbuf_finish
#define sbuf_data _bsd_sbuf_data
#define sbuf_len _bsd_sbuf_len
#define sbuf_delete _bsd_sbuf_delete
#define sbuf_new _bsd_sbuf_new
#endif /* __rtems__ */
#include <sys/types.h>
#include <rtems/bsd/sys/errno.h>
#include <rtems/bsd/sys/param.h>

View File

@ -382,6 +382,7 @@ mainwrapper(int argc, char *argv[])
gre_ctor();
group_ctor();
ifmedia_ctor();
ieee80211_ctor();
inet6_ctor();
inet_ctor();
lagg_ctor();

View File

@ -1,5 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
#ifdef __rtems__
#include "rtems-bsd-ifconfig-namespace.h"
#endif /* __rtems__ */
/*
* Copyright 2001 The Aerospace Corporation. All rights reserved.
*
@ -59,6 +63,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __rtems__
#include <machine/rtems-bsd-program.h>
#endif /* __rtems__ */
#include <rtems/bsd/sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@ -95,6 +102,9 @@
#include <lib80211/lib80211_regdomain.h>
#include <lib80211/lib80211_ioctl.h>
#ifdef __rtems__
#include "rtems-bsd-ifconfig-ifieee80211-data.h"
#endif /* __rtems__ */
#ifndef IEEE80211_FIXED_RATE_NONE
#define IEEE80211_FIXED_RATE_NONE 0xff
@ -3448,7 +3458,11 @@ printmimo(const struct ieee80211_mimo_info *mi)
static void
list_scan(int s)
{
#ifndef __rtems__
uint8_t buf[24*1024];
#else /* __rtems__ */
static uint8_t buf[24*1024];
#endif /* __rtems__ */
char ssid[IEEE80211_NWID_LEN+1];
const uint8_t *cp;
int len, ssidmax, idlen;
@ -5693,7 +5707,11 @@ static struct afswtch af_ieee80211 = {
.af_other_status = ieee80211_status,
};
#ifndef __rtems__
static __constructor void
#else /* __rtems__ */
void
#endif /* __rtems__ */
ieee80211_ctor(void)
{
int i;

View File

@ -7,11 +7,11 @@
/* ifbridge.c */
/* ifclone.c */
/* ifconfig.c */
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int setaddr);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern struct ifreq ifr);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char name[16]);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char *descr);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern size_t descrlen);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int setaddr);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int setmask);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int doalias);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int clearaddr);
@ -28,6 +28,7 @@ RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char *f_addr);
/* ifgif.c */
/* ifgre.c */
/* ifgroup.c */
/* ifieee80211.c */
/* iflagg.c */
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char lacpbuf[120]);
/* ifmac.c */

View File

@ -0,0 +1,24 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
#include "rtems-bsd-ifconfig-data.h"
/* ifieee80211.c */
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int col);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static char spacer);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static char const *modename[14]);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211req_chaninfo *chaninfo);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_regdomain regdomain);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gotregdomain);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_roamparams_req roamparams);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gotroam);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_txparams_req txparams);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gottxparams);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_channel curchan);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gotcurchan);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmediareq *ifmr);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int htconf);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gothtconf);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_clone_params params);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct cmd ieee80211_cmds[177]);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct afswtch af_ieee80211);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int vhtconf);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gotvhtconf);

View File

@ -15,11 +15,11 @@
#define clone_ctor _bsd_ifconfig_clone_ctor
#define clone_setdefcallback _bsd_ifconfig_clone_setdefcallback
/* ifconfig.c */
#define setaddr _bsd_ifconfig_setaddr
#define ifr _bsd_ifconfig_ifr
#define name _bsd_ifconfig_name
#define descr _bsd_ifconfig_descr
#define descrlen _bsd_ifconfig_descrlen
#define setaddr _bsd_ifconfig_setaddr
#define setmask _bsd_ifconfig_setmask
#define doalias _bsd_ifconfig_doalias
#define clearaddr _bsd_ifconfig_clearaddr
@ -49,6 +49,8 @@
#define gre_ctor _bsd_ifconfig_gre_ctor
/* ifgroup.c */
#define group_ctor _bsd_ifconfig_group_ctor
/* ifieee80211.c */
#define ieee80211_ctor _bsd_ifconfig_ieee80211_ctor
/* iflagg.c */
#define lacpbuf _bsd_ifconfig_lacpbuf
#define lagg_ctor _bsd_ifconfig_lagg_ctor

View File

@ -1945,6 +1945,8 @@ def user_space(mm):
'include/rpcsvc/ypclnt.h',
'include/rpcsvc/yp_prot.h',
'include/sysexits.h',
'lib/lib80211/lib80211_ioctl.h',
'lib/lib80211/lib80211_regdomain.h',
'lib/libc/db/btree/btree.h',
'lib/libc/db/btree/extern.h',
'lib/libc/db/recno/extern.h',
@ -2040,6 +2042,8 @@ def user_space(mm):
'bin/hostname/hostname.c',
'contrib/libxo/libxo/libxo.c',
'contrib/libxo/libxo/xo_encoder.c',
'lib/lib80211/lib80211_ioctl.c',
'lib/lib80211/lib80211_regdomain.c',
'lib/libc/gen/err.c',
'lib/libc/gen/feature_present.c',
'lib/libc/gen/getdomainname.c',
@ -2220,6 +2224,7 @@ def user_space(mm):
'sbin/ifconfig/ifgif.c',
'sbin/ifconfig/ifgre.c',
'sbin/ifconfig/ifgroup.c',
'sbin/ifconfig/ifieee80211.c',
'sbin/ifconfig/iflagg.c',
'sbin/ifconfig/ifmac.c',
'sbin/ifconfig/ifmedia.c',
@ -2261,6 +2266,45 @@ def user_space(mm):
)
return mod
#
# Contrib expat
#
def contrib_expat(mm):
mod = builder.Module('contrib_expat')
cflags = ['-DHAVE_MEMMOVE=1']
mod.addRTEMSHeaderFiles(
[
'include/bsdxml.h',
]
)
mod.addUserSpaceHeaderFiles(
[
'contrib/expat/lib/ascii.h',
'contrib/expat/lib/asciitab.h',
'contrib/expat/lib/expat_external.h',
'contrib/expat/lib/expat.h',
'contrib/expat/lib/iasciitab.h',
'contrib/expat/lib/internal.h',
'contrib/expat/lib/latin1tab.h',
'contrib/expat/lib/nametab.h',
'contrib/expat/lib/utf8tab.h',
'contrib/expat/lib/xmlrole.h',
'contrib/expat/lib/xmltok.h',
'contrib/expat/lib/xmltok_impl.h',
]
)
mod.addUserSpaceSourceFiles(
[
'contrib/expat/lib/xmlparse.c',
'contrib/expat/lib/xmlrole.c',
'contrib/expat/lib/xmltok.c',
'contrib/expat/lib/xmltok_impl.c',
'contrib/expat/lib/xmltok_ns.c',
],
mm.generator['source'](cflags)
)
return mod
#
# Contrib libpcap
#
@ -2830,6 +2874,7 @@ def sources(mm):
mm.addModule(in_cksum(mm))
mm.addModule(user_space(mm))
mm.addModule(contrib_expat(mm))
mm.addModule(contrib_libpcap(mm))
mm.addModule(usr_sbin_tcpdump(mm))

View File

@ -66,6 +66,7 @@ def build(bld):
includes += ["freebsd/sys/contrib/pf"]
includes += ["freebsd/sys/net"]
includes += ["freebsd/include"]
includes += ["freebsd/lib"]
includes += ["freebsd/lib/libc/include"]
includes += ["freebsd/lib/libc/isc/include"]
includes += ["freebsd/lib/libc/resolv"]
@ -73,6 +74,7 @@ def build(bld):
includes += ["freebsd/lib/libkvm"]
includes += ["freebsd/lib/libmemstat"]
includes += ["freebsd/lib/libipsec"]
includes += ["freebsd/contrib/expat/lib"]
includes += ["freebsd/contrib/libpcap"]
includes += ["freebsd/contrib/libxo"]
includes += ["rtemsbsd/sys"]
@ -230,9 +232,24 @@ def build(bld):
libbsd_use += ["yacc_pfctly"]
# Objects built with different CFLAGS
objs01_source = ['freebsd/bin/hostname/hostname.c',
objs01_source = ['freebsd/contrib/expat/lib/xmlparse.c',
'freebsd/contrib/expat/lib/xmlrole.c',
'freebsd/contrib/expat/lib/xmltok.c',
'freebsd/contrib/expat/lib/xmltok_impl.c',
'freebsd/contrib/expat/lib/xmltok_ns.c']
bld.objects(target = "objs01",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + ['HAVE_MEMMOVE=1'],
source = objs01_source)
libbsd_use += ["objs01"]
objs02_source = ['freebsd/bin/hostname/hostname.c',
'freebsd/contrib/libxo/libxo/libxo.c',
'freebsd/contrib/libxo/libxo/xo_encoder.c',
'freebsd/lib/lib80211/lib80211_ioctl.c',
'freebsd/lib/lib80211/lib80211_regdomain.c',
'freebsd/lib/libc/gen/err.c',
'freebsd/lib/libc/gen/feature_present.c',
'freebsd/lib/libc/gen/getdomainname.c',
@ -413,6 +430,7 @@ def build(bld):
'freebsd/sbin/ifconfig/ifgif.c',
'freebsd/sbin/ifconfig/ifgre.c',
'freebsd/sbin/ifconfig/ifgroup.c',
'freebsd/sbin/ifconfig/ifieee80211.c',
'freebsd/sbin/ifconfig/iflagg.c',
'freebsd/sbin/ifconfig/ifmac.c',
'freebsd/sbin/ifconfig/ifmedia.c',
@ -449,24 +467,24 @@ def build(bld):
'freebsd/usr.bin/netstat/unix.c',
'freebsd/usr.bin/vmstat/vmstat.c',
'freebsd/usr.sbin/arp/arp.c']
bld.objects(target = "objs01",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + ['INET', 'INET6'],
source = objs01_source)
libbsd_use += ["objs01"]
objs02_source = ['rtemsbsd/mghttpd/mongoose.c']
bld.objects(target = "objs02",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + ['NO_CGI', 'NO_POPEN', 'NO_SSL', 'USE_WEBSOCKET'],
defines = defines + ['INET', 'INET6'],
source = objs02_source)
libbsd_use += ["objs02"]
objs03_source = ['freebsd/lib/libc/db/btree/bt_close.c',
objs03_source = ['rtemsbsd/mghttpd/mongoose.c']
bld.objects(target = "objs03",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + ['NO_CGI', 'NO_POPEN', 'NO_SSL', 'USE_WEBSOCKET'],
source = objs03_source)
libbsd_use += ["objs03"]
objs04_source = ['freebsd/lib/libc/db/btree/bt_close.c',
'freebsd/lib/libc/db/btree/bt_conv.c',
'freebsd/lib/libc/db/btree/bt_debug.c',
'freebsd/lib/libc/db/btree/bt_delete.c',
@ -490,15 +508,15 @@ def build(bld):
'freebsd/lib/libc/db/recno/rec_search.c',
'freebsd/lib/libc/db/recno/rec_seq.c',
'freebsd/lib/libc/db/recno/rec_utils.c']
bld.objects(target = "objs03",
bld.objects(target = "objs04",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + ['INET6', '__DBINTERFACE_PRIVATE'],
source = objs03_source)
libbsd_use += ["objs03"]
source = objs04_source)
libbsd_use += ["objs04"]
objs04_source = ['dhcpcd/arp.c',
objs05_source = ['dhcpcd/arp.c',
'dhcpcd/auth.c',
'dhcpcd/bpf.c',
'dhcpcd/common.c',
@ -520,15 +538,15 @@ def build(bld):
'dhcpcd/ipv6nd.c',
'dhcpcd/net.c',
'dhcpcd/platform-bsd.c']
bld.objects(target = "objs04",
bld.objects(target = "objs05",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + ['INET', 'INET6', 'MASTER_ONLY', 'THERE_IS_NO_FORK', '__FreeBSD__'],
source = objs04_source)
libbsd_use += ["objs04"]
source = objs05_source)
libbsd_use += ["objs05"]
objs05_source = ['freebsd/contrib/libpcap/bpf_image.c',
objs06_source = ['freebsd/contrib/libpcap/bpf_image.c',
'freebsd/contrib/libpcap/etherent.c',
'freebsd/contrib/libpcap/fad-getad.c',
'freebsd/contrib/libpcap/gencode.c',
@ -541,15 +559,15 @@ def build(bld):
'freebsd/contrib/libpcap/savefile.c',
'freebsd/contrib/libpcap/sf-pcap-ng.c',
'freebsd/contrib/libpcap/sf-pcap.c']
bld.objects(target = "objs05",
bld.objects(target = "objs06",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + ['BSD=1', 'HAVE_INTTYPES=1', 'HAVE_LIMITS_H=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SYS_IOCCOM_H=1', 'HAVE_VSNPRINTF=1', 'INET6', '_U_=__attribute__((unused))', '__FreeBSD__=1'],
source = objs05_source)
libbsd_use += ["objs05"]
source = objs06_source)
libbsd_use += ["objs06"]
objs06_source = ['freebsd/contrib/tcpdump/addrtoname.c',
objs07_source = ['freebsd/contrib/tcpdump/addrtoname.c',
'freebsd/contrib/tcpdump/af.c',
'freebsd/contrib/tcpdump/bpf_dump.c',
'freebsd/contrib/tcpdump/checksum.c',
@ -692,13 +710,13 @@ def build(bld):
'freebsd/contrib/tcpdump/smbutil.c',
'freebsd/contrib/tcpdump/tcpdump.c',
'freebsd/contrib/tcpdump/util.c']
bld.objects(target = "objs06",
bld.objects(target = "objs07",
features = "c",
cflags = cflags,
includes = ['freebsd/contrib/tcpdump', 'freebsd/usr.sbin/tcpdump/tcpdump'] + includes,
defines = defines + ['HAVE_CONFIG_H=1', 'HAVE_NET_PFVAR_H=1', 'INET6', '_U_=__attribute__((unused))', '__FreeBSD__=1'],
source = objs06_source)
libbsd_use += ["objs06"]
source = objs07_source)
libbsd_use += ["objs07"]
source = ['freebsd/sys/arm/xilinx/zy7_slcr.c',
'freebsd/sys/cam/cam.c',

46
rtemsbsd/include/bsdxml.h Normal file
View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2016 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* 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.
*/
#ifndef BSDXML_H
#define BSDXML_H
/*
* Note: On FreeBSD the bsdxml.h is generated out of the expat.h using some
* source manipulations. See freebsd-org/lib/libexpat/Makefile for more details.
*/
#ifdef __VMS
#error FIXME __VMS should not be defined here.
#endif /* __VMS */
#include <expat.h>
#endif /* BSDXML_H */