4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-21 00:07:36 +08:00

newlib: drop phoenix support

This code has not been updated since 2016, and it looks like it has
rotted quite a bit since.  It does not build against the current set
of phoenix sources -- I had to hack both the kernel headers and the
newlib headers up to get it to build, and I still have no idea if it
actually links or runs.  It seems like the project itself has moved
away from newlib and to its own C library:
https://phoenix-rtos.com/documentation/libc/README.md

So since there's no interest from the phoenix folks to maintain this,
and it has a significant amount of non-standard code that we try to
keep up-to-date (without actually testing it), just punt it all.
This commit is contained in:
Mike Frysinger 2022-03-13 17:22:36 -04:00
parent 761ef3b434
commit be9c0561e7
138 changed files with 277 additions and 11798 deletions

View File

@ -1023,33 +1023,7 @@ 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.
(45) Phoenix Systems - Phoenix-RTOS targets
Copyright (c) 2016 Phoenix Systems
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.
(46) embedded brains - RTEMS targets
(45) embedded brains - RTEMS targets
Copyright (c) 2017 embedded brains GmbH
All rights reserved.
@ -1075,7 +1049,7 @@ 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.
(47) John Baldwin - RTEMS targets
(46) John Baldwin - RTEMS targets
Copyright (c) 2015 John Baldwin <jhb@FreeBSD.org>.
All rights reserved.
@ -1104,8 +1078,7 @@ 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.
(48) Jeffrey Roberson - RTEMS targets
(47) Jeffrey Roberson - RTEMS targets
Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org>
All rights reserved.
@ -1134,7 +1107,7 @@ 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.
(49) - SiFive Inc. (riscv-* targets)
(48) - SiFive Inc. (riscv-* targets)
Copyright (c) 2017 SiFive Inc. All rights reserved.
@ -1146,7 +1119,7 @@ including the implied warranties of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. A copy of this license is available at
http://www.opensource.org/licenses.
(50) Michael R. Neilly (riscv-* targets)
(49) Michael R. Neilly (riscv-* targets)
(c) Copyright 2017 Michael R. Neilly
All rights reserved.
@ -1179,7 +1152,7 @@ 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.
(51) Mentor Graphics (amdgcn-* targets)
(50) Mentor Graphics (amdgcn-* targets)
Copyright (c) 2014-2017 Mentor Graphics.
@ -1193,7 +1166,7 @@ and need not follow the licensing terms described here, provided that
the new terms are clearly indicated on the first page of each file where
they apply.
(52) BSD-2-Clause-FreeBSD (pru-* targets)
(51) BSD-2-Clause-FreeBSD (pru-* targets)
SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@ -1220,7 +1193,7 @@ 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.
(53) Andrew Turner (arm-* targets)
(52) Andrew Turner (arm-* targets)
Copyright (c) 2013 Andrew Turner <andrew@FreeBSD.ORG>
All rights reserved.
@ -1246,7 +1219,7 @@ 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.
(54) BSD-2-Clause-FreeBSD David Schultz (arm-* targets)
(53) BSD-2-Clause-FreeBSD David Schultz (arm-* targets)
SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@ -1274,7 +1247,7 @@ 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.
(55) - C-SKY Microsystems (csky-* targets)
(54) - C-SKY Microsystems (csky-* targets)
Copyright (c) 2020 C-SKY Microsystems All rights reserved.
@ -1286,7 +1259,7 @@ including the implied warranties of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. A copy of this license is available at
http://www.opensource.org/licenses.
(56) BSD-3-Clause-FreeBSD Peter Wemm (rtems targets)
(55) BSD-3-Clause-FreeBSD Peter Wemm (rtems targets)
SPDX-License-Identifier: BSD-3-Clause

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@
- remove i?86-pc-linux-gnu support
- remove decstation & sunos support
- remove phoenix OS support
- build system internals heavily rewritten & updated
*** Major changes in newlib version 4.2.0:

35
newlib/configure vendored
View File

@ -747,9 +747,6 @@ HAVE_LIBC_MACHINE_AMDGCN_FALSE
HAVE_LIBC_MACHINE_AMDGCN_TRUE
HAVE_LIBC_MACHINE_AARCH64_FALSE
HAVE_LIBC_MACHINE_AARCH64_TRUE
HAVE_LIBC_SYS_PHOENIX_ARM_DIR_FALSE
HAVE_LIBC_SYS_PHOENIX_ARM_DIR_TRUE
PHOENIX_MACHINE_DIR
HAVE_SPU_EA_FALSE
HAVE_SPU_EA_TRUE
SH64_FALSE
@ -788,8 +785,6 @@ HAVE_LIBC_SYS_RTEMS_DIR_FALSE
HAVE_LIBC_SYS_RTEMS_DIR_TRUE
HAVE_LIBC_SYS_RDOS_DIR_FALSE
HAVE_LIBC_SYS_RDOS_DIR_TRUE
HAVE_LIBC_SYS_PHOENIX_DIR_FALSE
HAVE_LIBC_SYS_PHOENIX_DIR_TRUE
HAVE_LIBC_SYS_OR1K_DIR_FALSE
HAVE_LIBC_SYS_OR1K_DIR_TRUE
HAVE_LIBC_SYS_NETWARE_DIR_FALSE
@ -5397,13 +5392,6 @@ fi
else
HAVE_LIBC_SYS_OR1K_DIR_TRUE='#'
HAVE_LIBC_SYS_OR1K_DIR_FALSE=
fi
if test "${sys_dir}" = phoenix; then
HAVE_LIBC_SYS_PHOENIX_DIR_TRUE=
HAVE_LIBC_SYS_PHOENIX_DIR_FALSE='#'
else
HAVE_LIBC_SYS_PHOENIX_DIR_TRUE='#'
HAVE_LIBC_SYS_PHOENIX_DIR_FALSE=
fi
if test "${sys_dir}" = rdos; then
HAVE_LIBC_SYS_RDOS_DIR_TRUE=
@ -5696,21 +5684,6 @@ else
fi
if test "$sys_dir" = "phoenix"; then :
PHOENIX_MACHINE_DIR=machine/${machine_dir}
fi
if test "${machine_dir}" = arm; then
HAVE_LIBC_SYS_PHOENIX_ARM_DIR_TRUE=
HAVE_LIBC_SYS_PHOENIX_ARM_DIR_FALSE='#'
else
HAVE_LIBC_SYS_PHOENIX_ARM_DIR_TRUE='#'
HAVE_LIBC_SYS_PHOENIX_ARM_DIR_FALSE=
fi
if test "${machine_dir}" = aarch64; then
HAVE_LIBC_MACHINE_AARCH64_TRUE=
@ -7537,10 +7510,6 @@ if test -z "${HAVE_LIBC_SYS_OR1K_DIR_TRUE}" && test -z "${HAVE_LIBC_SYS_OR1K_DIR
as_fn_error $? "conditional \"HAVE_LIBC_SYS_OR1K_DIR\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_LIBC_SYS_PHOENIX_DIR_TRUE}" && test -z "${HAVE_LIBC_SYS_PHOENIX_DIR_FALSE}"; then
as_fn_error $? "conditional \"HAVE_LIBC_SYS_PHOENIX_DIR\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_LIBC_SYS_RDOS_DIR_TRUE}" && test -z "${HAVE_LIBC_SYS_RDOS_DIR_FALSE}"; then
as_fn_error $? "conditional \"HAVE_LIBC_SYS_RDOS_DIR\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@ -7617,10 +7586,6 @@ if test -z "${HAVE_SPU_EA_TRUE}" && test -z "${HAVE_SPU_EA_FALSE}"; then
as_fn_error $? "conditional \"HAVE_SPU_EA\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_LIBC_SYS_PHOENIX_ARM_DIR_TRUE}" && test -z "${HAVE_LIBC_SYS_PHOENIX_ARM_DIR_FALSE}"; then
as_fn_error $? "conditional \"HAVE_LIBC_SYS_PHOENIX_ARM_DIR\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_LIBC_MACHINE_AARCH64_TRUE}" && test -z "${HAVE_LIBC_MACHINE_AARCH64_FALSE}"; then
as_fn_error $? "conditional \"HAVE_LIBC_MACHINE_AARCH64\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5

View File

@ -427,11 +427,6 @@ case "${host}" in
signal_dir=
sys_dir=netware
;;
*-*-phoenix*)
sys_dir=phoenix
posix_dir=posix
unix_dir=unix
;;
*-*-rtems*) # generic RTEMS support
sys_dir=rtems
posix_dir=posix
@ -595,11 +590,6 @@ case "${host}" in
newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DGETREENT_PROVIDED -DSIGNAL_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED"
syscall_dir=syscalls
;;
*-*-phoenix*)
newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DHAVE_BLKSIZE -DHAVE_NANOSLEEP"
default_newlib_io_long_long="yes"
syscall_dir=
;;
# RTEMS supplies its own versions of some routines:
# malloc() (reentrant version)
# exit() RTEMS has a "global" reent to flush

View File

@ -19,7 +19,6 @@ m4_foreach_w([SYS_DIR], [
m88kbug mmixware
netware
or1k
phoenix
rdos rtems
sh sysmec sysnec810 sysnecv850 sysvi386 sysvnecv70
tic80 tirtos
@ -39,7 +38,6 @@ m4_include([libc/machine/nds32/acinclude.m4])
m4_include([libc/machine/powerpc/acinclude.m4])
m4_include([libc/machine/sh/acinclude.m4])
m4_include([libc/machine/spu/acinclude.m4])
m4_include([libc/sys/phoenix/acinclude.m4])
m4_foreach_w([MACHINE], [
aarch64 amdgcn arc arm

View File

@ -31,9 +31,6 @@ endif
if HAVE_LIBC_SYS_OR1K_DIR
include %D%/or1k/Makefile.inc
endif
if HAVE_LIBC_SYS_PHOENIX_DIR
include %D%/phoenix/Makefile.inc
endif
if HAVE_LIBC_SYS_RDOS_DIR
include %D%/rdos/Makefile.inc
endif

View File

@ -1,105 +0,0 @@
libc_a_SOURCES += \
%D%/net/domainname.c \
%D%/net/freeaddrinfo.c \
%D%/net/getaddrinfo.c \
%D%/net/gethostbyaddr.c \
%D%/net/gethostbyname.c \
%D%/net/getnameinfo.c \
%D%/net/getservbyname.c \
%D%/net/getservbyport.c \
%D%/net/herror.c \
%D%/net/hostname.c \
%D%/net/inet_addr.c \
%D%/net/inet_aton.c \
%D%/net/inet_lnaof.c \
%D%/net/inet_makeaddr.c \
%D%/net/inet_net_ntop.c \
%D%/net/inet_net_pton.c \
%D%/net/inet_netof.c \
%D%/net/inet_network.c \
%D%/net/inet_ntoa.c \
%D%/net/inet_ntop.c \
%D%/net/inet_pton.c \
%D%/net/nametoindex.c \
%D%/net/network.c \
%D%/alarm.c \
%D%/chmod.c \
%D%/chown.c \
%D%/clocks.c \
%D%/dup.c \
%D%/endmntent.c \
%D%/exec.c \
%D%/fcntl.c \
%D%/fork.c \
%D%/fs.c \
%D%/getentropy.c \
%D%/getmntent.c \
%D%/getpagesize.c \
%D%/groups.c \
%D%/ids.c \
%D%/io.c \
%D%/ioctl.c \
%D%/mmap.c \
%D%/mount.c \
%D%/nanosleep.c \
%D%/phoenix.c \
%D%/pid.c \
%D%/pipe.c \
%D%/poll.c \
%D%/realpath.c \
%D%/reboot.c \
%D%/resource.c \
%D%/sbrk.c \
%D%/sched.c \
%D%/select.c \
%D%/semaphore.c \
%D%/setmntent.c \
%D%/shm.c \
%D%/signal.c \
%D%/socket.c \
%D%/sockopt.c \
%D%/stat.c \
%D%/statfs.c \
%D%/symlink.c \
%D%/sync.c \
%D%/sysconf.c \
%D%/syslog.c \
%D%/time.c \
%D%/truncate.c \
%D%/tty.c \
%D%/uname.c \
%D%/utime.c \
%D%/wait.c
libc_a_CPPFLAGS_%C%_net = -I$(srcdir)/%D%
%D%/crt0.o: %D%/$(PHOENIX_MACHINE_DIR)/crt0.o
$(AM_V_at)rm -f $@
$(AM_V_GEN)ln $< $@ >/dev/null 2>/dev/null || cp $< $@
INSTALL_DATA_LOCAL += install-data-local-%C%
install-data-local-%C%:
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/arpa; \
for i in $(srcdir)/%D%/include/arpa/*.h; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/arpa/`basename $$i`; \
done; \
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/net; \
for i in $(srcdir)/%D%/include/net/*.h; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/net/`basename $$i`; \
done; \
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netinet; \
for i in $(srcdir)/%D%/include/netinet/*.h; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netinet/`basename $$i`; \
done; \
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netinet6; \
for i in $(srcdir)/%D%/include/netinet6/*.h; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netinet6/`basename $$i`; \
done; \
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netpacket; \
for i in $(srcdir)/%D%/include/netpacket/*.h; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netpacket/`basename $$i`; \
done;
if HAVE_LIBC_SYS_PHOENIX_ARM_DIR
include %D%/machine/arm/Makefile.inc
endif

View File

@ -1,8 +0,0 @@
AS_IF([test "$sys_dir" = "phoenix"], [dnl
PHOENIX_MACHINE_DIR=machine/${machine_dir}
])
AC_SUBST(PHOENIX_MACHINE_DIR)
m4_foreach_w([MACHINE], [
arm
], [AM_CONDITIONAL([HAVE_LIBC_SYS_PHOENIX_]m4_toupper(MACHINE)[_DIR], test "${machine_dir}" = MACHINE)])

View File

@ -1,29 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
unsigned int alarm(unsigned int seconds)
{
/* TODO: implement. */
return 0;
}

View File

@ -1,146 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _POSIX_OPT_H
#define _POSIX_OPT_H
/* Job control is supported. */
#define _POSIX_JOB_CONTROL 1
/* Processes have a saved set-user-ID and a saved set-group-ID. */
#define _POSIX_SAVED_IDS 1
/* Priority scheduling is supported. */
#define _POSIX_PRIORITY_SCHEDULING 1
/* Synchronizing file data is supported. */
#define _POSIX_SYNCHRONIZED_IO 1
/* The fsync function is present. */
#define _POSIX_FSYNC 1
/* Mapping of files to memory is supported. */
#define _POSIX_MAPPED_FILES 1
/* Locking of all memory is supported. */
#define _POSIX_MEMLOCK 1
/* Locking of ranges of memory is supported. */
#define _POSIX_MEMLOCK_RANGE 1
/* Setting of memory protections is supported. */
#define _POSIX_MEMORY_PROTECTION 1
/* Implementation supports `poll' function. */
#define _POSIX_POLL 1
/* Implementation supports `select' and `pselect' functions. */
#define _POSIX_SELECT 1
/* Only root can change owner of file. */
#define _POSIX_CHOWN_RESTRICTED 1
/* `c_cc' member of 'struct termios' structure can be disabled by
using the value _POSIX_VDISABLE. */
#define _POSIX_VDISABLE '\0'
/* Filenames are not silently truncated. */
#define _POSIX_NO_TRUNC 1
/* X/Open realtime support is available. */
#define _XOPEN_REALTIME 1
/* X/Open realtime thread support is available. */
#define _XOPEN_REALTIME_THREADS 1
/* XPG4.2 shared memory is supported. */
#define _XOPEN_SHM 1
/* Tell we don't have POSIX threads. */
#undef _POSIX_THREADS
/* We have the reentrant functions described in POSIX. */
#define _POSIX_REENTRANT_FUNCTIONS 1
#define _POSIX_THREAD_SAFE_FUNCTIONS 1
/* We provide priority scheduling for threads. */
#define _POSIX_THREAD_PRIORITY_SCHEDULING 1
/* We support user-defined stack sizes. */
#define _POSIX_THREAD_ATTR_STACKSIZE 1
/* We support user-defined stacks. */
#define _POSIX_THREAD_ATTR_STACKADDR 1
/* We support POSIX.1b semaphores, but only the non-shared form for now. */
#define _POSIX_SEMAPHORES 1
/* Real-time signals are supported. */
#define _POSIX_REALTIME_SIGNALS 1
/* We support asynchronous I/O. */
#define _POSIX_ASYNCHRONOUS_IO 1
#define _POSIX_ASYNC_IO 1
/* Alternative name for Unix98. */
#define _LFS_ASYNCHRONOUS_IO 1
/* The LFS support in asynchronous I/O is also available. */
#define _LFS64_ASYNCHRONOUS_IO 1
/* The rest of the LFS is also available. */
#define _LFS_LARGEFILE 1
#define _LFS64_LARGEFILE 1
#define _LFS64_STDIO 1
/* POSIX shared memory objects are implemented. */
#define _POSIX_SHARED_MEMORY_OBJECTS 1
/* GNU libc provides regular expression handling. */
#define _POSIX_REGEXP 1
/* Reader/Writer locks are available. */
#define _POSIX_READER_WRITER_LOCKS 200912L
/* We have a POSIX shell. */
#define _POSIX_SHELL 1
/* We support the Timeouts option. */
#define _POSIX_TIMEOUTS 200912L
/* We support spinlocks. */
#define _POSIX_SPIN_LOCKS 200912L
/* The `spawn' function family is supported. */
#define _POSIX_SPAWN 200912L
/* We don't have POSIX timers. */
#undef _POSIX_TIMERS
/* The barrier functions are available. */
#define _POSIX_BARRIERS 200912L
/* POSIX message queues are not yet supported. */
#undef _POSIX_MESSAGE_PASSING
#endif

View File

@ -1,50 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sys/types.h>
int chmod(const char *pathname, mode_t mode)
{
int ret = syscall2(int, SYS_CHMOD, pathname, mode);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int fchmod(int fd, mode_t mode)
{
int ret = syscall2(int, SYS_FCHMOD, fd, mode);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,61 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sys/types.h>
int chown(const char *pathname, uid_t owner, gid_t group)
{
int ret = syscall3(int, SYS_CHOWN, pathname, (unsigned int) owner, (unsigned int) group);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int fchown(int fd, uid_t owner, gid_t group)
{
int ret = syscall3(int, SYS_FCHOWN, fd, (unsigned int) owner, (unsigned int) group);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int lchown(const char *pathname, uid_t owner, gid_t group)
{
int ret = syscall3(int, SYS_LCHOWN, pathname, (unsigned int) owner, (unsigned int) group);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,50 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <time.h>
int clock_gettime(clockid_t clock_id, struct timespec *tp)
{
int ret = syscall2(int, SYS_CLOCK_GETTIME, clock_id, tp);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int clock_settime(clockid_t clock_id, const struct timespec *tp)
{
int ret = syscall2(int, SYS_CLOCK_SETTIME, clock_id, tp);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,50 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <fcntl.h>
int dup(int oldfd)
{
int ret = fcntl(oldfd, F_DUPFD, 0);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int dup2(int oldfd, int newfd)
{
int ret = syscall2(int, SYS_DUP2, oldfd, newfd);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,31 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <stdio.h>
int endmntent(FILE *fp)
{
fclose(fp);
return 1;
}

View File

@ -1,55 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <stdio.h>
int execve(const char *filename, char *const argv[], char *const envp[])
{
int ret = syscall3(int, SYS_EXECVE, filename, argv, envp);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int _execve(const char *filename, char *const argv[], char *const envp[])
{
return execve(filename, argv, envp);
}
void exit(int status)
{
fflush(NULL);
syscall1(int, SYS_EXIT, status);
}
void _exit(int status)
{
exit(status);
}

View File

@ -1,48 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
int fcntl( int fd , int cmd, ...)
{
int arg = 0;
if ((cmd == F_DUPFD) || (cmd == F_SETFD) || (cmd == F_SETFL)) {
va_list args;
va_start(args, cmd);
arg = va_arg(args, int);
va_end(args);
}
int ret = syscall3(int, SYS_FCNTL, fd, cmd, arg);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,70 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
pid_t fork()
{
int ret = syscall3(int, SYS_FORK, 0x10, 0x20, 0x30);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
pid_t vfork()
{
return fork();
}
int daemon(int nochdir, int noclose)
{
switch(fork()) {
case -1:
return -1;
case 0:
break;
default:
exit(0);
}
if (setsid() == -1)
return -1;
if (nochdir == 0)
chdir("/");
if (noclose == 0)
freopen("/dev/null", "a+", stdout);
return 0;
}

View File

@ -1,130 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <fcntl.h>
#include <malloc.h>
#include <stdio.h>
#include <sys/dirent.h>
#include <sys/stat.h>
#define MAX_PATH 1024
int mkdir(const char *pathname, mode_t mode)
{
int ret = syscall2(int, SYS_MKDIR, pathname, mode);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int rmdir(const char *pathname)
{
int ret = syscall1(int, SYS_RMDIR, pathname);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int chdir(const char *path)
{
int ret = syscall1(int, SYS_SETCWD, path);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
char *getcwd(char *buf, size_t size)
{
if (buf == NULL)
buf = (char *) malloc(MAX_PATH);
int ret = syscall2(int, SYS_GETCWD, buf, size);
if (ret < 0) {
errno = -ret;
return NULL;
}
return buf;
}
int unlink(const char *pathname)
{
int ret = syscall1(int, SYS_UNLINK, pathname);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int mkfifo(const char *pathname, mode_t mode)
{
int ret = syscall3(int, SYS_OPEN, pathname, O_CREAT, (mode | S_IFIFO));
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int mknod(const char *pathname, mode_t mode, dev_t dev)
{
int ret = syscall3(int, SYS_MKNOD, pathname, mode, dev);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
{
int ret = syscall3(int, SYS_GETDENTS, fd, dirp, count);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int chroot(const char *path)
{
return chdir(path);
}

View File

@ -1,48 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#define DEV_RANDOM "/dev/random"
#define MAX_ENTROPY 256
int getentropy(void *buf, size_t buflen)
{
if (buflen > MAX_ENTROPY) {
errno = -EIO;
return -1;
}
int ret = -1;
int fd = open(DEV_RANDOM, O_RDONLY);
if (fd >= 0) {
ret = read(fd, buf, buflen);
close(fd);
}
return (ret > 0) ? 0 : -1;
}

View File

@ -1,101 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <mntent.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define COLUMN_FS_NAME 0
#define COLUMN_MOUNTPOINT 1
#define COLUMN_FS_TYPE 2
#define COLUMN_OPTS 3
#define COLUMN_DUMP_FREQ 4
#define COLUMN_PASSNO 5
#define BUFFER_SIZE 4096
struct mntent *getmntent_r(FILE *fp, struct mntent *result, char *buffer, int bufsize)
{
char *token, *buff_ptr;
char *line = NULL;
size_t size = 0;
int i;
buff_ptr = buffer;
if (getline(&line, &size, fp) == -1 || feof(fp)) {
free(line);
return NULL;
}
for (token = strtok(line, " "), i = 0; token != NULL; token = strtok(NULL, " "), ++i) {
if (((buff_ptr + strlen(token) + 1) - buffer) > bufsize) {
errno = ENOBUFS;
free(line);
return NULL;
}
switch (i) {
case COLUMN_FS_NAME:
result->mnt_fsname = strcpy(buff_ptr, token);
break;
case COLUMN_MOUNTPOINT:
result->mnt_dir = strcpy(buff_ptr, token);
break;
case COLUMN_FS_TYPE:
result->mnt_type = strcpy(buff_ptr, token);
break;
case COLUMN_OPTS:
result->mnt_opts = strcpy(buff_ptr, token);
break;
case COLUMN_DUMP_FREQ:
result->mnt_freq = atoi(token);
break;
case COLUMN_PASSNO:
result->mnt_passno = atoi(token);
break;
default:
free(line);
return NULL;
}
buff_ptr += strlen(token) + 1;
}
free(line);
return result;
}
struct mntent *getmntent(FILE *fp)
{
static struct mntent result;
static char buffer[BUFFER_SIZE];
memset(&result, 0, sizeof(struct mntent));
memset(buffer, 0, sizeof(buffer));
return getmntent_r(fp, &result, buffer, sizeof(buffer));
}

View File

@ -1,31 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#define PHOENIX_PAGESIZE 0x1000
int getpagesize()
{
/* TODO: consider making it a syscall. */
return PHOENIX_PAGESIZE;
}

View File

@ -1,100 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <stdio.h>
#include <sys/types.h>
int initgroups(const char *user, gid_t group)
{
/* TODO: implement. */
if(user == NULL) {
errno = EINVAL;
return -1;
}
return 0;
}
int getgroups(int size, gid_t list[])
{
int ret = syscall2(int, SYS_GETGROUPS, size, list);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int setgroups(size_t size, const gid_t *list)
{
int ret = syscall2(int, SYS_SETGROUPS, size, list);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
struct group *getgrent()
{
/* TODO: implement. */
errno = ENOSYS;
return NULL;
}
void setgrent()
{
/* TODO: implement. */
}
void endgrent()
{
/* TODO: implement. */
}
struct group *getgrnam(const char *name)
{
/* TODO: implement. */
errno = ENOSYS;
return NULL;
}
struct group *getgrgid(gid_t gid)
{
/* TODO: implement. */
errno = ENOSYS;
return NULL;
}
int setpgrp(pid_t pid, pid_t pgid)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}

View File

@ -1,137 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
uid_t getuid()
{
return syscall0(int, SYS_GETUID);
}
uid_t geteuid()
{
return syscall0(int, SYS_GETEUID);
}
int setuid(uid_t uid)
{
int ret = syscall1(int, SYS_SETUID, (unsigned int) uid);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int seteuid(uid_t euid)
{
int ret = syscall1(int, SYS_SETEUID, (unsigned int) euid);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int setreuid(uid_t ruid, uid_t euid)
{
int ret = syscall2(int, SYS_SETREUID, (unsigned int) ruid, (unsigned int) euid);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
gid_t getgid()
{
return syscall0(int, SYS_GETGID);
}
gid_t getegid()
{
return syscall0(int, SYS_GETEGID);
}
int setgid(gid_t gid)
{
int ret = syscall2(int, SYS_SETGID, (unsigned int) gid, 0);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int setegid(gid_t egid)
{
int ret = syscall1(int, SYS_SETEGID, (unsigned int) egid);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int setregid(gid_t rgid, gid_t egid)
{
int ret = syscall2(int, SYS_SETREGID, (unsigned int) rgid, (unsigned int) egid);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int setpgid(pid_t pid, pid_t pgid)
{
int ret = syscall2(int, SYS_SETGID, pgid, pid);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
pid_t getsid(pid_t pid)
{
errno = ENOSYS;
return -1;
}
pid_t setsid()
{
return getpid();
}

View File

@ -1,47 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _ARPA_INET_H
#define _ARPA_INET_H
#include <netinet/in.h>
#include <phoenix/socket.h>
#include <stdint.h>
#define INET_ADDRSTRLEN 16
#define INET6_ADDRSTRLEN 46
int inet_aton(const char *cp, struct in_addr *inp);
in_addr_t inet_addr(const char *cp);
in_addr_t inet_network(const char *cp);
char *inet_ntoa(struct in_addr in);
struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host);
in_addr_t inet_lnaof(struct in_addr in);
in_addr_t inet_netof(struct in_addr in);
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
int inet_pton(int af, const char *src, void *dst);
int inet_net_pton(int af, const char *pres, void *netp, size_t nsize);
char *inet_net_ntop(int af, const void *netp, int bits, char *pres, size_t psize);
#endif

View File

@ -1,44 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _ARPA_NAMESER_H
#define _ARPA_NAMESER_H
/* Define constants based on RFC 883, RFC 1034, RFC 1035 */
#define NS_PACKETSZ 512 /* Maximum packet size */
#define NS_MAXDNAME 1025 /* Maximum domain name */
#define NS_MAXCDNAME 255 /* Maximum compressed domain name */
#define NS_MAXLABEL 63 /* Maximum length of domain label */
#define NS_HFIXEDSZ 12 /* Bytes of fixed data in header */
#define NS_QFIXEDSZ 4 /* Bytes of fixed data in query */
#define NS_RRFIXEDSZ 10 /* Bytes of fixed data in r record */
#define NS_INT32SZ 4 /* Bytes of data in a u_int32_t */
#define NS_INT16SZ 2 /* Bytes of data in a u_int16_t */
#define NS_INT8SZ 1 /* Bytes of data in a u_int8_t */
#define NS_INADDRSZ 4 /* IPv4 T_A */
#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */
#endif

View File

@ -1,327 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)telnet.h 8.2 (Berkeley) 12/15/93
* $FreeBSD: src/include/arpa/telnet.h,v 1.8 2001/12/03 12:41:18 markm Exp $
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#ifndef _ARPA_TELNET_H
#define _ARPA_TELNET_H
/* Definitions for the TELNET protocol. */
#define IAC 255 /* interpret as command: */
#define DONT 254 /* you are not to use option */
#define DO 253 /* please, you use option */
#define WONT 252 /* I won't use option */
#define WILL 251 /* I will use option */
#define SB 250 /* interpret as subnegotiation */
#define GA 249 /* you may reverse the line */
#define EL 248 /* erase the current line */
#define EC 247 /* erase the current character */
#define AYT 246 /* are you there */
#define AO 245 /* abort output--but let prog finish */
#define IP 244 /* interrupt process--permanently */
#define BREAK 243 /* break */
#define DM 242 /* data mark--for connect. cleaning */
#define NOP 241 /* nop */
#define SE 240 /* end sub negotiation */
#define EOR 239 /* end of record (transparent mode) */
#define ABORT 238 /* Abort process */
#define SUSP 237 /* Suspend process */
#define xEOF 236 /* End of file: EOF is already used... */
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
const char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
0
};
#else
extern char *telcmds[];
#endif
#define TELCMD_FIRST xEOF
#define TELCMD_LAST IAC
#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && (unsigned int)(x) >= TELCMD_FIRST)
#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
/* telnet options */
#define TELOPT_BINARY 0 /* 8-bit data path */
#define TELOPT_ECHO 1 /* echo */
#define TELOPT_RCP 2 /* prepare to reconnect */
#define TELOPT_SGA 3 /* suppress go ahead */
#define TELOPT_NAMS 4 /* approximate message size */
#define TELOPT_STATUS 5 /* give status */
#define TELOPT_TM 6 /* timing mark */
#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
#define TELOPT_NAOL 8 /* negotiate about output line width */
#define TELOPT_NAOP 9 /* negotiate about output page size */
#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
#define TELOPT_XASCII 17 /* extended ascic character set */
#define TELOPT_LOGOUT 18 /* force logout */
#define TELOPT_BM 19 /* byte macro */
#define TELOPT_DET 20 /* data entry terminal */
#define TELOPT_SUPDUP 21 /* supdup protocol */
#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
#define TELOPT_SNDLOC 23 /* send location */
#define TELOPT_TTYPE 24 /* terminal type */
#define TELOPT_EOR 25 /* end or record */
#define TELOPT_TUID 26 /* TACACS user identification */
#define TELOPT_OUTMRK 27 /* output marking */
#define TELOPT_TTYLOC 28 /* terminal location number */
#define TELOPT_3270REGIME 29 /* 3270 regime */
#define TELOPT_X3PAD 30 /* X.3 PAD */
#define TELOPT_NAWS 31 /* window size */
#define TELOPT_TSPEED 32 /* terminal speed */
#define TELOPT_LFLOW 33 /* remote flow control */
#define TELOPT_LINEMODE 34 /* Linemode option */
#define TELOPT_XDISPLOC 35 /* X Display Location */
#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
#define TELOPT_AUTHENTICATION 37 /* Authenticate */
#define TELOPT_ENCRYPT 38 /* Encryption option */
#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
#define TELOPT_EXOPL 255 /* extended-options-list */
#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
#ifdef TELOPTS
const char *telopts[NTELOPTS + 1] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
"TACACS UID", "OUTPUT MARKING", "TTYLOC",
"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
"ENCRYPT", "NEW-ENVIRON",
0
};
#define TELOPT_FIRST TELOPT_BINARY
#define TELOPT_LAST TELOPT_NEW_ENVIRON
#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
#endif
/* Sub-option qualifiers */
#define TELQUAL_IS 0 /* Option is... */
#define TELQUAL_SEND 1 /* Send option */
#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
#define LFLOW_OFF 0 /* Disable remote flow control */
#define LFLOW_ON 1 /* Enable remote flow control */
#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
/* LINEMODE suboptions */
#define LM_MODE 1
#define LM_FORWARDMASK 2
#define LM_SLC 3
#define MODE_EDIT 0x01
#define MODE_TRAPSIG 0x02
#define MODE_ACK 0x04
#define MODE_SOFT_TAB 0x08
#define MODE_LIT_ECHO 0x10
#define MODE_MASK 0x1f
/* Not part of protocol, but needed to simplify things... */
#define MODE_FLOW 0x0100
#define MODE_ECHO 0x0200
#define MODE_INBIN 0x0400
#define MODE_OUTBIN 0x0800
#define MODE_FORCE 0x1000
#define SLC_SYNCH 1
#define SLC_BRK 2
#define SLC_IP 3
#define SLC_AO 4
#define SLC_AYT 5
#define SLC_EOR 6
#define SLC_ABORT 7
#define SLC_EOF 8
#define SLC_SUSP 9
#define SLC_EC 10
#define SLC_EL 11
#define SLC_EW 12
#define SLC_RP 13
#define SLC_LNEXT 14
#define SLC_XON 15
#define SLC_XOFF 16
#define SLC_FORW1 17
#define SLC_FORW2 18
#define SLC_MCL 19
#define SLC_MCR 20
#define SLC_MCWL 21
#define SLC_MCWR 22
#define SLC_MCBOL 23
#define SLC_MCEOL 24
#define SLC_INSRT 25
#define SLC_OVER 26
#define SLC_ECR 27
#define SLC_EWR 28
#define SLC_EBOL 29
#define SLC_EEOL 30
#define NSLC 30
/*
* For backwards compatibility, we define SLC_NAMES to be the
* list of names if SLC_NAMES is not defined.
*/
#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
"LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
"MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
"MCEOL", "INSRT", "OVER", "ECR", "EWR", \
"EBOL", "EEOL", \
0
#ifdef SLC_NAMES
const char *slc_names[] = {
SLC_NAMELIST
};
#else
extern char *slc_names[];
#define SLC_NAMES SLC_NAMELIST
#endif
#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
#define SLC_NAME(x) slc_names[x]
#define SLC_NOSUPPORT 0
#define SLC_CANTCHANGE 1
#define SLC_VARIABLE 2
#define SLC_DEFAULT 3
#define SLC_LEVELBITS 0x03
#define SLC_FUNC 0
#define SLC_FLAGS 1
#define SLC_VALUE 2
#define SLC_ACK 0x80
#define SLC_FLUSHIN 0x40
#define SLC_FLUSHOUT 0x20
#define OLD_ENV_VAR 1
#define OLD_ENV_VALUE 0
#define NEW_ENV_VAR 0
#define NEW_ENV_VALUE 1
#define ENV_ESC 2
#define ENV_USERVAR 3
/* AUTHENTICATION suboptions */
/* Who is authenticating who ... */
#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
#define AUTH_WHO_SERVER 1 /* Server authenticating client */
#define AUTH_WHO_MASK 1
/* Amount of authentication done */
#define AUTH_HOW_ONE_WAY 0
#define AUTH_HOW_MUTUAL 2
#define AUTH_HOW_MASK 2
#define AUTHTYPE_NULL 0
#define AUTHTYPE_KERBEROS_V4 1
#define AUTHTYPE_KERBEROS_V5 2
#define AUTHTYPE_SPX 3
#define AUTHTYPE_MINK 4
#define AUTHTYPE_SRA 6
#define AUTHTYPE_CNT 7
#define AUTHTYPE_TEST 99
#ifdef AUTH_NAMES
const char *authtype_names[] = {
"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
0
};
#else
extern char *authtype_names[];
#endif
#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
#define AUTHTYPE_NAME(x) authtype_names[x]
/* ENCRYPTion suboptions */
#define ENCRYPT_IS 0 /* I pick encryption type ... */
#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
#define ENCRYPT_REPLY 2 /* Initial setup response */
#define ENCRYPT_START 3 /* Am starting to send encrypted */
#define ENCRYPT_END 4 /* Am ending encrypted */
#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
#define ENCRYPT_REQEND 6 /* Request you end encrypting */
#define ENCRYPT_ENC_KEYID 7
#define ENCRYPT_DEC_KEYID 8
#define ENCRYPT_CNT 9
#define ENCTYPE_ANY 0
#define ENCTYPE_DES_CFB64 1
#define ENCTYPE_DES_OFB64 2
#define ENCTYPE_CNT 3
#ifdef ENCRYPT_NAMES
const char *encrypt_names[] = {
"IS", "SUPPORT", "REPLY", "START", "END",
"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
0
};
const char *enctype_names[] = {
"ANY", "DES_CFB64", "DES_OFB64",
0
};
#else
extern char *encrypt_names[];
extern char *enctype_names[];
#endif
#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
#define ENCRYPT_NAME(x) encrypt_names[x]
#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
#define ENCTYPE_NAME(x) enctype_names[x]
#endif

View File

@ -1,30 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef FEATURES_H
#define FEATURES_H
#include <sys/features.h>
#endif

View File

@ -1,66 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef MNTENT_H
#define MNTENT_H
#include <features.h>
#define __need_FILE
#include <stdio.h>
#include <paths.h>
/* File listing canonical interesting mount points. */
#define MNTTAB _PATH_MNTTAB /* Deprecated alias. */
/* File listing currently active mount points. */
#define MOUNTED _PATH_MOUNTED /* Deprecated alias. */
/* General filesystem types. */
#define MNTTYPE_IGNORE "ignore" /* Ignore this entry. */
#define MNTTYPE_NFS "nfs" /* Network file system. */
#define MNTTYPE_SWAP "swap" /* Swap device. */
/* Generic mount options. */
#define MNTOPT_DEFAULTS "defaults" /* Use all default options. */
#define MNTOPT_RO "ro" /* Read only. */
#define MNTOPT_RW "rw" /* Read/write. */
#define MNTOPT_SUID "suid" /* Set uid allowed. */
#define MNTOPT_NOSUID "nosuid" /* No set uid allowed. */
#define MNTOPT_NOAUTO "noauto" /* Do not auto mount. */
/* Structure describing a mount table entry. */
struct mntent {
char *mnt_fsname; /* Device or server for filesystem. */
char *mnt_dir; /* Directory mounted on. */
char *mnt_type; /* Type of filesystem: ufs, nfs, etc. */
char *mnt_opts; /* Comma-separated options for fs. */
int mnt_freq; /* Dump frequency (in days). */
int mnt_passno; /* Pass number for `fsck'. */
};
FILE *setmntent(const char *filename, const char *type);
struct mntent *getmntent(FILE *fp);
int endmntent(FILE * filep);
#endif

View File

@ -1,239 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)if.h 8.1 (Berkeley) 6/10/93
* $FreeBSD: src/sys/net/if.h,v 1.71 2002/03/19 21:54:16 alfred Exp $
*/
#ifndef _NET_IF_H
#define _NET_IF_H
#include <phoenix/iface.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/time.h>
struct ifnet;
/*
* Length of interface external name, including terminating '\0'.
* Note: this is the same size as a generic device's external name.
*/
#define IFNAMSIZ 16
#define IF_NAMESIZE IFNAMSIZ
#define IF_MAXUNIT 0x7fff /* ifp->if_unit is only 15 bits */
/* Structure describing a `cloning' interface. */
struct if_clone {
LIST_ENTRY(if_clone) ifc_list; /* On list of cloners */
const char *ifc_name; /* Name of device, e.g. `gif' */
size_t ifc_namelen; /* Length of name */
int ifc_maxunit; /* Maximum unit number */
unsigned char *ifc_units; /* Bitmap to handle units */
int ifc_bmlen; /* Bitmap length */
int (*ifc_create)(struct if_clone *, int);
int (*ifc_destroy)(struct ifnet *);
};
#define IF_CLONE_INITIALIZER(name, create, destroy, maxunit) \
{ { 0 }, name, sizeof(name) - 1, maxunit, NULL, 0, create, destroy }
/* Structure used to query names of interface cloners. */
struct if_clonereq {
int ifcr_total; /* Total cloners (out) */
int ifcr_count; /* Room for this many in user buffer */
char *ifcr_buffer; /* Buffer for cloner names */
};
/*
* Structure describing information about an interface
* which may be of interest to management entities.
*/
struct if_data {
/* Generic interface information */
u_char ifi_type; /* Ethernet, tokenring, etc */
u_char ifi_physical; /* E.g., AUI, Thinnet, 10base-T, etc */
u_char ifi_addrlen; /* Media address length */
u_char ifi_hdrlen; /* Media header length */
u_char ifi_recvquota; /* Polling quota for receive intrs */
u_char ifi_xmitquota; /* Polling quota for xmit intrs */
u_long ifi_mtu; /* Maximum transmission unit */
u_long ifi_metric; /* Routing metric (external only) */
u_long ifi_baudrate; /* Linespeed */
/* Volatile statistics */
u_long ifi_ipackets; /* Packets received on interface */
u_long ifi_ierrors; /* Input errors on interface */
u_long ifi_opackets; /* Packets sent on interface */
u_long ifi_oerrors; /* Output errors on interface */
u_long ifi_collisions; /* Collisions on csma interfaces */
u_long ifi_ibytes; /* Total number of octets received */
u_long ifi_obytes; /* Total number of octets sent */
u_long ifi_imcasts; /* Packets received via multicast */
u_long ifi_omcasts; /* Packets sent via multicast */
u_long ifi_iqdrops; /* Dropped on input, this interface */
u_long ifi_noproto; /* Destined for unsupported protocol */
u_long ifi_hwassist; /* HW offload capabilities */
u_long ifi_unused; /* XXX was ifi_xmittiming */
struct timeval ifi_lastchange; /* Time of last administrative change */
};
/*
* The following flag(s) ought to go in if_flags, but we cannot change
* struct ifnet because of binary compatibility, so we store them in
* if_ipending, which is not used so far.
* If possible, make sure the value is not conflicting with other
* IFF flags, so we have an easier time when we want to merge them.
*/
#define IFF_POLLING 0x10000 /* Interface is in polling mode. */
/* Flags set internally only */
#define IFF_CANTCHANGE (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING | IFF_OACTIVE | IFF_SIMPLEX | IFF_MULTICAST | IFF_ALLMULTI | IFF_NOTRAILERS)
/* Capabilities that interfaces can advertise. */
#define IFCAP_RXCSUM 0x0001 /* Can offload checksum on RX */
#define IFCAP_TXCSUM 0x0002 /* Can offload checksum on TX */
#define IFCAP_NETCONS 0x0004 /* Can be a network console */
#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM)
#define IFQ_MAXLEN 50
#define IFNET_SLOWHZ 1 /* Granularity is 1 second */
/* Message format for use in obtaining information about interfaces from getkerninfo and the routing socket */
struct if_msghdr {
u_short ifm_msglen; /* To skip over non-understood messages */
u_char ifm_version; /* Future binary compatibility */
u_char ifm_type; /* Message type */
int ifm_addrs; /* Like rtm_addrs */
int ifm_flags; /* Value of if_flags */
u_short ifm_index; /* Index for associated ifp */
struct if_data ifm_data; /* Statistics and other data about if */
};
/* Message format for use in obtaining information about interface addresses from getkerninfo and the routing socket */
struct ifa_msghdr {
u_short ifam_msglen; /* To skip over non-understood messages */
u_char ifam_version; /* Future binary compatibility */
u_char ifam_type; /* Message type */
int ifam_addrs; /* Like rtm_addrs */
int ifam_flags; /* Value of ifa_flags */
u_short ifam_index; /* Index for associated ifp */
int ifam_metric; /* Value of ifa_metric */
};
/* Message format for use in obtaining information about multicast addresses from the routing socket */
struct ifma_msghdr {
u_short ifmam_msglen; /* To skip over non-understood messages */
u_char ifmam_version; /* Future binary compatibility */
u_char ifmam_type; /* Message type */
int ifmam_addrs; /* Like rtm_addrs */
int ifmam_flags; /* Value of ifa_flags */
u_short ifmam_index; /* Index for associated ifp */
};
/* Message format announcing the arrival or departure of a network interface. */
struct if_announcemsghdr {
u_short ifan_msglen; /* To skip over non-understood messages */
u_char ifan_version; /* Future binary compatibility */
u_char ifan_type; /* Message type */
u_short ifan_index; /* Index for associated ifp */
char ifan_name[IFNAMSIZ]; /* If name, e.g. "en0" */
u_short ifan_what; /* What type of announcement */
};
#define IFAN_ARRIVAL 0 /* Interface arrival */
#define IFAN_DEPARTURE 1 /* Interface departure */
struct ifaliasreq {
char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
struct sockaddr ifra_addr;
struct sockaddr ifra_broadaddr;
struct sockaddr ifra_mask;
};
struct ifmediareq {
char ifm_name[IFNAMSIZ]; /* If name, e.g. "en0" */
int ifm_current; /* Current media options */
int ifm_mask; /* Don't care mask */
int ifm_status; /* Media status */
int ifm_active; /* Active options */
int ifm_count; /* # entries in ifm_ulist array */
int *ifm_ulist; /* Media words */
};
/*
* Structure used to retrieve aux status data from interfaces.
* Kernel suppliers to this interface should respect the formatting
* needed by ifconfig(8): each line starts with a TAB and ends with
* a newline. The canonical example to copy and paste is in if_tun.c.
*/
#define IFSTATMAX 800 /* 10 lines of text */
struct ifstat {
char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */
char ascii[IFSTATMAX + 1];
};
/*
* Structure used in SIOCGIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible).
*/
struct ifconf {
int ifc_len; /* Size of associated buffer */
union {
caddr_t ifcu_buf;
struct ifreq *ifcu_req;
} ifc_ifcu;
#define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* Array of structures returned */
};
/* Structure for SIOC[AGD]LIFADDR */
struct if_laddrreq {
char iflr_name[IFNAMSIZ];
u_int flags;
#define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */
u_int prefixlen; /* in/out */
struct sockaddr_storage addr; /* in/out */
struct sockaddr_storage dstaddr; /* out */
};
struct if_nameindex {
u_int if_index; /* 1, 2, ... */
char *if_name; /* null terminated name: "le0", ... */
};
unsigned int if_nametoindex(const char *ifname);
char *if_indextoname(unsigned int ifindex, char *ifname);
struct if_nameindex *if_nameindex();
void if_freenameindex(struct if_nameindex *ptr);
#endif

View File

@ -1,117 +0,0 @@
/*
* Copyright (c) 1986, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)if_arp.h 8.1 (Berkeley) 6/10/93
* $FreeBSD: src/sys/net/if_arp.h,v 1.16 2001/10/14 20:17:52 fjoe Exp $
*/
#ifndef _NET_IF_ARP_H_
#define _NET_IF_ARP_H_
/*
* Address Resolution Protocol.
*
* See RFC 826 for protocol description. ARP packets are variable
* in size; the arphdr structure defines the fixed-length portion.
* Protocol type values are the same as those for 10 Mb/s Ethernet.
* It is followed by the variable-sized fields ar_sha, arp_spa,
* arp_tha and arp_tpa in that order, according to the lengths
* specified. Field names used correspond to RFC 826.
*/
struct arphdr {
u_short ar_hrd; /* format of hardware address */
#define ARPHRD_ETHER 1 /* ethernet hardware format */
#define ARPHRD_IEEE802 6 /* token-ring hardware format */
#define ARPHRD_ARCNET 7 /* arcnet hardware format */
#define ARPHRD_FRELAY 15 /* frame relay hardware format */
u_short ar_pro; /* format of protocol address */
u_char ar_hln; /* length of hardware address */
u_char ar_pln; /* length of protocol address */
u_short ar_op; /* one of: */
#define ARPOP_REQUEST 1 /* request to resolve address */
#define ARPOP_REPLY 2 /* response to previous request */
#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */
#define ARPOP_REVREPLY 4 /* response giving protocol address */
#define ARPOP_INVREQUEST 8 /* request to identify peer */
#define ARPOP_INVREPLY 9 /* response identifying peer */
/*
* The remaining fields are variable in size,
* according to the sizes above.
*/
#ifdef COMMENT_ONLY
u_char ar_sha[]; /* sender hardware address */
u_char ar_spa[]; /* sender protocol address */
u_char ar_tha[]; /* target hardware address */
u_char ar_tpa[]; /* target protocol address */
#endif
};
#define ar_sha(ap) (((caddr_t)((ap)+1)) + 0)
#define ar_spa(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln)
#define ar_tha(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln + (ap)->ar_pln)
#define ar_tpa(ap) (((caddr_t)((ap)+1)) + 2*(ap)->ar_hln + (ap)->ar_pln)
#define arphdr_len2(ar_hln, ar_pln) \
(sizeof(struct arphdr) + 2*(ar_hln) + 2*(ar_pln))
#define arphdr_len(ap) (arphdr_len2((ap)->ar_hln, (ap)->ar_pln))
/*
* ARP ioctl request
*/
struct arpreq {
struct sockaddr arp_pa; /* protocol address */
struct sockaddr arp_ha; /* hardware address */
int arp_flags; /* flags */
};
/* arp_flags and at_flags field values */
#define ATF_INUSE 0x01 /* entry in use */
#define ATF_COM 0x02 /* completed entry (enaddr valid) */
#define ATF_PERM 0x04 /* permanent entry */
#define ATF_PUBL 0x08 /* publish entry (respond for other host) */
#define ATF_USETRAILERS 0x10 /* has requested trailers */
#ifdef _KERNEL
/*
* Structure shared between the ethernet driver modules and
* the address resolution code. For example, each ec_softc or il_softc
* begins with this structure.
*/
struct arpcom {
/*
* The ifnet struct _must_ be at the head of this structure.
*/
struct ifnet ac_if; /* network-visible interface */
u_char ac_enaddr[6]; /* ethernet hardware address */
int ac_multicnt; /* length of ac_multiaddrs list */
void *ac_netgraph; /* ng_ether(4) netgraph node info */
};
extern u_char etherbroadcastaddr[6];
#endif
#endif /* !_NET_IF_ARP_H_ */

View File

@ -1,225 +0,0 @@
/*-
* Copyright (c) 1980, 1983, 1988, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* 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, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION 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.
* -
* --Copyright--
*/
/*
* @(#)netdb.h 8.1 (Berkeley) 6/2/93
* From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $
* $FreeBSD: src/include/netdb.h,v 1.23 2002/03/23 17:24:53 imp Exp $
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#ifndef _NETDB_H
#define _NETDB_H
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#ifndef _PATH_HEQUIV
#define _PATH_HEQUIV "/etc/hosts.equiv"
#endif
#define _PATH_HOSTS "/etc/hosts"
#define _PATH_NETWORKS "/etc/networks"
#define _PATH_PROTOCOLS "/etc/protocols"
#define _PATH_SERVICES "/etc/services"
#define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
extern int *__h_errno_location(void);
#define h_errno (*(__h_errno_location()))
#define MAXALIASES 35
/* For now, only support one return address. */
#define MAXADDRS 2
struct hostent {
char *h_name; /* Official name of host */
char **h_aliases; /* Alias list */
int h_addrtype; /* Host address type */
int h_length; /* Length of address */
char **h_addr_list; /* List of addresses from name server */
char *h_addr; /* Address, for backward compatibility */
/* Private data, for re-entrancy */
char *__host_addrs[MAXADDRS];
char *__host_aliases[MAXALIASES];
unsigned int __host_addr[4];
};
/* Assumption here is that a network number fits in an unsigned long -- probably a poor one. */
struct netent {
char *n_name; /* Official name of net */
char **n_aliases; /* Alias list */
int n_addrtype; /* Net address type */
unsigned long n_net; /* Network # */
};
struct servent {
char *s_name; /* Official service name */
char **s_aliases; /* Alias list */
int s_port; /* Port # */
char *s_proto; /* Protocol to use */
};
struct protoent {
char *p_name; /* Official protocol name */
char **p_aliases; /* Alias list */
int p_proto; /* Protocol # */
};
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
size_t ai_addrlen; /* Length of ai_addr */
char *ai_canonname; /* Canonical name for hostname */
struct sockaddr *ai_addr; /* Binary address */
struct addrinfo *ai_next; /* Next structure in linked list */
};
/* Error return codes from gethostbyname() and gethostbyaddr() (left in extern int h_errno). */
#define NETDB_INTERNAL -1 /* See errno */
#define NETDB_SUCCESS 0 /* No problem */
#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */
#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define NO_DATA 4 /* Valid name, no data record of requested type */
#define NO_ADDRESS NO_DATA /* No address, look for MX record */
/* Error return codes from getaddrinfo() */
#define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
#define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
#define EAI_AGAIN -3 /* Temporary failure in name resolution. */
#define EAI_FAIL -4 /* Non-recoverable failure in name res. */
#define EAI_NODATA -5 /* No address associated with NAME. */
#define EAI_FAMILY -6 /* `ai_family' not supported. */
#define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
#define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
#define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
#define EAI_MEMORY -10 /* Memory allocation failure. */
#define EAI_SYSTEM -11 /* System error returned in `errno'. */
#define EAI_OVERFLOW -12 /* Argument buffer overflow. */
#ifdef __USE_GNU
#define EAI_INPROGRESS -100 /* Processing request in progress. */
#define EAI_CANCELED -101 /* Request canceled. */
#define EAI_NOTCANCELED -102 /* Request not canceled. */
#define EAI_ALLDONE -103 /* All requests done. */
#define EAI_INTR -104 /* Interrupted by a signal. */
#define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
#endif
/* Flag values for getaddrinfo() */
#define AI_PASSIVE 0x00000001 /* Get address to use bind() */
#define AI_CANONNAME 0x00000002 /* Fill ai_canonname */
#define AI_NUMERICHOST 0x00000004 /* Prevent name resolution */
#define AI_NUMERICSERV 0x00000008 /* Fon't use name resolution. */
/* Valid flags for addrinfo */
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ADDRCONFIG)
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
#define AI_V4MAPPED_CFG 0x00000200 /* Accept IPv4-mapped if kernel supports */
#define AI_ADDRCONFIG 0x00000400 /* Only if any address is assigned */
#define AI_V4MAPPED 0x00000800 /* Accept IPv4-mapped IPv6 address */
/* Special recommended flags for getipnodebyname */
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
/* Constants for getnameinfo() */
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
/* Flag values for getnameinfo() */
#define NI_NOFQDN 0x00000001
#define NI_NUMERICHOST 0x00000002
#define NI_NAMEREQD 0x00000004
#define NI_NUMERICSERV 0x00000008
#define NI_DGRAM 0x00000010
#define NI_WITHSCOPEID 0x00000020
/* Scope delimit character. */
#define SCOPE_DELIMITER '%'
void endhostent();
void endnetent();
void endnetgrent();
void endprotoent();
void endservent();
void freehostent(struct hostent *ip);
struct hostent *gethostbyaddr(const void *name, socklen_t len, int type);
struct hostent *gethostbyname(const char *name);
struct hostent *gethostbyname2(const char *name, int af);
struct hostent *gethostent();
struct hostent *getipnodebyaddr(const void *addr, size_t len, int af, int *error_num);
struct hostent *getipnodebyname(const char *name, int af, int flags, int *error_num);
struct netent *getnetbyaddr(uint32_t net, int type);
struct netent *getnetbyname(const char *name);
struct netent *getnetent();
int getnetgrent(char **host, char **user, char **domain);
struct protoent *getprotobyname(const char *name);
struct protoent *getprotobynumber(int proto);
struct protoent *getprotoent();
struct servent *getservbyname(const char *name, const char *proto);
struct servent *getservbyport(int name, const char *proto);
struct servent *getservent();
void herror(const char *s);
const char *hstrerror(int err);
int innetgr(const char *netgroup, const char *host, const char *user, const char *domain);
void sethostent(int stayopen);
void setnetent(int stayopen);
void setprotoent(int stayopen);
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags);
void freeaddrinfo(struct addrinfo *res);
char *gai_strerror(int errcode);
int setnetgrent(const char *netgroup);
void setservent(int stayopen);
#endif

View File

@ -1,362 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1990, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)in.h 8.3 (Berkeley) 1/3/94
* $FreeBSD: src/sys/netinet/in.h,v 1.68 2002/04/24 01:26:11 mike Exp $
*/
/* Copied from Linux, modified for Phoenix */
#ifndef _NETINET_IN_H
#define _NETINET_IN_H
#include <machine/endian.h>
#include <phoenix/netinet.h>
#include <sys/types.h>
#if BYTE_ORDER == BIG_ENDIAN
#define htons(a) (a)
#define htonl(a) (a)
#define ntohs(a) (a)
#define ntohl(a) (a)
#error Big endian is not supported!
#else
static uint32_t htonl(uint32_t hostlong)
{
return ((hostlong & 0xff) << 24) | ((hostlong & 0xff00) << 8) | ((hostlong & 0xff0000UL) >> 8) | ((hostlong & 0xff000000UL) >> 24);
}
static uint16_t htons(uint16_t hostshort)
{
return ((hostshort & 0xff) << 8) | ((hostshort & 0xff00) >> 8);
}
static uint32_t ntohl(uint32_t netlong)
{
return htonl(netlong);
}
static uint16_t ntohs(uint16_t netshort)
{
return htons(netshort);
}
#endif
#if __POSIX_VISIBLE >= 200112
#define IPPROTO_RAW 255 /* Raw IP packet */
#define INET_ADDRSTRLEN 16
#endif
/*
* Constants and structures defined by the internet system,
* Per RFC 790, September 1981, and numerous additions.
*/
/* Protocols (RFC 1700) */
#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */
#define IPPROTO_IGMP 2 /* Group mgmt protocol */
#define IPPROTO_GGP 3 /* Gateway^2 (deprecated) */
#define IPPROTO_IPV4 4 /* IPv4 encapsulation */
#define IPPROTO_IPIP IPPROTO_IPV4
#define IPPROTO_ST 7 /* Stream protocol II */
#define IPPROTO_EGP 8 /* Exterior gateway protocol */
#define IPPROTO_PIGP 9 /* Private interior gateway */
#define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */
#define IPPROTO_NVPII 11 /* Network voice protocol*/
#define IPPROTO_PUP 12 /* Pup */
#define IPPROTO_ARGUS 13 /* Argus */
#define IPPROTO_EMCON 14 /* EMCON */
#define IPPROTO_XNET 15 /* Cross Net Debugger */
#define IPPROTO_CHAOS 16 /* Chaos*/
#define IPPROTO_MUX 18 /* Multiplexing */
#define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */
#define IPPROTO_HMP 20 /* Host Monitoring */
#define IPPROTO_PRM 21 /* Packet Radio Measurement */
#define IPPROTO_IDP 22 /* Xns idp */
#define IPPROTO_TRUNK1 23 /* Trunk-1 */
#define IPPROTO_TRUNK2 24 /* Trunk-2 */
#define IPPROTO_LEAF1 25 /* Leaf-1 */
#define IPPROTO_LEAF2 26 /* Leaf-2 */
#define IPPROTO_RDP 27 /* Reliable Data */
#define IPPROTO_IRTP 28 /* Reliable Transaction */
#define IPPROTO_TP 29 /* Tp-4 w/ class negotiation */
#define IPPROTO_BLT 30 /* Bulk Data Transfer */
#define IPPROTO_NSP 31 /* Network Services */
#define IPPROTO_INP 32 /* Merit Internodal */
#define IPPROTO_SEP 33 /* Sequential Exchange */
#define IPPROTO_3PC 34 /* Third Party Connect */
#define IPPROTO_IDPR 35 /* InterDomain Policy Routing */
#define IPPROTO_XTP 36 /* XTP */
#define IPPROTO_DDP 37 /* Datagram Delivery */
#define IPPROTO_CMTP 38 /* Control Message Transport */
#define IPPROTO_TPXX 39 /* TP++ Transport */
#define IPPROTO_IL 40 /* IL transport protocol */
#define IPPROTO_IPV6 41 /* IP6 header */
#define IPPROTO_SDRP 42 /* Source Demand Routing */
#define IPPROTO_ROUTING 43 /* IP6 routing header */
#define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */
#define IPPROTO_IDRP 45 /* InterDomain Routing*/
#define IPPROTO_RSVP 46 /* Resource reservation */
#define IPPROTO_GRE 47 /* General Routing Encap. */
#define IPPROTO_MHRP 48 /* Mobile Host Routing */
#define IPPROTO_BHA 49 /* BHA */
#define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */
#define IPPROTO_AH 51 /* IP6 Auth Header */
#define IPPROTO_INLSP 52 /* Integ. Net Layer Security */
#define IPPROTO_SWIPE 53 /* IP with encryption */
#define IPPROTO_NHRP 54 /* Next Hop Resolution */
#define IPPROTO_MOBILE 55 /* IP Mobility */
#define IPPROTO_TLSP 56 /* Transport Layer Security */
#define IPPROTO_SKIP 57 /* SKIP */
#define IPPROTO_ICMPV6 58 /* ICMP6 */
#define IPPROTO_NONE 59 /* IP6 no next header */
#define IPPROTO_DSTOPTS 60 /* IP6 destination option */
#define IPPROTO_AHIP 61 /* Any host internal protocol */
#define IPPROTO_CFTP 62 /* CFTP */
#define IPPROTO_HELLO 63 /* "hello" routing protocol */
#define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */
#define IPPROTO_KRYPTOLAN 65 /* Kryptolan */
#define IPPROTO_RVD 66 /* Remote Virtual Disk */
#define IPPROTO_IPPC 67 /* Pluribus Packet Core */
#define IPPROTO_ADFS 68 /* Any distributed FS */
#define IPPROTO_SATMON 69 /* Satnet Monitoring */
#define IPPROTO_VISA 70 /* VISA Protocol */
#define IPPROTO_IPCV 71 /* Packet Core Utility */
#define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */
#define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */
#define IPPROTO_WSN 74 /* Wang Span Network */
#define IPPROTO_PVP 75 /* Packet Video Protocol */
#define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */
#define IPPROTO_ND 77 /* Sun net disk proto (temp.) */
#define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */
#define IPPROTO_WBEXPAK 79 /* WIDEBAND EXPAK */
#define IPPROTO_EON 80 /* ISO cnlp */
#define IPPROTO_VMTP 81 /* VMTP */
#define IPPROTO_SVMTP 82 /* Secure VMTP */
#define IPPROTO_VINES 83 /* Banyon VINES */
#define IPPROTO_TTP 84 /* TTP */
#define IPPROTO_IGP 85 /* NSFNET-IGP */
#define IPPROTO_DGP 86 /* Dissimilar gateway prot. */
#define IPPROTO_TCF 87 /* TCF */
#define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */
#define IPPROTO_OSPFIGP 89 /* OSPFIGP */
#define IPPROTO_SRPC 90 /* Strite RPC protocol */
#define IPPROTO_LARP 91 /* Locus Address Resoloution */
#define IPPROTO_MTP 92 /* Multicast Transport */
#define IPPROTO_AX25 93 /* AX.25 Frames */
#define IPPROTO_IPEIP 94 /* IP encapsulated in IP */
#define IPPROTO_MICP 95 /* Mobile Int.ing control */
#define IPPROTO_SCCSP 96 /* Semaphore Comm. security */
#define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */
#define IPPROTO_ENCAP 98 /* Encapsulation header */
#define IPPROTO_APES 99 /* Aany private encr. scheme */
#define IPPROTO_GMTP 100 /* GMTP*/
#define IPPROTO_IPCOMP 108 /* Payload compression (IPComp) */
/* 101-254: Partly Unassigned */
#define IPPROTO_PIM 103 /* Protocol Independent Mcast */
#define IPPROTO_PGM 113 /* PGM */
/* 255: Reserved */
/* BSD Private, local use, namespace incursion */
#define IPPROTO_DIVERT 254 /* Divert pseudo-protocol */
#define IPPROTO_MAX 256
/* Last return value of *_input(), meaning "all job for this pkt is done". */
#define IPPROTO_DONE 257
/* Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root). (IP_PORTRANGE_LOW) */
#define IPPORT_RESERVED 1024
/* Default local port range, used by both IP_PORTRANGE_DEFAULT and IP_PORTRANGE_HIGH. */
#define IPPORT_HIFIRSTAUTO 49152
#define IPPORT_HILASTAUTO 65535
/*
* Scanning for a free reserved port return a value below IPPORT_RESERVED,
* but higher than IPPORT_RESERVEDSTART. Traditionally the start value was
* 512, but that conflicts with some well-known-services that firewalls may
* have a fit if we use.
*/
#define IPPORT_RESERVEDSTART 600
#define IPPORT_MAX 65535
/*
* Definitions of bits in internet address integers.
* On subnets, the decomposition of addresses to host and net parts
* is done according to subnet mask, not the masks here.
*/
#define IN_CLASSA(i) (((u_int32_t) (i) & 0x80000000) == 0)
#define IN_CLASSA_NET 0xff000000
#define IN_CLASSA_NSHIFT 24
#define IN_CLASSA_HOST 0x00ffffff
#define IN_CLASSA_MAX 128
#define IN_CLASSB(i) (((u_int32_t) (i) & 0xc0000000) == 0x80000000)
#define IN_CLASSB_NET 0xffff0000
#define IN_CLASSB_NSHIFT 16
#define IN_CLASSB_HOST 0x0000ffff
#define IN_CLASSB_MAX 65536
#define IN_CLASSC(i) (((u_int32_t) (i) & 0xe0000000) == 0xc0000000)
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST 0x000000ff
#define IN_CLASSD(i) (((u_int32_t) (i) & 0xf0000000) == 0xe0000000)
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
#define IN_MULTICAST(i) IN_CLASSD(i)
#define IN_EXPERIMENTAL(i) (((u_int32_t) (i) & 0xf0000000) == 0xf0000000)
#define IN_BADCLASS(i) (((u_int32_t) (i) & 0xf0000000) == 0xf0000000)
#define INADDR_LOOPBACK (u_int32_t) 0x7f000001
#define INADDR_NONE 0xffffffff /* -1 return */
#define INADDR_UNSPEC_GROUP (u_int32_t) 0xe0000000 /* 224.0.0.0 */
#define INADDR_ALLHOSTS_GROUP (u_int32_t) 0xe0000001 /* 224.0.0.1 */
#define INADDR_ALLRTRS_GROUP (u_int32_t) 0xe0000002 /* 224.0.0.2 */
#define INADDR_MAX_LOCAL_GROUP (u_int32_t) 0xe00000ff /* 224.0.0.255 */
#define IN_LOOPBACKNET 127 /* Official */
/* Defaults and limits for options */
#define IP_DEFAULT_MULTICAST_TTL 1 /* Normally limit m'casts to 1 hop */
#define IP_DEFAULT_MULTICAST_LOOP 1 /* Normally hear sends if a member */
#define IP_MAX_MEMBERSHIPS 20 /* Per socket */
/* Argument for IP_PORTRANGE - which range to search when port is unspecified at bind() or connect() */
#define IP_PORTRANGE_DEFAULT 0 /* Default range */
#define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
#define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
/*
* Definitions for inet sysctl operations.
*
* Third level is protocol number.
* Fourth level is desired variable within that protocol.
*/
#define IPPROTO_MAXID (IPPROTO_AH + 1) /* Don't list to IPPROTO_MAX */
#define CTL_IPPROTO_NAMES { \
{ "ip", CTLTYPE_NODE }, \
{ "icmp", CTLTYPE_NODE }, \
{ "igmp", CTLTYPE_NODE }, \
{ "ggp", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ "tcp", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ "egp", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ "pup", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ "udp", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ "idp", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ "ipsec", CTLTYPE_NODE }, \
}
/* Names for IP sysctl objects */
#define IPCTL_FORWARDING 1 /* Act as router */
#define IPCTL_SENDREDIRECTS 2 /* May send redirects when forwarding */
#define IPCTL_DEFTTL 3 /* Default TTL */
#ifdef notyet
#define IPCTL_DEFMTU 4 /* Default MTU */
#endif
#define IPCTL_RTEXPIRE 5 /* Cloned route expiration time */
#define IPCTL_RTMINEXPIRE 6 /* Min value for expiration time */
#define IPCTL_RTMAXCACHE 7 /* Trigger level for dynamic expire */
#define IPCTL_SOURCEROUTE 8 /* May perform source routes */
#define IPCTL_DIRECTEDBROADCAST 9 /* May re-broadcast received packets */
#define IPCTL_INTRQMAXLEN 10 /* Max length of netisr queue */
#define IPCTL_INTRQDROPS 11 /* Number of netisr q drops */
#define IPCTL_STATS 12 /* Ipstat structure */
#define IPCTL_ACCEPTSOURCEROUTE 13 /* May accept source routed packets */
#define IPCTL_FASTFORWARDING 14 /* Use fast IP forwarding code */
#define IPCTL_KEEPFAITH 15 /* FAITH IPv4->IPv6 translater ctl */
#define IPCTL_GIF_TTL 16 /* Default TTL for gif encap packet */
#define IPCTL_MAXID 17
#define IPCTL_NAMES { \
{ 0, 0 }, \
{ "forwarding", CTLTYPE_INT }, \
{ "redirect", CTLTYPE_INT }, \
{ "ttl", CTLTYPE_INT }, \
{ "mtu", CTLTYPE_INT }, \
{ "rtexpire", CTLTYPE_INT }, \
{ "rtminexpire", CTLTYPE_INT }, \
{ "rtmaxcache", CTLTYPE_INT }, \
{ "sourceroute", CTLTYPE_INT }, \
{ "directed-broadcast", CTLTYPE_INT }, \
{ "intr-queue-maxlen", CTLTYPE_INT }, \
{ "intr-queue-drops", CTLTYPE_INT }, \
{ "stats", CTLTYPE_STRUCT }, \
{ "accept_sourceroute", CTLTYPE_INT }, \
{ "fastforwarding", CTLTYPE_INT }, \
}
#endif

View File

@ -1,53 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)in_systm.h 8.1 (Berkeley) 6/10/93
* $FreeBSD: src/sys/netinet/in_systm.h,v 1.10 2002/03/19 21:25:46 alfred Exp $
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#ifndef _NETINET_IN_SYSTM_H
#define _NETINET_IN_SYSTM_H
#include <sys/types.h>
/*
* Network types.
*
* Internally the system keeps counters in the headers with the bytes
* swapped so that VAX instructions will work on them. It reverses
* the bytes before transmission at each protocol level. The n_ types
* represent the types with the bytes in ``high-ender'' order.
*/
typedef u_int16_t n_short; /* short as received from the net */
typedef u_int32_t n_long; /* long as received from the net */
typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */
#endif

View File

@ -1,176 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)ip.h 8.2 (Berkeley) 6/1/94
* $FreeBSD: src/sys/netinet/ip.h,v 1.19 2001/12/14 19:37:32 rwatson Exp $
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#ifndef _NETINET_IP_H
#define _NETINET_IP_H
#include <netinet/in_systm.h>
/* Definitions for internet protocol version 4. Per RFC 791, September 1981. */
#define IPVERSION 4
/* Structure of an internet header, naked of options. */
struct ip {
#ifdef _IP_VHL
u_char ip_vhl; /* version << 4 | header length >> 2 */
#else
#if BYTE_ORDER == LITTLE_ENDIAN
u_int ip_hl: 4, /* header length */
ip_v: 4; /* version */
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_int ip_v: 4, /* version */
ip_hl: 4; /* header length */
#endif
#endif /* not _IP_VHL */
u_char ip_tos; /* type of service */
u_short ip_len; /* total length */
u_short ip_id; /* identification */
u_short ip_off; /* fragment offset field */
#define IP_RF 0x8000 /* reserved fragment flag */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
u_char ip_ttl; /* time to live */
u_char ip_p; /* protocol */
u_short ip_sum; /* checksum */
struct in_addr ip_src, ip_dst; /* source and dest address */
};
#ifdef _IP_VHL
#define IP_MAKE_VHL(v, hl) ((v) << 4 | (hl))
#define IP_VHL_HL(vhl) ((vhl) & 0x0f)
#define IP_VHL_V(vhl) ((vhl) >> 4)
#define IP_VHL_BORING 0x45
#endif
#define IP_MAXPACKET 65535 /* maximum packet size */
/*
* Definitions for IP type of service (ip_tos)
*/
#define IPTOS_LOWDELAY 0x10
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_RELIABILITY 0x04
#define IPTOS_MINCOST 0x02
/* ECN bits proposed by Sally Floyd */
#define IPTOS_CE 0x01 /* congestion experienced */
#define IPTOS_ECT 0x02 /* ECN-capable transport */
/*
* Definitions for IP precedence (also in ip_tos) (hopefully unused)
*/
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/* Definitions for options. */
#define IPOPT_COPIED(o) ((o)&0x80)
#define IPOPT_CLASS(o) ((o)&0x60)
#define IPOPT_NUMBER(o) ((o)&0x1f)
#define IPOPT_CONTROL 0x00
#define IPOPT_RESERVED1 0x20
#define IPOPT_DEBMEAS 0x40
#define IPOPT_RESERVED2 0x60
#define IPOPT_EOL 0 /* end of option list */
#define IPOPT_NOP 1 /* no operation */
#define IPOPT_RR 7 /* record packet route */
#define IPOPT_TS 68 /* timestamp */
#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
#define IPOPT_LSRR 131 /* loose source route */
#define IPOPT_ESO 133 /* extended security */
#define IPOPT_CIPSO 134 /* commerical security */
#define IPOPT_SATID 136 /* satnet id */
#define IPOPT_SSRR 137 /* strict source route */
#define IPOPT_RA 148 /* router alert */
/* Offsets to fields in options other than EOL and NOP. */
#define IPOPT_OPTVAL 0 /* option ID */
#define IPOPT_OLEN 1 /* option length */
#define IPOPT_OFFSET 2 /* offset within option */
#define IPOPT_MINOFF 4 /* min value of above */
/* Time stamp option structure. */
struct ip_timestamp {
u_char ipt_code; /* IPOPT_TS */
u_char ipt_len; /* size of structure (variable) */
u_char ipt_ptr; /* index of current entry */
#if BYTE_ORDER == LITTLE_ENDIAN
u_int ipt_flg: 4, /* flags, see below */
ipt_oflw: 4; /* overflow counter */
#endif
#if BYTE_ORDER == BIG_ENDIAN
u_int ipt_oflw: 4, /* overflow counter */
ipt_flg: 4; /* flags, see below */
#endif
union ipt_timestamp {
n_long ipt_time[1];
struct ipt_ta {
struct in_addr ipt_addr;
n_long ipt_time;
} ipt_ta[1];
} ipt_timestamp;
};
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
/* bits for security (not byte swapped) */
#define IPOPT_SECUR_UNCLASS 0x0000
#define IPOPT_SECUR_CONFID 0xf135
#define IPOPT_SECUR_EFTO 0x789a
#define IPOPT_SECUR_MMMM 0xbc4d
#define IPOPT_SECUR_RESTR 0xaf13
#define IPOPT_SECUR_SECRET 0xd788
#define IPOPT_SECUR_TOPSECRET 0x6bc5
/* Internet implementation parameters. */
#define MAXTTL 255 /* maximum time to live (seconds) */
#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
#define IPFRAGTTL 60 /* time to live for frags, slowhz */
#define IPTTLDEC 1 /* subtracted when forwarding */
#define IP_MSS 576 /* default maximum segment size */
#endif

View File

@ -1,420 +0,0 @@
/* $FreeBSD: src/sys/netinet6/in6.h,v 1.19 2002/04/19 04:46:22 suz Exp $ */
/* $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* 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.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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.
*/
/*
* Copyright (c) 1982, 1986, 1990, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)in.h 8.3 (Berkeley) 1/3/94
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#ifndef _NETINET6_IN6_H
#define _NETINET6_IN6_H
#include <phoenix/netinet6.h>
#include <sys/types.h>
/*
* Identification of the network protocol stack
* for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
* has the table of implementation/integration differences.
*/
#define __KAME__
#define __KAME_VERSION "20010528/FreeBSD"
/*
* Local port number conventions:
*
* Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
* unless a kernel is compiled with IPNOPRIVPORTS defined.
*
* When a user does a bind(2) or connect(2) with a port number of zero,
* a non-conflicting local port address is chosen.
*
* The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
* that is settable by sysctl(3); net.inet.ip.anonportmin and
* net.inet.ip.anonportmax respectively.
*
* A user may set the IPPROTO_IP option IP_PORTRANGE to change this
* default assignment range.
*
* The value IP_PORTRANGE_DEFAULT causes the default behavior.
*
* The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
* and exists only for FreeBSD compatibility purposes.
*
* The value IP_PORTRANGE_LOW changes the range to the "low" are
* that is (by convention) restricted to privileged processes.
* This convention is based on "vouchsafe" principles only.
* It is only secure if you trust the remote host to restrict these ports.
* The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
*/
#define IPV6PORT_RESERVED 1024
#define IPV6PORT_ANONMIN 49152
#define IPV6PORT_ANONMAX 65535
#define IPV6PORT_RESERVEDMIN 600
#define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1)
/* Socket address for IPv6 */
#ifndef _XOPEN_SOURCE
#define SIN6_LEN
#endif
/* Definition of some useful macros to handle IP6 addresses */
#define IN6ADDR_ANY_INIT \
{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
#define IN6ADDR_LOOPBACK_INIT \
{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
#define IN6ADDR_NODELOCAL_ALLNODES_INIT \
{{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
{{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
extern const struct in6_addr in6addr_any;
extern const struct in6_addr in6addr_loopback;
extern const struct in6_addr in6addr_nodelocal_allnodes;
extern const struct in6_addr in6addr_linklocal_allnodes;
extern const struct in6_addr in6addr_linklocal_allrouters;
/*
* Equality
* NOTE: Some of kernel programming environment (for example, openbsd/sparc)
* does not supply memcmp(). For userland memcmp() is preferred as it is
* in ANSI standard.
*/
#define IN6_ARE_ADDR_EQUAL(a, b) (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
/* Unspecified */
#define IN6_IS_ADDR_UNSPECIFIED(a) \
((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
/* Loopback */
#define IN6_IS_ADDR_LOOPBACK(a) \
((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))
/* IPv4 compatible */
#define IN6_IS_ADDR_V4COMPAT(a) \
((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1)))
/* Mapped */
#define IN6_IS_ADDR_V4MAPPED(a) \
((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
/* KAME Scope Values */
#define __IPV6_ADDR_SCOPE_NODELOCAL 0x01
#define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02
#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */
#define __IPV6_ADDR_SCOPE_GLOBAL 0x0e
/*
* Unicast Scope
* Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
*/
#define IN6_IS_ADDR_LINKLOCAL(a) \
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
#define IN6_IS_ADDR_SITELOCAL(a) \
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
/* Multicast */
#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
/* Multicast Scope */
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
#define IN6_IS_ADDR_MC_GLOBAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && \
(__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
/* IP6 route structure */
#ifndef _XOPEN_SOURCE
struct route_in6 {
struct rtentry *ro_rt;
struct sockaddr_in6 ro_dst;
};
#endif
/*
* Options for use with [gs]etsockopt at the IPV6 level.
* First word of comment is data type; bool is stored in int.
*/
#define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */
#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
#define IPV6_MULTICAST_IF 9 /* u_char; set/get IP6 multicast i/f */
#define IPV6_MULTICAST_HOPS 10 /* u_char; set/get IP6 multicast hops */
#define IPV6_MULTICAST_LOOP 11 /* u_char; set/get IP6 multicast loopback */
#define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */
#define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */
#define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */
#define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */
/* RFC2292 options */
#define IPV6_PKTINFO 19 /* bool; send/recv if, src/dst addr */
#define IPV6_HOPLIMIT 20 /* bool; hop limit */
#define IPV6_NEXTHOP 21 /* bool; next hop addr */
#define IPV6_HOPOPTS 22 /* bool; hop-by-hop option */
#define IPV6_DSTOPTS 23 /* bool; destination option */
#define IPV6_RTHDR 24 /* bool; routing header */
#define IPV6_PKTOPTIONS 25 /* buf/cmsghdr; set/get IPv6 options */
#define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */
#define IPV6_V6ONLY 27 /* bool; only bind INET6 at wildcard bind */
#define IPV6_BINDV6ONLY IPV6_V6ONLY
#define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */
#define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */
#define IPV6_FW_ADD 30 /* add a firewall rule to chain */
#define IPV6_FW_DEL 31 /* delete a firewall rule from chain */
#define IPV6_FW_FLUSH 32 /* flush firewall rule chain */
#define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */
#define IPV6_FW_GET 34 /* get entire firewall rule chain */
/* to define items, should talk with KAME guys first, for *BSD compatibility */
#define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */
#define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */
#define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */
/* Defaults and limits for options */
#define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */
#define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
/* Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. */
struct ipv6_mreq {
struct in6_addr ipv6mr_multiaddr;
unsigned int ipv6mr_interface;
};
/* IPV6_PKTINFO: Packet information(RFC2292 sec 5) */
struct in6_pktinfo {
struct in6_addr ipi6_addr; /* src/dst IPv6 address */
unsigned int ipi6_ifindex; /* send/recv interface index */
};
/*
* Argument for IPV6_PORTRANGE:
* - which range to search when port is unspecified at bind() or connect()
*/
#define IPV6_PORTRANGE_DEFAULT 0 /* default range */
#define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
#define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
#ifndef _XOPEN_SOURCE
/*
* Definitions for inet6 sysctl operations.
*
* Third level is protocol number.
* Fourth level is desired variable within that protocol.
*/
#define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */
#define CTL_IPV6PROTO_NAMES { \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, \
{ "tcp6", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ "udp6", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, \
{ "ip6", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, \
{ "ipsec6", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ "icmp6", CTLTYPE_NODE }, \
{ 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ 0, 0 }, \
{ "pim6", CTLTYPE_NODE }, \
}
/*
* Names for IP sysctl objects
*/
#define IPV6CTL_FORWARDING 1 /* act as router */
#define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding */
#define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */
#ifdef notyet
#define IPV6CTL_DEFMTU 4 /* default MTU */
#endif
#define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */
#define IPV6CTL_STATS 6 /* stats */
#define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */
#define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */
#define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */
#define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */
#define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */
#define IPV6CTL_ACCEPT_RTADV 12
#define IPV6CTL_KEEPFAITH 13
#define IPV6CTL_LOG_INTERVAL 14
#define IPV6CTL_HDRNESTLIMIT 15
#define IPV6CTL_DAD_COUNT 16
#define IPV6CTL_AUTO_FLOWLABEL 17
#define IPV6CTL_DEFMCASTHLIM 18
#define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */
#define IPV6CTL_KAME_VERSION 20
#define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */
#define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */
#define IPV6CTL_V6ONLY 24
#define IPV6CTL_RTEXPIRE 25 /* cloned route expiration time */
#define IPV6CTL_RTMINEXPIRE 26 /* min value for expiration time */
#define IPV6CTL_RTMAXCACHE 27 /* trigger level for dynamic expire */
#define IPV6CTL_USETEMPADDR 32 /* use temporary addresses (RFC3041) */
#define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */
#define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */
#define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */
#define IPV6CTL_RIP6STATS 36 /* raw_ip6 stats */
/* New entries should be added here from current IPV6CTL_MAXID value. */
/* to define items, should talk with KAME guys first, for *BSD compatibility */
#define IPV6CTL_MAXID 37
#endif /* !_XOPEN_SOURCE */
/* Redefinition of mbuf flags */
#define M_AUTHIPHDR M_PROTO2
#define M_DECRYPTED M_PROTO3
#define M_LOOP M_PROTO4
#define M_AUTHIPDGM M_PROTO5
struct cmsghdr;
int inet6_option_space(int);
int inet6_option_init(void *, struct cmsghdr **, int);
int inet6_option_append(struct cmsghdr *, const uint8_t *, int, int);
uint8_t *inet6_option_alloc(struct cmsghdr *, int, int, int);
int inet6_option_next(const struct cmsghdr *, uint8_t **);
int inet6_option_find(const struct cmsghdr *, uint8_t **, int);
size_t inet6_rthdr_space(int, int);
struct cmsghdr *inet6_rthdr_init(void *, int);
int inet6_rthdr_add(struct cmsghdr *, const struct in6_addr *, unsigned int);
int inet6_rthdr_lasthop(struct cmsghdr *, unsigned int);
int inet6_rthdr_segments(const struct cmsghdr *);
struct in6_addr *inet6_rthdr_getaddr(struct cmsghdr *, int);
int inet6_rthdr_getflags(const struct cmsghdr *, int);
int inet6_opt_init(void *, size_t);
int inet6_opt_append(void *, size_t, int, uint8_t, size_t, uint8_t, void **);
int inet6_opt_finish(void *, size_t, int);
int inet6_opt_set_val(void *, size_t, void *, int);
int inet6_opt_next(void *, size_t, int, uint8_t *, size_t *, void **);
int inet6_opt_find(void *, size_t, int, uint8_t, size_t *, void **);
int inet6_opt_get_val(void *, size_t, void *, int);
size_t inet6_rth_space(int, int);
void *inet6_rth_init(void *, int, int, int);
int inet6_rth_add(void *, const struct in6_addr *);
int inet6_rth_reverse(const void *, void *);
int inet6_rth_segments(const void *);
struct in6_addr *inet6_rth_getaddr(const void *, int);
#endif

View File

@ -1,63 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef NETPACKET_PACKET_H
#define NETPACKET_PACKET_H
struct sockaddr_ll {
unsigned short int sll_family;
unsigned short int sll_protocol;
int sll_ifindex;
unsigned short int sll_hatype;
unsigned char sll_pkttype;
unsigned char sll_halen;
unsigned char sll_addr[8];
};
#define PACKET_ADD_MEMBERSHIP 1
#define PACKET_DROP_MEMBERSHIP 2
#define PACKET_RECV_OUTPUT 3
#define PACKET_RX_RING 5
#define PACKET_STATISTICS 6
#define PACKET_HOST 0
#define PACKET_BROADCAST 1
#define PACKET_MULTICAST 2
#define PACKET_OTHERHOST 3
#define PACKET_OUTGOING 4
#define PACKET_LOOPBACK 5
#define PACKET_FASTROUTE 6
struct packet_mreq {
int mr_ifindex;
unsigned short int mr_type;
unsigned short int mr_alen;
unsigned char mr_address[8];
};
#define PACKET_MR_MULTICAST 0
#define PACKET_MR_PROMISC 1
#define PACKET_MR_ALLMULTI 2
#endif

View File

@ -1,30 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef POLL_H
#define POLL_H
#include <sys/poll.h>
#endif

View File

@ -1,52 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef SEMAPHORE_H
#define SEMAPHORE_H
#include <time.h>
/* System specific semaphore definition. */
typedef struct {
int fd;
} sem_t;
/* Value returned if `sem_open' failed. */
#define SEM_FAILED ((sem_t *) 0)
/* Maximum value the semaphore can have. */
#define SEM_VALUE_MAX (2147483647)
int sem_init(sem_t *sem, int pshared, unsigned int value);
int sem_destroy(sem_t *sem);
sem_t *sem_open(const char *name, int oflag, ...);
int sem_close(sem_t *sem);
int sem_unlink(const char *name);
int sem_wait(sem_t *sem);
int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
int sem_trywait(sem_t *sem);
int sem_post(sem_t *sem);
int sem_getvalue(sem_t * sem, int *sval);
#endif

View File

@ -1,143 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef SYSLOG_H
#define SYSLOG_H
#include <stdlib.h>
#define LOG_EMERG 0 /* System is unusable */
#define LOG_ALERT 1 /* Action must be taken immediately */
#define LOG_CRIT 2 /* Critical conditions */
#define LOG_ERR 3 /* Error conditions */
#define LOG_WARNING 4 /* Warning conditions */
#define LOG_NOTICE 5 /* Normal but significant condition */
#define LOG_INFO 6 /* Informational */
#define LOG_DEBUG 7 /* Debug-level messages */
#define LOG_PRIMASK 0x07 /* Mask to extract priority part (internal) */
#define LOG_PRI(p) ((p) & LOG_PRIMASK) /* Extract priority */
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
#ifdef SYSLOG_NAMES
#define INTERNAL_NOPRI 0x10 /* The "no priority" priority */
#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) /* Mark "facility" */
typedef struct _code {
char *c_name;
int c_val;
} CODE;
CODE prioritynames[] = {
"alert", LOG_ALERT,
"crit", LOG_CRIT,
"debug", LOG_DEBUG,
"emerg", LOG_EMERG,
"err", LOG_ERR,
"error", LOG_ERR, /* DEPRECATED */
"info", LOG_INFO,
"none", INTERNAL_NOPRI, /* INTERNAL */
"notice", LOG_NOTICE,
"panic", LOG_EMERG, /* DEPRECATED */
"warn", LOG_WARNING, /* DEPRECATED */
"warning", LOG_WARNING,
NULL, -1,
};
#endif
/* Facility codes */
#define LOG_KERN (0 << 3) /* Kernel messages */
#define LOG_USER (1 << 3) /* Random user-level messages */
#define LOG_MAIL (2 << 3) /* Mail system */
#define LOG_DAEMON (3 << 3) /* System daemons */
#define LOG_AUTH (4 << 3) /* Security/authorization messages */
#define LOG_SYSLOG (5 << 3) /* Messages generated internally by syslogd */
#define LOG_LPR (6 << 3) /* Line printer subsystem */
#define LOG_NEWS (7 << 3) /* Network news subsystem */
#define LOG_UUCP (8 << 3) /* UUCP subsystem */
#define LOG_CRON (9 << 3) /* Clock daemon */
#define LOG_AUTHPRIV (10 << 3) /* Security/authorization messages (private) */
/* Other codes through 15 reserved for system use */
#define LOG_LOCAL0 (16 << 3) /* Reserved for local use */
#define LOG_LOCAL1 (17 << 3) /* Reserved for local use */
#define LOG_LOCAL2 (18 << 3) /* Reserved for local use */
#define LOG_LOCAL3 (19 << 3) /* Reserved for local use */
#define LOG_LOCAL4 (20 << 3) /* Reserved for local use */
#define LOG_LOCAL5 (21 << 3) /* Reserved for local use */
#define LOG_LOCAL6 (22 << 3) /* Reserved for local use */
#define LOG_LOCAL7 (23 << 3) /* Reserved for local use */
#define LOG_NFACILITIES 24 /* Current number of facilities */
#define LOG_FACMASK 0x03f8 /* Mask to extract facility part */
#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) /* Facility of pri */
#ifdef SYSLOG_NAMES
CODE facilitynames[] = {
"auth", LOG_AUTH,
"authpriv", LOG_AUTHPRIV,
"cron", LOG_CRON,
"daemon", LOG_DAEMON,
"kern", LOG_KERN,
"lpr", LOG_LPR,
"mail", LOG_MAIL,
"mark", INTERNAL_MARK, /* INTERNAL */
"news", LOG_NEWS,
"security", LOG_AUTH, /* DEPRECATED */
"syslog", LOG_SYSLOG,
"user", LOG_USER,
"uucp", LOG_UUCP,
"local0", LOG_LOCAL0,
"local1", LOG_LOCAL1,
"local2", LOG_LOCAL2,
"local3", LOG_LOCAL3,
"local4", LOG_LOCAL4,
"local5", LOG_LOCAL5,
"local6", LOG_LOCAL6,
"local7", LOG_LOCAL7,
NULL, -1,
};
#endif
/* Arguments to setlogmask */
#define LOG_MASK(pri) (1 << (pri)) /* Mask for one priority */
#define LOG_UPTO(pri) ((1 << ((pri) + 1)) - 1) /* All priorities through pri */
/*
* Option flags for openlog.
*
* LOG_ODELAY no longer does anything.
* LOG_NDELAY is the inverse of what it used to be.
*/
#define LOG_PID 0x01 /* Log the pid with each message */
#define LOG_CONS 0x02 /* Log on the console if errors in sending */
#define LOG_ODELAY 0x04 /* Delay open until first syslog() (default) */
#define LOG_NDELAY 0x08 /* Don't delay open */
#define LOG_NOWAIT 0x10 /* Don't wait for console forks: DEPRECATED */
#define LOG_PERROR 0x20 /* Log to stderr as well */
void openlog(const char *ident, int option, int facility);
void syslog(int priority, const char *format, ...);
void closelog();
#endif

View File

@ -1,68 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef TIME_H
#define TIME_H
#include <_ansi.h>
#include <phoenix/time.h>
#include <sys/reent.h>
#include <sys/time.h>
#include <sys/types.h>
extern int _daylight;
extern long _timezone;
extern char *_tzname[2];
/* POSIX defines the external tzname being defined in time.h */
#ifndef tzname
#define tzname _tzname
#endif
void tzset();
clock_t clock();
int clock_gettime(clockid_t clock_id, struct timespec *tp);
int clock_settime(clockid_t clock_id, const struct timespec *tp);
int clock_getres(clockid_t clock_id, struct timespec *res);
double difftime(time_t time1, time_t time0);
time_t mktime(struct tm *tm);
time_t time(time_t *t);
char *asctime(const struct tm *tm);
char *ctime(const time_t *timep);
struct tm *gmtime(const time_t *timep);
struct tm *localtime(const time_t *timep);
char *asctime_r(const struct tm *tm, char *buf);
char *ctime_r(const time_t *timep, char *buf);
struct tm *gmtime_r(const time_t *timep, struct tm *result);
struct tm *localtime_r(const time_t *timep, struct tm *result);
size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);
int nanosleep(const struct timespec *req, struct timespec *rem);
#endif

View File

@ -1,100 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
int open(const char *pathname, int flags, ...)
{
int mode = S_IFREG | S_IRWXUGO;
if (flags & O_CREAT) {
va_list arg;
va_start(arg, flags);
mode = va_arg(arg, int);
va_end(arg);
}
int ret = syscall3(int, SYS_OPEN, pathname, flags, mode);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
ssize_t read(int fd, void *buf, size_t count)
{
int ret = syscall3(int, SYS_READ, fd, buf, count);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
ssize_t write(int fd, const void *buf, size_t count)
{
int ret = syscall3(int, SYS_WRITE, fd, buf, count);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
off_t lseek(int fd, off_t offset, int whence)
{
int ret = syscall3(int, SYS_LSEEK, fd, offset, whence);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int close(int fd)
{
int ret = syscall1(int, SYS_CLOSE, fd);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int _close(int fd)
{
return close(fd);
}

View File

@ -1,43 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <stdarg.h>
int ioctl(int d, int request, ...)
{
va_list ap;
va_start(ap, request);
int ret = syscall3(int, SYS_IOCTL, d, request, va_arg(ap, void *));
va_end(ap);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1 +0,0 @@
libc_a_SOURCES += %D%/syscall.S

View File

@ -1,54 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
.syntax unified
.section .text, "ax"
.global _start
.global main
.global exit
.global environ
.global __progname
.align 4
_start:
/* Ignore return address passed on the top of stack. */
pop {lr}
ldmfd sp, {r0-r2}
ldr r3, =environ
ldr r4, =__progname
ldr r5, [r1]
str r2, [r3]
str r5, [r4]
/* Align stack. */
bic sp, #0x00000007
ldr lr, =main
blx lr
ldr lr, =exit
blx lr
.section .data
__progname:
.word 0

View File

@ -1,52 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
.thumb
.syntax unified
.section .text, "ax"
.global _syscall5
.global _syscall3
.global hal_cpuRestoreCtx
.type _syscall5, %function
.func _syscall5
_syscall5:
push {r4, r5}
ldr r4, [sp, #8]
ldr r5, [sp, #12]
svc #255
pop {r4, r5}
bx lr
.endfunc
.type _syscall3, %function
.func _syscall3
_syscall3:
svc #255
bx lr
.endfunc
.end

View File

@ -1,86 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <malloc.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
void *ret = NULL;
MmapArg_t arg = {
.fd = fd,
.addr = addr,
.pflags = prot,
.mflags = flags,
.offs = offset,
.len = length,
.raddr = &ret
};
struct stat st;
if (fstat(fd, &st) < 0)
return NULL;
if (st.st_mode & S_IFREG) {
if (prot != PROT_READ) {
errno = ENOSYS;
return MAP_FAILED;
}
if ((ret = malloc(length)) == 0) {
errno = ENOMEM;
return MAP_FAILED;
}
if (pread(fd, ret, length, offset) < 0) {
free(ret);
return MAP_FAILED;
}
}
else {
int err = syscall1(int, SYS_MMAP, &arg);
if(err < 0) {
errno = -err;
return MAP_FAILED;
}
}
return ret;
}
int munmap(void *addr, size_t length)
{
int ret = syscall2(int, SYS_MUNMAP, addr, length);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,54 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data)
{
int ret = syscall5(int, SYS_MOUNT, source, target, filesystemtype, mountflags, data);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int umount2(const char *target, int flags)
{
int ret = syscall2(int, SYS_UMOUNT, target, flags);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int umount(const char *target)
{
return umount2(target, 0);
}

View File

@ -1,40 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
int nanosleep(const struct timespec *req, struct timespec *rem)
{
int ret = syscall2(int, SYS_NANOSLEEP, req, rem);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,52 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#define NAME_GET 0
#define NAME_SET 1
int getdomainname(char *name, size_t len)
{
int ret = syscall3(int, SYS_DOMAINNAME, name, len, NAME_GET);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int setdomainname(const char *name, size_t len)
{
int ret = syscall3(int, SYS_DOMAINNAME, name, len, NAME_SET);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,52 +0,0 @@
/* The Inner Net License, Version 2.00
The author(s) grant permission for redistribution and use in source and
binary forms, with or without modification, of the software and documentation
provided that the following conditions are met:
0. If you receive a version of the software that is specifically labelled
as not being for redistribution (check the version message and/or README),
you are not permitted to redistribute that version of the software in any
way or form.
1. All terms of the all other applicable copyrights and licenses must be
followed.
2. Redistributions of source code must retain the authors' copyright
notice(s), this list of conditions, and the following disclaimer.
3. Redistributions in binary form must reproduce the authors' copyright
notice(s), this list of conditions, and the following disclaimer in the
documentation and/or other materials provided with the distribution.
4. [The copyright holder has authorized the removal of this clause.]
5. Neither the name(s) of the author(s) nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ITS AUTHORS 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 AUTHORS 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.
If these license terms cause you a real problem, contact the author. */
/* This software is Copyright 1996 by Craig Metz, All Rights Reserved. */
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <malloc.h>
#include <netdb.h>
#include <stdio.h>
void freeaddrinfo(struct addrinfo *res)
{
while (res != NULL) {
struct addrinfo *p = res;
res = res->ai_next;
free(p->ai_canonname);
free(p);
}
}

View File

@ -1,185 +0,0 @@
/*
* Mar 8, 2000 by Hajimu UMEMOTO <ume@mahoroba.org>
* $Id: getaddrinfo.c,v 1.2 2002/05/22 17:56:56 snsimon Exp $
*
* This module is besed on ssh-1.2.27-IPv6-1.5 written by
* KIKUCHI Takahiro <kick@kyoto.wide.ad.jp>
*/
/*
* Copyright (c) 2001 Carnegie Mellon University. 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.
*
* 3. The name "Carnegie Mellon University" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For permission or any other legal
* details, please contact
* Office of Technology Transfer
* Carnegie Mellon University
* 5000 Forbes Avenue
* Pittsburgh, PA 15213-3890
* (412) 268-4387, fax: (412) 268-7395
* tech-transfer@andrew.cmu.edu
*
* 4. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by Computing Services
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
*
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
* FOR ANY SPECIAL, 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.
*/
/*
* fake library for ssh
*
* This file includes getaddrinfo(), freeaddrinfo() and gai_strerror().
* These funtions are defined in rfc2133.
*
* But these functions are not implemented correctly. The minimum subset
* is implemented for ssh use only. For example, this routine assumes
* that ai_family is AF_INET. Don't use it for another purpose.
*
* In the case not using 'configure --enable-ipv6', this getaddrinfo.c
* will be used if you have broken getaddrinfo or no getaddrinfo.
*/
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
static struct addrinfo *malloc_ai(int port, u_long addr, int socktype, int proto)
{
struct addrinfo *ai = (struct addrinfo *)malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
if (ai) {
memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
ai->ai_addr = (struct sockaddr *)(ai + 1);
/* XXX -- ssh doesn't use sa_len */
ai->ai_addrlen = sizeof(struct sockaddr_in);
#ifdef HAVE_SOCKADDR_SA_LEN
ai->ai_addr->sa_len = sizeof(struct sockaddr_in);
#endif
ai->ai_addr->sa_family = ai->ai_family = AF_INET;
((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port;
((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
ai->ai_socktype = socktype;
ai->ai_protocol = proto;
return ai;
}
return NULL;
}
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
{
struct addrinfo *cur, *prev = NULL;
struct hostent *hp;
struct in_addr in;
int i, port = 0, socktype, proto;
if (hints && hints->ai_family != PF_INET && hints->ai_family != PF_UNSPEC)
return EAI_FAMILY;
socktype = (hints && hints->ai_socktype) ? hints->ai_socktype : SOCK_STREAM;
if (hints && hints->ai_protocol)
proto = hints->ai_protocol;
else {
switch (socktype) {
case SOCK_DGRAM:
proto = IPPROTO_UDP;
break;
case SOCK_STREAM:
proto = IPPROTO_TCP;
break;
default:
proto = 0;
break;
}
}
if (service) {
if (isdigit((int)*service))
port = htons(atoi(service));
else {
struct servent *se;
char *pe_proto;
switch (socktype) {
case SOCK_DGRAM:
pe_proto = "udp";
break;
case SOCK_STREAM:
pe_proto = "tcp";
break;
default:
pe_proto = NULL;
break;
}
if ((se = getservbyname(service, pe_proto)) == NULL)
return EAI_SERVICE;
port = se->s_port;
}
}
if (!node) {
if (hints && hints->ai_flags & AI_PASSIVE)
*res = malloc_ai(port, htonl(0x00000000), socktype, proto);
else
*res = malloc_ai(port, htonl(0x7f000001), socktype, proto);
if (*res)
return 0;
else
return EAI_MEMORY;
}
if (inet_aton(node, &in)) {
*res = malloc_ai(port, in.s_addr, socktype, proto);
if (*res)
return 0;
else
return EAI_MEMORY;
}
if (hints && hints->ai_flags & AI_NUMERICHOST)
return EAI_NODATA;
if ((hp = gethostbyname(node)) && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
for (i = 0; hp->h_addr_list[i]; i++) {
if ((cur = malloc_ai(port, ((struct in_addr *)hp->h_addr_list[i])->s_addr, socktype, proto)) == NULL) {
if (*res)
freeaddrinfo(*res);
return EAI_MEMORY;
}
if (prev)
prev->ai_next = cur;
else
*res = cur;
prev = cur;
}
if (hints && hints->ai_flags & AI_CANONNAME && *res) {
/* NOT sasl_strdup for compatibility */
if (((*res)->ai_canonname = strdup(hp->h_name)) == NULL) {
freeaddrinfo(*res);
return EAI_MEMORY;
}
}
return 0;
}
return EAI_NODATA;
}

View File

@ -1,33 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <netdb.h>
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type)
{
/* TODO: implement. */
errno = ENOSYS;
return NULL;
}

View File

@ -1,33 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <netdb.h>
struct hostent *gethostbyname(const char *name)
{
/* TODO: implement. */
errno = ENOSYS;
return NULL;
}

View File

@ -1,33 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <netdb.h>
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
{
/* TODO: implement. */
errno = ENOSYS;
return EAI_SYSTEM;
}

View File

@ -1,33 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <netdb.h>
struct servent *getservbyname(const char *name, const char *proto)
{
/* TODO: implement. */
errno = ENOSYS;
return NULL;
}

View File

@ -1,33 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <netdb.h>
struct servent *getservbyport(int port, const char *proto)
{
/* TODO: implement. */
errno = ENOSYS;
return NULL;
}

View File

@ -1,38 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <netdb.h>
#include <reent.h>
const char *hstrerror(int err)
{
errno = ENOSYS;
return NULL;
}
int *__h_errno_location()
{
return &(_REENT->_new._reent._h_errno);
}

View File

@ -1,52 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#define NAME_GET 0
#define NAME_SET 1
int gethostname(char *name, size_t len)
{
int ret = syscall3(int, SYS_HOSTNAME, name, len, NAME_GET);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int sethostname(const char *name, size_t len)
{
int ret = syscall3(int, SYS_HOSTNAME, name, len, NAME_SET);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,66 +0,0 @@
/* $KAME: inet_addr.c,v 1.5 2001/08/20 02:32:40 itojun Exp $ */
/*
* ++Copyright++ 1983, 1990, 1993
* -
* Copyright (c) 1983, 1990, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* 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, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION 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.
* -
* --Copyright--
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
in_addr_t inet_addr(const char *cp)
{
struct in_addr val;
if (inet_aton(cp, &val))
return val.s_addr;
return INADDR_NONE;
}

View File

@ -1,163 +0,0 @@
/* $KAME: inet_addr.c,v 1.5 2001/08/20 02:32:40 itojun Exp $ */
/*
* ++Copyright++ 1983, 1990, 1993
* -
* Copyright (c) 1983, 1990, 1993
* The Regents of the University of California. 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
* -
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* 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, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION 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.
* -
* --Copyright--
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdlib.h>
int inet_aton(const char *cp, struct in_addr *inp)
{
u_long parts[4];
in_addr_t val;
char *c;
char *endptr;
int gotend, n;
c = (char *)cp;
n = 0;
/*
* Run through the string, grabbing numbers until
* the end of the string, or some error
*/
gotend = 0;
while (!gotend) {
errno = 0;
val = strtoul(c, &endptr, 0);
if (errno == ERANGE) /* Fail completely if it overflowed. */
return 0;
/*
* If the whole string is invalid, endptr will equal
* c.. this way we can make sure someone hasn't
* gone '.12' or something which would get past
* the next check.
*/
if (endptr == c)
return 0;
parts[n] = val;
c = endptr;
/* Check the next character past the previous number's end */
switch (*c) {
case '.':
/* Make sure we only do 3 dots .. */
if (n == 3) /* Whoops. Quit. */
return 0;
n++;
c++;
break;
case '\0':
gotend = 1;
break;
default:
if (isspace((unsigned char)*c)) {
gotend = 1;
break;
}
else
return 0; /* Invalid character, so fail */
}
}
/*
* Concoct the address according to
* the number of parts specified.
*/
switch (n) {
case 0: /* a -- 32 bits */
/*
* Nothing is necessary here. Overflow checking was
* already done in strtoul().
*/
break;
case 1: /* a.b -- 8.24 bits */
if (val > 0xffffff || parts[0] > 0xff)
return 0;
val |= parts[0] << 24;
break;
case 2: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff || parts[0] > 0xff || parts[1] > 0xff)
return 0;
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 3: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff || parts[0] > 0xff || parts[1] > 0xff ||
parts[2] > 0xff)
return 0;
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
if (inp != NULL)
inp->s_addr = htonl(val);
return 1;
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. 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.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/param.h>
in_addr_t inet_lnaof(struct in_addr in)
{
register u_int32_t i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return (i) & IN_CLASSA_HOST;
else if (IN_CLASSB(i))
return (i) & IN_CLASSB_HOST;
else
return (i) & IN_CLASSC_HOST;
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. 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.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/param.h>
struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host)
{
struct in_addr in;
if (net < 128)
in.s_addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
else if (net < 65536)
in.s_addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
else if (net < 16777216L)
in.s_addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
else
in.s_addr = net | host;
in.s_addr = htonl(in.s_addr);
return in;
}

View File

@ -1,107 +0,0 @@
/*
* Copyright (c) 1996 by Internet Software Consortium.
*
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
/* Author: Paul Vixie (ISC), July 1996 */
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
static char *inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size)
{
char *odst = dst;
char *t;
u_int m;
int b;
if (bits < 0 || bits > 32) {
errno = EINVAL;
return (NULL);
}
if (bits == 0) {
if (size < sizeof "0")
goto emsgsize;
*dst++ = '0';
*dst = '\0';
}
/* Format whole octets. */
for (b = bits / 8; b > 0; b--) {
if (size < sizeof "255.")
goto emsgsize;
t = dst;
dst += SPRINTF((dst, "%u", *src++));
if (b > 1) {
*dst++ = '.';
*dst = '\0';
}
size -= (size_t)(dst - t);
}
/* Format partial octet. */
b = bits % 8;
if (b > 0) {
if (size < sizeof ".255")
goto emsgsize;
t = dst;
if (dst != odst)
*dst++ = '.';
m = ((1 << b) - 1) << (8 - b);
dst += SPRINTF((dst, "%u", *src & m));
size -= (size_t)(dst - t);
}
/* Format CIDR /width. */
if (size < sizeof "/32")
goto emsgsize;
dst += SPRINTF((dst, "/%u", bits));
return (odst);
emsgsize:
errno = EMSGSIZE;
return (NULL);
}
char *inet_net_ntop(int af, const void *netp, int bits, char *pres, size_t psize)
{
switch (af) {
case AF_INET:
return inet_net_ntop_ipv4(netp, bits, pres, psize);
default:
errno = EAFNOSUPPORT;
return NULL;
}
}

View File

@ -1,190 +0,0 @@
/*
* Copyright (c) 1996 by Internet Software Consortium.
*
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
/* Author: Paul Vixie (ISC), June 1996 */
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
static int inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
{
static const char xdigits[] = "0123456789abcdef";
static const char digits[] = "0123456789";
int n, ch, tmp, dirty, bits;
const u_char *odst = dst;
ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X') && isascii(src[1]) && isxdigit(src[1])) {
/* Hexadecimal: Eat nybble string. */
if (size <= 0)
goto emsgsize;
*dst = 0, dirty = 0;
src++; /* skip x or X. */
while ((ch = *src++) != '\0' &&
isascii(ch) && isxdigit(ch)) {
if (isupper(ch))
ch = tolower(ch);
n = strchr(xdigits, ch) - xdigits;
assert(n >= 0 && n <= 15);
*dst |= n;
if (!dirty++)
*dst <<= 4;
else
if (size-- > 0)
*++dst = 0, dirty = 0;
else
goto emsgsize;
}
if (dirty)
size--;
}
else {
if (isascii(ch) && isdigit(ch)) {
/* Decimal: eat dotted digit string. */
for (;;) {
tmp = 0;
do {
n = strchr(digits, ch) - digits;
assert(n >= 0 && n <= 9);
tmp *= 10;
tmp += n;
if (tmp > 255)
goto enoent;
}
while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
if (size-- <= 0)
goto emsgsize;
*dst++ = (u_char) tmp;
if (ch == '\0' || ch == '/')
break;
if (ch != '.')
goto enoent;
ch = *src++;
if (!isascii(ch) || !isdigit(ch))
goto enoent;
}
}
else
goto enoent;
}
bits = -1;
if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) {
/* CIDR width specifier. Nothing can follow it. */
ch = *src++; /* Skip over the /. */
bits = 0;
do {
n = strchr(digits, ch) - digits;
assert(n >= 0 && n <= 9);
bits *= 10;
bits += n;
}
while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
if (ch != '\0')
goto enoent;
if (bits > 32)
goto emsgsize;
}
/* Firey death and destruction unless we prefetched EOS. */
if (ch != '\0')
goto enoent;
/* If nothing was written to the destination, we found no address. */
if (dst == odst)
goto enoent;
/* If no CIDR spec was given, infer width from net class. */
if (bits == -1) {
if (*odst >= 240) /* Class E */
bits = 32;
else
if (*odst >= 224) /* Class D */
bits = 4;
else
if (*odst >= 192) /* Class C */
bits = 24;
else
if (*odst >= 128) /* Class B */
bits = 16;
else /* Class A */
bits = 8;
/* If imputed mask is narrower than specified octets, widen. */
if (bits >= 8 && bits < ((dst - odst) * 8))
bits = (dst - odst) * 8;
}
/* Extend network to cover the actual mask. */
while (bits > ((dst - odst) * 8)) {
if (size-- <= 0)
goto emsgsize;
*dst++ = '\0';
}
return (bits);
enoent:
errno = ENOENT;
return -1;
emsgsize:
errno = EMSGSIZE;
return -1;
}
int inet_net_pton(int af, const char *pres, void *netp, size_t nsize)
{
switch (af) {
case AF_INET:
return inet_net_pton_ipv4(pres, netp, nsize);
default:
errno = EAFNOSUPPORT;
return -1;
}
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. 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.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/param.h>
in_addr_t inet_netof(struct in_addr in)
{
register u_int32_t i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return ((i) & IN_CLASSA_NET) >> IN_CLASSA_NSHIFT;
else if (IN_CLASSB(i))
return ((i) & IN_CLASSB_NET) >> IN_CLASSB_NSHIFT;
else
return ((i) & IN_CLASSC_NET) >> IN_CLASSC_NSHIFT;
}

View File

@ -1,102 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. 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.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <ctype.h>
#include <netinet/in.h>
#include <sys/types.h>
in_addr_t inet_network(const char *cp)
{
register u_int32_t val, base, n, i;
register char c;
u_int32_t parts[4], *pp = parts;
int digit;
again:
val = 0;
base = 10;
digit = 0;
if (*cp == '0')
digit = 1, base = 8, cp++;
if (*cp == 'x' || *cp == 'X')
base = 16, cp++;
while ((c = *cp) != 0) {
if (isdigit(c)) {
if (base == 8 && (c == '8' || c == '9'))
return INADDR_NONE;
val = (val * base) + (c - '0');
cp++;
digit = 1;
continue;
}
if (base == 16 && isxdigit(c)) {
val = (val << 4) + (tolower (c) + 10 - 'a');
cp++;
digit = 1;
continue;
}
break;
}
if (!digit)
return INADDR_NONE;
if (pp >= parts + 4 || val > 0xff)
return INADDR_NONE;
if (*cp == '.') {
*pp++ = val, cp++;
goto again;
}
if (*cp && !isspace(*cp))
return INADDR_NONE;
if (pp >= parts + 4 || val > 0xff)
return INADDR_NONE;
*pp++ = val;
n = pp - parts;
for (val = 0, i = 0; i < n; i++) {
val <<= 8;
val |= parts[i] & 0xff;
}
return val;
}

View File

@ -1,35 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <stdio.h>
#include <arpa/inet.h>
static char static_buffer[18];
char *inet_ntoa(struct in_addr in)
{
unsigned char *bytes = (unsigned char *) &in;
snprintf(static_buffer, sizeof(static_buffer), "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3]);
return static_buffer;
}

View File

@ -1,171 +0,0 @@
/* Copyright (c) 1996 by Internet Software Consortium.
*
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
/* Author: Paul Vixie, 1996 */
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#define SPRINTF(x) ((socklen_t) sprintf x)
/*
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static const char *inet_ntop4(const u_char *src, char *dst, socklen_t size)
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) {
errno = ENOSPC;
return NULL;
}
strcpy(dst, tmp);
return dst;
}
static const char *inet_ntop6(const u_char *src, char *dst, socklen_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
* to contain a value of the specified size. On some systems, like
* Crays, there is no such thing as an integer variable with 16 bits.
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")], *tp;
struct {
int base, len;
} best, cur;
u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
/*
* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, '\0', sizeof words);
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
}
else {
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
}
if (best.base != -1 && best.len < 2)
best.base = -1;
/*
* Format the result.
*/
tp = tmp;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len)) {
if (i == best.base)
*tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp)))
return NULL;
tp += strlen(tp);
break;
}
tp += SPRINTF((tp, "%x", words[i]));
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/*
* Check for overflow, copy, and we're done.
*/
if ((socklen_t)(tp - tmp) > size) {
errno = ENOSPC;
return NULL;
}
strcpy(dst, tmp);
return dst;
}
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
switch (af) {
case AF_INET:
return inet_ntop4(src, dst, size);
case AF_INET6:
return inet_ntop6(src, dst, size);
default:
errno = EAFNOSUPPORT;
return NULL;
}
/* NOTREACHED */
}

View File

@ -1,198 +0,0 @@
/* $KAME: inet_pton.c,v 1.5 2001/08/20 02:32:40 itojun Exp $ */
/* Copyright (c) 1996 by Internet Software Consortium.
*
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
/* Author: Paul Vixie, 1996 */
/* Copied from Linux, modified for Phoenix-RTOS. */
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/types.h>
/*
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static int inet_pton4(const char *src, u_char *dst)
{
static const char digits[] = "0123456789";
int saw_digit, octets, ch;
u_char tmp[NS_INADDRSZ], *tp;
saw_digit = 0;
octets = 0;
*(tp = tmp) = 0;
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr(digits, ch)) != NULL) {
u_int new = *tp * 10 + (pch - digits);
if (new > 255)
return 0;
*tp = new;
if (! saw_digit) {
if (++octets > 4)
return 0;
saw_digit = 1;
}
}
else
if (ch == '.' && saw_digit) {
if (octets == 4)
return 0;
*++tp = 0;
saw_digit = 0;
}
else
return 0;
}
if (octets < 4)
return 0;
memcpy(dst, tmp, NS_INADDRSZ);
return 1;
}
static int inet_pton6(const char *src, u_char *dst)
{
static const char xdigits_l[] = "0123456789abcdef";
static const char xdigits_u[] = "0123456789ABCDEF";
u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, saw_xdigit;
u_int val;
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
endp = tp + NS_IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
return 0;
curtok = src;
saw_xdigit = 0;
val = 0;
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
return 0;
saw_xdigit = 1;
continue;
}
if (ch == ':') {
curtok = src;
if (!saw_xdigit) {
if (colonp)
return 0;
colonp = tp;
continue;
}
if (tp + NS_INT16SZ > endp)
return 0;
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
saw_xdigit = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4(curtok, tp) > 0) {
tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
}
return 0;
}
if (saw_xdigit) {
if (tp + NS_INT16SZ > endp)
return 0;
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
}
if (colonp != NULL) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
const int n = tp - colonp;
int i;
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
}
tp = endp;
}
if (tp != endp)
return 0;
memcpy(dst, tmp, NS_IN6ADDRSZ);
return 1;
}
int inet_pton(int af, const char *src, void *dst)
{
switch (af) {
case AF_INET:
return inet_pton4(src, dst);
case AF_INET6:
return inet_pton6(src, dst);
default:
errno = EAFNOSUPPORT;
return -1;
}
/* NOTREACHED */
}

View File

@ -1,50 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
unsigned int if_nametoindex(const char *ifname)
{
if (strcmp(ifname, "eth0") != 0) {
errno = EINVAL;
return 0;
}
return 1;
}
char *if_indextoname(unsigned int ifindex, char *ifname)
{
if (ifindex != 1) {
errno = ENXIO;
return NULL;
}
strcpy(ifname, "eth0");
return ifname;
}

View File

@ -1,49 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
int network_setUp(const char *interface)
{
int ret = syscall2(int, SYS_NET_CONFIGURE, interface, 1);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int network_setDown(const char *interface)
{
int ret = syscall2(int, SYS_NET_CONFIGURE, interface, 0);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,23 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/

View File

@ -1,37 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <sys/types.h>
pid_t getpid()
{
return syscall0(int, SYS_GETPID);
}
pid_t getppid()
{
return syscall0(int, SYS_GETPPID);
}

View File

@ -1,38 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
int pipe(int pipefd[2])
{
int ret = syscall1(int, SYS_PIPE, pipefd);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,39 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <poll.h>
int poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
int ret = syscall3(int, SYS_POLL, fds, nfds, timeout);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,104 +0,0 @@
/* Written 2000 by Werner Almesberger */
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/dirent.h>
#include <sys/stat.h>
#include <unistd.h>
static int resolve_path(char *path, char *result, char *pos)
{
if (*path == '/') {
*result = '/';
pos = result+1;
++path;
}
*pos = 0;
if (!*path)
return 0;
while (1) {
struct stat st;
char *slash = *path ? strchr(path,'/') : NULL;
if (slash)
*slash = 0;
if (!path[0] || (path[0] == '.' && (!path[1] || (path[1] == '.' && !path[2])))) {
--pos;
if (pos != result && path[0] && path[1])
while (*--pos != '/');
}
else {
strcpy(pos,path);
if (lstat(result,&st) < 0)
return -1;
if (S_ISLNK(st.st_mode)) {
char buf[PATH_MAX_SIZE];
if (readlink(result,buf,sizeof(buf)) < 0)
return -1;
*pos = 0;
if (slash) {
*slash = '/';
strcat(buf, slash);
}
strcpy(path,buf);
if (*path == '/')
result[1] = 0;
pos = strchr(result,0);
continue;
}
pos = strchr(result,0);
}
if (slash) {
*pos++ = '/';
path = slash + 1;
}
*pos = 0;
if (!slash)
break;
}
return 0;
}
char *realpath(const char *path, char *resolved_path)
{
char cwd[PATH_MAX_SIZE];
char *path_copy;
int res;
if (!*path) {
errno = ENOENT;
return NULL;
}
if (!getcwd(cwd, sizeof(cwd)))
return NULL;
strcpy(resolved_path, "/");
if (resolve_path(cwd, resolved_path, resolved_path))
return NULL;
strcat(resolved_path, "/");
path_copy = strdup(path);
if (!path_copy)
return NULL;
res = resolve_path(path_copy, resolved_path, strchr(resolved_path, 0));
free(path_copy);
if (res)
return NULL;
return resolved_path;
}

View File

@ -1,38 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
int reboot(int how)
{
int ret = syscall1(int, SYS_REBOOT, how);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,88 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sched.h>
#include <sys/resource.h>
#include <sys/sched.h>
#include <sys/types.h>
int getpriority(int which, id_t who)
{
struct sched_param param;
if (which != PRIO_PROCESS) {
errno = ENOSYS;
return -1;
}
int ret = sched_getparam(who, &param);
if (ret < 0) {
errno = -ret;
return -1;
}
errno = EOK;
return param.sched_priority;
}
int setpriority(int which, id_t who, int prio)
{
struct sched_param param;
if (which != PRIO_PROCESS) {
errno = ENOSYS;
return -1;
}
param.sched_priority = prio;
int ret = sched_setparam(who, &param);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int getrlimit(int resource, struct rlimit *rlim)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}
int setrlimit(int resource, const struct rlimit *rlim)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}
int getrusage(int who, struct rusage *usage)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}

View File

@ -1,48 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <stdint.h>
extern const char _end[]; /* Defined by the linker */
void *sbrk(intptr_t increment)
{
static char *heap_end = (char *) _end;
char *prev_heap_end = heap_end;
if (increment != 0) {
int ret= syscall2(int, SYS_SBRK, increment, heap_end);
if (ret != 0) {
errno = -ret;
return (void *) -1;
}
heap_end += increment;
}
return (void *) prev_heap_end;
}

View File

@ -1,107 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sys/sched.h>
#include <sys/types.h>
int sched_getparam(pid_t pid, struct sched_param *param)
{
int ret = syscall2(int, SYS_SCHED_GETPARAM, pid, param);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int sched_setparam(pid_t pid, const struct sched_param *param)
{
int ret = syscall2(int, SYS_SCHED_SETPARAM, pid, param);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int sched_getscheduler(pid_t pid)
{
int ret = syscall1(int, SYS_SCHED_GETSCHEDULER, pid);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param)
{
int ret = syscall3(int, SYS_SCHED_SETSCHEDULER, pid, policy, param);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int sched_get_priority_max(int policy)
{
int ret = syscall1(int, SYS_SCHED_GET_PRIORITY_MAX, policy);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int sched_get_priority_min(int policy)
{
int ret = syscall1(int, SYS_SCHED_GET_PRIORITY_MIN, policy);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int sched_yield(void)
{
int ret = syscall0(int, SYS_SCHED_YIELD);
if(ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,40 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
{
int ret = syscall5(int, SYS_SELECT, nfds, readfds, writefds, exceptfds, timeout);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,168 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <errno.h>
#include <fcntl.h>
#include <malloc.h>
#include <semaphore.h>
#include <stdarg.h>
#include <string.h>
#include <sys/dirent.h>
#include <sys/ioctl.h>
#include <sys/ipc.h>
#include <sys/stat.h>
#include <unistd.h>
int sem_init(sem_t *sem, int pshared, unsigned int value)
{
errno = ENOSYS;
return -1;
}
int sem_destroy(sem_t *sem)
{
errno = ENOSYS;
return -1;
}
sem_t *sem_open(const char *name, int oflag, ...)
{
sem_t *sem = (sem_t *) malloc(sizeof(sem_t));
if(sem == NULL) {
errno = ENOMEM;
return SEM_FAILED;
}
if (*name == '/')
++name;
char sem_name[PATH_MAX_SIZE + 24] = "/dev/ipc/sem_";
strncpy(sem_name + 13, name, PATH_MAX_SIZE + 10);
int mode = S_IRWXUGO;
int initval = 1;
if (oflag & O_CREAT) {
va_list ap;
va_start(ap, oflag);
mode = va_arg(ap, int);
initval = va_arg(ap, int);
va_end(ap);
}
sem->fd = open(sem_name, oflag, mode);
if (sem->fd != -1) {
int flags = fcntl(sem->fd, F_GETFD, 0);
if (flags >= 0) {
flags |= FD_CLOEXEC;
flags = fcntl (sem->fd, F_SETFD, flags);
}
if (flags == -1) {
close (sem->fd);
free(sem);
return SEM_FAILED;
}
}
else {
free(sem);
return SEM_FAILED;
}
if (sem != SEM_FAILED && (oflag | O_CREAT)) {
if (ioctl(sem->fd, IPC_SEM_INIT, initval) < 0) {
free(sem);
return SEM_FAILED;
}
}
return sem;
}
int sem_close(sem_t *sem)
{
if (sem == NULL || sem->fd < 0) {
errno = EINVAL;
return -1;
}
close(sem->fd);
free(sem);
return 0;
}
int sem_unlink(const char *name)
{
return unlink(name);
}
int sem_wait(sem_t *sem)
{
if(sem == NULL || sem->fd < 0) {
errno = EINVAL;
return -1;
}
return ioctl(sem->fd, IPC_SEM_DOWN, 0);
}
int sem_timedwait(sem_t * sem, const struct timespec *abs_timeout)
{
if(sem == NULL || sem->fd < 0) {
errno = EINVAL;
return -1;
}
return ioctl(sem->fd, IPC_SEM_DOWN_TIMEOUT, 0);
}
int sem_trywait(sem_t *sem)
{
if(sem == NULL || sem->fd < 0) {
errno = EINVAL;
return -1;
}
return ioctl(sem->fd, IPC_SEM_TRYDOWN, 0);
}
int sem_post(sem_t *sem)
{
if(sem == NULL || sem->fd < 0) {
errno = EINVAL;
return -1;
}
return ioctl(sem->fd, IPC_SEM_UP, 0);
}
int sem_getvalue (sem_t *sem, int *sval)
{
if(sem == NULL || sem->fd < 0) {
errno = EINVAL;
return -1;
}
return ioctl(sem->fd, IPC_SEM_GETVAL, (unsigned long) sval);
}

View File

@ -1,30 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <stdio.h>
FILE *setmntent(const char *filename, const char *type)
{
return fopen(filename, type);
}

View File

@ -1,68 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 <fcntl.h>
#include <string.h>
#include <sys/dirent.h>
#include <sys/ioctl.h>
#include <sys/ipc.h>
#include <unistd.h>
int shm_open(const char *name, int oflag, mode_t mode)
{
char shm_name[PATH_MAX_SIZE + 24] = "/dev/ipc/shm_";
if (*name == '/')
++name;
strncpy(shm_name + 13, name, PATH_MAX_SIZE + 10);
int fd = open(shm_name, oflag, mode);
if (fd >= 0) {
int flags = fcntl(fd, F_GETFD, 0);
if (flags >= 0) {
flags |= FD_CLOEXEC;
flags = fcntl(fd, F_SETFD, flags);
}
if (flags == -1) {
close(fd);
return -1;
}
}
if (fd != -1 && (oflag | O_CREAT)) {
if (ioctl(fd, IPC_SHM_INIT, 0) < 0) {
close(fd);
return -1;
}
}
return fd;
}
int shm_unlink(const char *name)
{
return unlink(name);
}

View File

@ -1,75 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
int kill(pid_t pid, int sig)
{
int ret = syscall2(int, SYS_KILL, pid, sig);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
sighandler_t signal(int signum, sighandler_t handler)
{
/* TODO: implement. */
errno = ENOSYS;
return SIG_ERR;
}
int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}
int sigsuspend(const sigset_t *mask)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}
int raise(int sig)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}

View File

@ -1,138 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <phoenix/socket_args.h>
#include <sys/socket.h>
int socket(int domain, int type, int protocol)
{
int ret = syscall3(int, SYS_SOCKET, domain, type, protocol);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
int ret = syscall3(int, SYS_BIND, sockfd, addr, addrlen);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int listen(int sockfd, int backlog)
{
int ret = syscall2(int, SYS_LISTEN, sockfd, backlog);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
int ret = syscall3(int, SYS_ACCEPT, sockfd, addr, addrlen);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
int ret = syscall3(int, SYS_CONNECT, sockfd, addr, addrlen);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
{
struct sendto_args args = { sockfd, buf, len, flags, dest_addr, addrlen };
int ret = syscall1(int, SYS_SENDTO, &args);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int send(int sockfd, const void *buf, size_t len, int flags)
{
return sendto(sockfd, buf, len, flags, NULL, 0);
}
int recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)
{
struct recvfrom_args args = { sockfd, buf, len, flags, src_addr, addrlen };
int ret = syscall1(int, SYS_RECVFROM, &args);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int recv(int sockfd, void *buf, size_t len, int flags)
{
return recvfrom(sockfd, buf, len, flags, NULL, NULL);
}
int shutdown(int sockfd, int how)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}
int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
int ret = syscall3(int, SYS_GETPEERNAME, sockfd, addr, addrlen);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,77 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <phoenix/socket_args.h>
#include <phoenix/sockios.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
int ret = syscall3(int, SYS_GETSOCKNAME, sockfd, addr, addrlen);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen)
{
struct sockopt_args args;
args.level = level;
args.optname = optname;
args.optval = optval;
args.optlen = *optlen;
int ret = ioctl(sockfd, IOC_GETSOCKOPT, &args);
if (ret < 0) {
errno = -ret;
return -1;
}
*optlen = args.optlen;
return ret;
}
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
{
struct sockopt_args args;
args.level = level;
args.optname = optname;
args.optval = (void *) optval;
args.optlen = optlen;
int ret = ioctl(sockfd, IOC_SETSOCKOPT, &args);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,66 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sys/stat.h>
int stat(const char *pathname, struct stat *buf)
{
int ret = syscall2(int, SYS_STAT, pathname, buf);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int fstat(int fd, struct stat *buf)
{
int ret = syscall2(int, SYS_FSTAT, fd, buf);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int lstat(const char *pathname, struct stat *buf)
{
int ret = syscall2(int, SYS_LSTAT, pathname, buf);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
mode_t umask(mode_t mask)
{
return syscall1(int, SYS_UMASK, mask);
}

View File

@ -1,39 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
#include <sys/vfs.h>
int statfs(const char *path, struct statfs *buf)
{
int ret = syscall2(int, SYS_STATFS, path, buf);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,60 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
int symlink(const char *target, const char *linkpath)
{
int ret = syscall2(int, SYS_SYMLINK, target, linkpath);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}
int readlink(const char *pathname, char *buf, size_t bufsize)
{
int ret = syscall3(int, SYS_READLINK, pathname, buf, bufsize);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int link(const char *oldpath, const char *newpath)
{
int ret = syscall2(int, SYS_LINK, oldpath, newpath);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}

View File

@ -1,50 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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 "syscall.h"
#include <errno.h>
void sync()
{
int ret = syscall0(int, SYS_SYNC);
if (ret < 0)
errno = -ret;
}
int fsync(int fd)
{
int ret = syscall1(int, SYS_FSYNC, fd);
if (ret < 0) {
errno = -ret;
return -1;
}
return ret;
}
int fdatasync(int fd)
{
return fsync(fd);
}

View File

@ -1,38 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _SYS__DEFAULT_FCNTL_H
#define _SYS__DEFAULT_FCNTL_H
#include <_ansi.h>
#include <phoenix/_default_fcntl.h>
#include <sys/types.h>
int open(const char *pathname, int flags, ...);
int _open(const char *pathname, int flags, ...);
int creat(const char *pathname, mode_t mode);
int fcntl(int fd, int cmd, ...);
int flock(int fd, int operation);
#endif

View File

@ -1,41 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef NULL
#if !defined(__cplusplus)
#define NULL ((void *) 0)
#else
#if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
#define NULL __null
#else
#if defined(__LP64__)
#define NULL (0L)
#else
#define NULL 0
#endif
#endif
#endif
#endif

View File

@ -1,30 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _SYS__TIMESPEC_H
#define _SYS__TIMESPEC_H
#include <phoenix/time.h>
#endif

View File

@ -1,30 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _SYS__TIMEVAL_H
#define _SYS__TIMEVAL_H
#include <phoenix/time.h>
#endif

View File

@ -1,72 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _SYS__TYPES_H
#define _SYS__TYPES_H
#include <machine/_types.h>
#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
typedef int _ssize_t;
#else
typedef long _ssize_t;
#endif
typedef long _off_t;
typedef long _fpos_t;
typedef long int __off_t;
typedef long int __loff_t;
typedef long __suseconds_t;
#define _CLOCK_T_ unsigned long
#define __need_wint_t
#include <stddef.h>
/* Conversion state information. */
typedef struct {
int __count;
union {
wint_t __wch;
unsigned char __wchb[4];
} __value;
} _mbstate_t;
struct __flock_mutex_t_tmp;
typedef struct {
int __a;
int __b;
struct {
long int __c1;
int __c2;
} __c;
int __d;
struct __flock_mutex_t_tmp *__e;
} __flock_mutex_t;
typedef struct {
__flock_mutex_t mutex;
} _flock_t;
#endif

View File

@ -1,61 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _SYS_DIRENT_H
#define _SYS_DIRENT_H
#include <phoenix/fs.h>
#include <sys/lock.h>
#include <sys/types.h>
#define PATH_MAX_SIZE 1024
#define HAVE_DD_LOCK
typedef struct {
int dd_fd; /* Directory file. */
int dd_loc; /* Position in buffer. */
int dd_seek;
char *dd_buf; /* Pointer to buffer. */
int dd_len; /* Buffer size. */
int dd_size; /* Data size in buffer. */
_LOCK_RECURSIVE_T dd_lock;
} DIR;
#define __dirfd(dir) (dir)->dd_fd
#define _seekdir seekdir
/* Declare which dirent fields are available in Phoenix-RTOS. */
#undef _DIRENT_HAVE_D_NAMLEN
#define _DIRENT_HAVE_D_OFF
#define _DIRENT_HAVE_D_RECLEN
#define d_fileno d_ino /* Backwards compatibility. */
#ifdef __USE_LARGEFILE64
#define dirent64 dirent
#endif
#endif

View File

@ -1,42 +0,0 @@
/* Copyright (c) 2016 Phoenix Systems
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.*/
#ifndef _SYS_ERRNO_H
#define _SYS_ERRNO_H
#include <phoenix/errno.h>
#include <sys/reent.h>
#ifndef _REENT_ONLY
#define errno (*__errno())
extern int *__errno (void);
#endif
/* Don't use these variables directly. Use strerror instead. */
extern __IMPORT const char * const _sys_errlist[];
extern __IMPORT int _sys_nerr;
#define __errno_r(ptr) ((ptr)->_errno)
#endif

Some files were not shown because too many files have changed in this diff Show More