diff options
Diffstat (limited to 'ecos/packages/net/tcpip/current/src/lib')
18 files changed, 1093 insertions, 0 deletions
diff --git a/ecos/packages/net/tcpip/current/src/lib/accept.c b/ecos/packages/net/tcpip/current/src/lib/accept.c new file mode 100644 index 0000000..c2844e1 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/accept.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/accept.c +// +// accept() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +accept(int s, const struct sockaddr *name, socklen_t *anamelen) +{ + struct sys_accept_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,name) = (struct sockaddr *)name; + SYSCALLARG(args,anamelen) = anamelen; + error = sys_accept(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return res; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/bind.c b/ecos/packages/net/tcpip/current/src/lib/bind.c new file mode 100644 index 0000000..994bc6c --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/bind.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/bind.c +// +// bind() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +bind(int s, const struct sockaddr *name, socklen_t namelen) +{ + struct sys_bind_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,name) = name; + SYSCALLARG(args,namelen) = namelen; + error = sys_bind(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/close.c b/ecos/packages/net/tcpip/current/src/lib/close.c new file mode 100644 index 0000000..7cf8f4e --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/close.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/close.c +// +// close() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +close(int fd) +{ + int error; + struct file *fp; + if (getfp(fd, &fp)) + return (EBADF); + error = (*fp->f_ops->fo_close)(fp); + if (error) { + errno = error; + return -1; + } else { + ffree(fp); + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/connect.c b/ecos/packages/net/tcpip/current/src/lib/connect.c new file mode 100644 index 0000000..10ec5c7 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/connect.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/connect.c +// +// connect() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +connect(int s, const struct sockaddr *name, socklen_t namelen) +{ + struct sys_connect_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,name) = name; + SYSCALLARG(args,namelen) = namelen; + error = sys_connect(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/getpeername.c b/ecos/packages/net/tcpip/current/src/lib/getpeername.c new file mode 100644 index 0000000..45eefc2 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/getpeername.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/getpeername.c +// +// getpeername() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +getpeername(int s, const struct sockaddr *name, socklen_t *namelen) +{ + struct sys_getpeername_args args; + int res, error; + SYSCALLARG(args,fdes) = s; + SYSCALLARG(args,asa) = (struct sockaddr *)name; + SYSCALLARG(args,alen) = namelen; + error = sys_getpeername(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/getsockname.c b/ecos/packages/net/tcpip/current/src/lib/getsockname.c new file mode 100644 index 0000000..32044f9 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/getsockname.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/getsockname.c +// +// getsockname() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +getsockname(int s, const struct sockaddr *name, socklen_t *namelen) +{ + struct sys_getsockname_args args; + int res, error; + SYSCALLARG(args,fdes) = s; + SYSCALLARG(args,asa) = (struct sockaddr *)name; + SYSCALLARG(args,alen) = namelen; + error = sys_getsockname(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/getsockopt.c b/ecos/packages/net/tcpip/current/src/lib/getsockopt.c new file mode 100644 index 0000000..22e2b70 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/getsockopt.c @@ -0,0 +1,54 @@ +//========================================================================== +// +// lib/getsockopt.c +// +// getsockopt() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +getsockopt(int s, int level, int name, void *val, socklen_t *avalsize) +{ + struct sys_getsockopt_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,level) = level; + SYSCALLARG(args,name) = name; + SYSCALLARG(args,val) = val; + SYSCALLARG(args,avalsize) = avalsize; + error = sys_getsockopt(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/ioctl.c b/ecos/packages/net/tcpip/current/src/lib/ioctl.c new file mode 100644 index 0000000..7af846c --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/ioctl.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/ioctl.c +// +// ioctl() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +ioctl(int fd, u_long cmd, void *data) +{ + struct sys_ioctl_args args; + int res, error; + SYSCALLARG(args,fd) = fd; + SYSCALLARG(args,com) = cmd; + SYSCALLARG(args,data) = data; + error = sys_ioctl(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/listen.c b/ecos/packages/net/tcpip/current/src/lib/listen.c new file mode 100644 index 0000000..fc489da --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/listen.c @@ -0,0 +1,51 @@ +//========================================================================== +// +// lib/listen.c +// +// listen() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +listen(int s, int backlog) +{ + struct sys_listen_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,backlog) = backlog; + error = sys_listen(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/read.c b/ecos/packages/net/tcpip/current/src/lib/read.c new file mode 100644 index 0000000..a9d59ab --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/read.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/read.c +// +// read() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +read(int fd, void *buf, size_t len) +{ + struct sys_read_args args; + int res, error; + SYSCALLARG(args,fd) = fd; + SYSCALLARG(args,buf) = buf; + SYSCALLARG(args,nbyte) = len; + error = sys_read(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return res; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/recv.c b/ecos/packages/net/tcpip/current/src/lib/recv.c new file mode 100644 index 0000000..39866c1 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/recv.c @@ -0,0 +1,42 @@ +//========================================================================== +// +// lib/recv.c +// +// recv() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas,andrew.lunn@ascom.ch +// Contributors: gthomas +// Date: 2001-11-01 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +extern ssize_t recvfrom (int, void *, size_t, int, struct sockaddr *, socklen_t *); + +ssize_t +recv(int s, void *buf, size_t buflen, int flags) +{ + + return(recvfrom(s,buf,buflen,flags,NULL,0)); +} diff --git a/ecos/packages/net/tcpip/current/src/lib/recvfrom.c b/ecos/packages/net/tcpip/current/src/lib/recvfrom.c new file mode 100644 index 0000000..63c1b27 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/recvfrom.c @@ -0,0 +1,56 @@ +//========================================================================== +// +// lib/recvfrom.c +// +// recvfrom() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +ssize_t +recvfrom(int s, const void *buf, size_t buflen, + int flags, const struct sockaddr *from, socklen_t *fromlen) +{ + struct sys_recvfrom_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,buf) = (void *)buf; + SYSCALLARG(args,len) = buflen; + SYSCALLARG(args,flags) = flags; + SYSCALLARG(args,from) = (struct sockaddr *)from; + SYSCALLARG(args,fromlenaddr) = fromlen; + error = sys_recvfrom(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return res; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/select.c b/ecos/packages/net/tcpip/current/src/lib/select.c new file mode 100644 index 0000000..9316913 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/select.c @@ -0,0 +1,209 @@ +//========================================================================== +// +// lib/select.c +// +// 'select()' system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: eCos implementation of 'select()' system call +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <cyg/kernel/kapi.h> +#include <sys/select.h> +#include <sys/bsdselect.h> + +static cyg_flag_t select_flag; +static cyg_bool select_flag_init = false; +#define SELECT_WAKE 0x01 +#define SELECT_ABORT 0x02 + +// +// Private function which does all the work for 'select()' +// +static int +_cyg_select(int nfd, fd_set *in, fd_set *out, fd_set *ex, + struct timeval *tv, cyg_bool_t abortable) +{ + int fd, mode, num, ticks; + struct file *fp; + fd_set in_res, out_res, ex_res; // Result sets + fd_set *selection[3], *result[3]; + cyg_tick_count_t now, then; + int mode_type[] = {FREAD, FWRITE, 0}; + cyg_flag_value_t flag, wait_flag; + + // Note: since this is called by application programs, it needs no protection + if (!select_flag_init) { + select_flag_init = true; + cyg_flag_init(&select_flag); + } + wait_flag = SELECT_WAKE; + if (abortable) wait_flag |= SELECT_ABORT; + FD_ZERO(&in_res); + FD_ZERO(&out_res); + FD_ZERO(&ex_res); + // Set up sets + selection[0] = in; result[0] = &in_res; + selection[1] = out; result[1] = &out_res; + selection[2] = ex; result[2] = &ex_res; + // Compute end time + if (tv) { + now = cyg_current_time(); + ticks = (tv->tv_sec * 100) + (tv->tv_usec / 10000); + then = now + ticks; + } else { + then = 0; // Compiler warnings :-( + ticks = 0; + } + // Scan sets for possible I/O until something found, timeout or error. + while (true) { + num = 0; // Total file descriptors "ready" + + cyg_scheduler_lock(); // Scan the list atomically wrt electing to sleep + + for (mode = 0; mode < 3; mode++) { + if (selection[mode]) { + for (fd = 0; fd < nfd; fd++) { + if (FD_ISSET(fd, selection[mode])) { + if (getfp(fd, &fp)) { + cyg_scheduler_unlock(); // return. + errno = EBADF; + return -1; + } + if ((*fp->f_ops->fo_select)(fp, mode_type[mode])) { + FD_SET(fd, result[mode]); + num++; + } + } + } + } + } + if (num) { + + cyg_scheduler_unlock(); // Happy, about to return. + + // Found something, update user's sets + if (in) { + memcpy(in, &in_res, sizeof(in_res)); + } + if (out) { + memcpy(out, &out_res, sizeof(out_res)); + } + if (ex) { + memcpy(ex, &ex_res, sizeof(ex_res)); + } + return num; + } + // Nothing found, see if we want to wait + if (tv) { + if (ticks == 0) { + // Special case of "poll" + cyg_scheduler_unlock(); // About to return. + return 0; + } + flag = cyg_flag_timed_wait(&select_flag, wait_flag, + CYG_FLAG_WAITMODE_OR, + then); + } else { + // Wait forever (until something happens) + flag = cyg_flag_wait(&select_flag, wait_flag, + CYG_FLAG_WAITMODE_OR); + } + + cyg_scheduler_unlock(); // waited atomically + + if (flag & SELECT_ABORT) { + errno = EINTR; + return -1; + } + if (!flag) { + return 0; // meaning no activity, ergo timeout occurred + } + } + errno = ENOSYS; + return -1; +} + +// +// This function is called by the lower layers to record the +// fact that a particular 'select' event is being requested. +// +void +selrecord(void *selector, struct selinfo *info) +{ + // Unused by this implementation +} + +// +// This function is called to indicate that a 'select' event +// may have occurred. +// +void +selwakeup(struct selinfo *info) +{ + // Need these ops to be atomic to make sure the clear occurs - + // otherwise a higher prio thread could hog the CPU when its fds are + // not ready, but the flag is (already) set, or set for someone else. + cyg_scheduler_lock(); + cyg_flag_setbits(&select_flag, SELECT_WAKE); + cyg_flag_maskbits(&select_flag, 0 ); // clear all + cyg_scheduler_unlock(); +} + +// +// The public function used by 'normal' programs. This interface does not allow +// the 'select()' to be externally interrupted. +// +int +select(int nfd, fd_set *in, fd_set *out, fd_set *ex, + struct timeval *tv) +{ + return _cyg_select(nfd, in, out, ex, tv, false); +} + +// +// The public function used by programs which wish to allow interruption, +// using the 'cyg_select_abort()' function below. +// +int +cyg_select_with_abort(int nfd, fd_set *in, fd_set *out, fd_set *ex, + struct timeval *tv) +{ + return _cyg_select(nfd, in, out, ex, tv, true); +} + +// +// This function can be called by the user to forceably abort any +// current selects. +// +void +cyg_select_abort(void) +{ + // See comments in selwakeup()... + cyg_scheduler_lock(); + cyg_flag_setbits(&select_flag, SELECT_ABORT); + cyg_flag_maskbits(&select_flag, 0 ); + cyg_scheduler_unlock(); +} + + diff --git a/ecos/packages/net/tcpip/current/src/lib/sendto.c b/ecos/packages/net/tcpip/current/src/lib/sendto.c new file mode 100644 index 0000000..d319150 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/sendto.c @@ -0,0 +1,56 @@ +//========================================================================== +// +// lib/sendto.c +// +// sendto() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +ssize_t +sendto(int s, const void *buf, size_t buflen, + int flags, const struct sockaddr *to, socklen_t tolen) +{ + struct sys_sendto_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,buf) = buf; + SYSCALLARG(args,len) = buflen; + SYSCALLARG(args,flags) = flags; + SYSCALLARG(args,to) = to; + SYSCALLARG(args,tolen) = tolen; + error = sys_sendto(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return res; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/setsockopt.c b/ecos/packages/net/tcpip/current/src/lib/setsockopt.c new file mode 100644 index 0000000..88902f0 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/setsockopt.c @@ -0,0 +1,54 @@ +//========================================================================== +// +// lib/setsockopt.c +// +// setsockopt() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +setsockopt(int s, int level, int name, const void *val, socklen_t valsize) +{ + struct sys_setsockopt_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,level) = level; + SYSCALLARG(args,name) = name; + SYSCALLARG(args,val) = val; + SYSCALLARG(args,valsize) = valsize; + error = sys_setsockopt(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/shutdown.c b/ecos/packages/net/tcpip/current/src/lib/shutdown.c new file mode 100644 index 0000000..a8956eb --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/shutdown.c @@ -0,0 +1,51 @@ +//========================================================================== +// +// lib/shutdown.c +// +// shutdown() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +shutdown(int s, int how) +{ + struct sys_shutdown_args args; + int res, error; + SYSCALLARG(args,s) = s; + SYSCALLARG(args,how) = how; + error = sys_shutdown(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return 0; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/socket.c b/ecos/packages/net/tcpip/current/src/lib/socket.c new file mode 100644 index 0000000..f92c225 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/socket.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/socket.c +// +// socket() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +socket(int domain, int type, int protocol) +{ + struct sys_socket_args args; + int res, error; + SYSCALLARG(args,domain) = domain; + SYSCALLARG(args,type) = type; + SYSCALLARG(args,protocol) = protocol; + error = sys_socket(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return res; + } +} diff --git a/ecos/packages/net/tcpip/current/src/lib/write.c b/ecos/packages/net/tcpip/current/src/lib/write.c new file mode 100644 index 0000000..0667631 --- /dev/null +++ b/ecos/packages/net/tcpip/current/src/lib/write.c @@ -0,0 +1,52 @@ +//========================================================================== +// +// lib/write.c +// +// write() system call +// +//========================================================================== +// ####BSDALTCOPYRIGHTBEGIN#### +// ------------------------------------------- +// Portions of this software may have been derived from OpenBSD +// or other sources, and if so are covered by the appropriate copyright +// and license included herein. +// ------------------------------------------- +// ####BSDALTCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +#include <sys/param.h> +#include <cyg/io/file.h> +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/syscallargs.h> + +int +write(int fd, const void *buf, size_t len) +{ + struct sys_write_args args; + int res, error; + SYSCALLARG(args,fd) = fd; + SYSCALLARG(args,buf) = buf; + SYSCALLARG(args,nbyte) = len; + error = sys_write(&args, &res); + if (error) { + errno = error; + return -1; + } else { + return res; + } +} |