source: rtems/cpukit/libcsupport/src/libio_sockets.c @ 690861c

4.104.114.84.95
Last change on this file since 690861c was 0eae36c7, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:54:13

2003-09-04 Joel Sherrill <joel@…>

  • include/chain.h, include/clockdrv.h, include/console.h, include/iosupp.h, include/rtc.h, include/spurious.h, include/timerdrv.h, include/vmeintr.h, include/motorola/mc68230.h, include/rtems/libcsupport.h, include/rtems/libio.h, include/rtems/libio_.h, include/rtems/termiostypes.h, include/sys/termios.h, include/zilog/z8036.h, include/zilog/z8530.h, include/zilog/z8536.h, src/brk.c, src/gettod.c, src/sbrk.c, src/times.c, src/access.c, src/base_fs.c, src/cfgetispeed.c, src/cfgetospeed.c, src/cfsetispeed.c, src/cfsetospeed.c, src/chdir.c, src/chmod.c, src/chown.c, src/chroot.c, src/close.c, src/ctermid.c, src/dup.c, src/dup2.c, src/eval.c, src/fchdir.c, src/fchmod.c, src/fcntl.c, src/fdatasync.c, src/fpathconf.c, src/fs_null_handlers.c, src/fstat.c, src/fsync.c, src/ftruncate.c, src/getdents.c, src/getpwent.c, src/hosterr.c, src/ioctl.c, src/isatty.c, src/libio.c, src/libio_sockets.c, src/link.c, src/lseek.c, src/lstat.c, src/malloc.c, src/mallocfreespace.c, src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mount.c, src/newlibc.c, src/no_libc.c, src/no_posix.c, src/open.c, src/pathconf.c, src/pipe.c, src/privateenv.c, src/read.c, src/readlink.c, src/rewinddir.c, src/rmdir.c, src/seekdir.c, src/stat.c, src/symlink.c, src/sync.c, src/tcdrain.c, src/tcflow.c, src/tcflush.c, src/tcgetattr.c, src/tcgetprgrp.c, src/tcsendbreak.c, src/tcsetattr.c, src/tcsetpgrp.c, src/telldir.c, src/termios.c, src/termiosinitialize.c, src/truncate.c, src/umask.c, src/unixlibc.c, src/unlink.c, src/unmount.c, src/utime.c, src/write.c: URL for license changed.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  This file contains the support infrastructure used to manage the
3 *  table of integer style file descriptors used by the socket calls.
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/libio_.h>             /* libio_.h pulls in rtems */
20#include <rtems.h>
21
22#include <errno.h>
23
24/*
25 * Convert an RTEMS file descriptor to a BSD socket pointer.
26 */
27
28struct socket *rtems_bsdnet_fdToSocket(
29  int fd
30)
31{
32  rtems_libio_t *iop;
33
34  /* same as rtems_libio_check_fd(_fd) but different return */
35  if ((unsigned32)fd >= rtems_libio_number_iops) {
36    errno = EBADF;
37    return NULL;
38  }
39  iop = &rtems_libio_iops[fd];
40
41  /* same as rtems_libio_check_is_open(iop) but different return */
42  if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) {
43    errno = EBADF;
44    return NULL;
45  }
46
47  if (iop->data1 == NULL)
48    errno = EBADF;
49  return iop->data1;
50}
51
52/*
53 * Create an RTEMS file descriptor for a socket
54 */
55
56int rtems_bsdnet_makeFdForSocket(
57  void *so,
58  const rtems_filesystem_file_handlers_r *h
59)
60{
61  rtems_libio_t *iop;
62  int fd;
63
64  iop = rtems_libio_allocate();
65  if (iop == 0) {
66      errno = ENFILE;
67      return -1;
68  }
69  fd = iop - rtems_libio_iops;
70  iop->flags |= LIBIO_FLAGS_WRITE | LIBIO_FLAGS_READ;
71  iop->data0 = fd;
72  iop->data1 = so;
73  iop->handlers = (rtems_filesystem_file_handlers_r *) h;
74  return fd;
75}
Note: See TracBrowser for help on using the repository browser.