forked from Imagelibrary/rtems
Added libio_sockets.c to hold support routines for networking code.
This commit is contained in:
58
c/src/exec/libcsupport/src/libio_sockets.c
Normal file
58
c/src/exec/libcsupport/src/libio_sockets.c
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* This file contains the support infrastructure used to manage the
|
||||||
|
* table of integer style file descriptors used by the socket calls.
|
||||||
|
*
|
||||||
|
* COPYRIGHT (c) 1989-1998.
|
||||||
|
* On-Line Applications Research Corporation (OAR).
|
||||||
|
* Copyright assigned to U.S. Government, 1994.
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.OARcorp.com/rtems/license.html.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libio_.h" /* libio_.h pulls in rtems */
|
||||||
|
#include <rtems.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert an RTEMS file descriptor to a BSD socket pointer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct socket *rtems_bsdnet_fdToSocket(
|
||||||
|
int fd
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_libio_t *iop;
|
||||||
|
|
||||||
|
if ((unsigned32)fd >= rtems_libio_number_iops)
|
||||||
|
return NULL;
|
||||||
|
iop = &rtems_libio_iops[fd];
|
||||||
|
if ((iop->flags & LIBIO_FLAGS_HANDLER_MASK) != LIBIO_FLAGS_HANDLER_SOCK)
|
||||||
|
return NULL;
|
||||||
|
return iop->data1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create an RTEMS file descriptor for a socket
|
||||||
|
*/
|
||||||
|
|
||||||
|
int rtems_bsdnet_makeFdForSocket(
|
||||||
|
void *so
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_libio_t *iop;
|
||||||
|
|
||||||
|
iop = rtems_libio_allocate();
|
||||||
|
if (iop == 0) {
|
||||||
|
errno = ENFILE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
iop->flags |= LIBIO_FLAGS_HANDLER_SOCK;
|
||||||
|
iop->data1 = so;
|
||||||
|
return iop - rtems_libio_iops;
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ LIBNAME=libcsupport.a
|
|||||||
LIB=${ARCH}/${LIBNAME}
|
LIB=${ARCH}/${LIBNAME}
|
||||||
|
|
||||||
BASE_FS_PIECES=base_fs mount unmount ioman \
|
BASE_FS_PIECES=base_fs mount unmount ioman \
|
||||||
libio eval
|
libio libio_sockets eval
|
||||||
|
|
||||||
IMFS_PIECES= imfs_chown imfs_creat imfs_directory imfs_eval imfs_free \
|
IMFS_PIECES= imfs_chown imfs_creat imfs_directory imfs_eval imfs_free \
|
||||||
imfs_gtkn imfs_init imfs_link imfs_mknod imfs_mount imfs_fchmod \
|
imfs_gtkn imfs_init imfs_link imfs_mknod imfs_mount imfs_fchmod \
|
||||||
|
|||||||
58
c/src/lib/libc/libio_sockets.c
Normal file
58
c/src/lib/libc/libio_sockets.c
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* This file contains the support infrastructure used to manage the
|
||||||
|
* table of integer style file descriptors used by the socket calls.
|
||||||
|
*
|
||||||
|
* COPYRIGHT (c) 1989-1998.
|
||||||
|
* On-Line Applications Research Corporation (OAR).
|
||||||
|
* Copyright assigned to U.S. Government, 1994.
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.OARcorp.com/rtems/license.html.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libio_.h" /* libio_.h pulls in rtems */
|
||||||
|
#include <rtems.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert an RTEMS file descriptor to a BSD socket pointer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct socket *rtems_bsdnet_fdToSocket(
|
||||||
|
int fd
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_libio_t *iop;
|
||||||
|
|
||||||
|
if ((unsigned32)fd >= rtems_libio_number_iops)
|
||||||
|
return NULL;
|
||||||
|
iop = &rtems_libio_iops[fd];
|
||||||
|
if ((iop->flags & LIBIO_FLAGS_HANDLER_MASK) != LIBIO_FLAGS_HANDLER_SOCK)
|
||||||
|
return NULL;
|
||||||
|
return iop->data1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create an RTEMS file descriptor for a socket
|
||||||
|
*/
|
||||||
|
|
||||||
|
int rtems_bsdnet_makeFdForSocket(
|
||||||
|
void *so
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_libio_t *iop;
|
||||||
|
|
||||||
|
iop = rtems_libio_allocate();
|
||||||
|
if (iop == 0) {
|
||||||
|
errno = ENFILE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
iop->flags |= LIBIO_FLAGS_HANDLER_SOCK;
|
||||||
|
iop->data1 = so;
|
||||||
|
return iop - rtems_libio_iops;
|
||||||
|
}
|
||||||
58
cpukit/libcsupport/src/libio_sockets.c
Normal file
58
cpukit/libcsupport/src/libio_sockets.c
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* This file contains the support infrastructure used to manage the
|
||||||
|
* table of integer style file descriptors used by the socket calls.
|
||||||
|
*
|
||||||
|
* COPYRIGHT (c) 1989-1998.
|
||||||
|
* On-Line Applications Research Corporation (OAR).
|
||||||
|
* Copyright assigned to U.S. Government, 1994.
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.OARcorp.com/rtems/license.html.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libio_.h" /* libio_.h pulls in rtems */
|
||||||
|
#include <rtems.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert an RTEMS file descriptor to a BSD socket pointer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct socket *rtems_bsdnet_fdToSocket(
|
||||||
|
int fd
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_libio_t *iop;
|
||||||
|
|
||||||
|
if ((unsigned32)fd >= rtems_libio_number_iops)
|
||||||
|
return NULL;
|
||||||
|
iop = &rtems_libio_iops[fd];
|
||||||
|
if ((iop->flags & LIBIO_FLAGS_HANDLER_MASK) != LIBIO_FLAGS_HANDLER_SOCK)
|
||||||
|
return NULL;
|
||||||
|
return iop->data1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create an RTEMS file descriptor for a socket
|
||||||
|
*/
|
||||||
|
|
||||||
|
int rtems_bsdnet_makeFdForSocket(
|
||||||
|
void *so
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_libio_t *iop;
|
||||||
|
|
||||||
|
iop = rtems_libio_allocate();
|
||||||
|
if (iop == 0) {
|
||||||
|
errno = ENFILE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
iop->flags |= LIBIO_FLAGS_HANDLER_SOCK;
|
||||||
|
iop->data1 = so;
|
||||||
|
return iop - rtems_libio_iops;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user