4.104.114.84.95
Last change
on this file since d78b7a9e was
d78b7a9e,
checked in by Joel Sherrill <joel.sherrill@…>, on 01/26/99 at 01:49:31
|
Added libio_sockets.c to hold support routines for networking code.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[d78b7a9e] | 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-1998. |
---|
| 6 | * On-Line Applications Research Corporation (OAR). |
---|
| 7 | * Copyright assigned to U.S. Government, 1994. |
---|
| 8 | * |
---|
| 9 | * The license and distribution terms for this file may be |
---|
| 10 | * found in the file LICENSE in this distribution or at |
---|
| 11 | * http://www.OARcorp.com/rtems/license.html. |
---|
| 12 | * |
---|
| 13 | * $Id$ |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "libio_.h" /* libio_.h pulls in rtems */ |
---|
| 17 | #include <rtems.h> |
---|
| 18 | |
---|
| 19 | #include <errno.h> |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | /* |
---|
| 23 | * Convert an RTEMS file descriptor to a BSD socket pointer. |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | struct socket *rtems_bsdnet_fdToSocket( |
---|
| 27 | int fd |
---|
| 28 | ) |
---|
| 29 | { |
---|
| 30 | rtems_libio_t *iop; |
---|
| 31 | |
---|
| 32 | if ((unsigned32)fd >= rtems_libio_number_iops) |
---|
| 33 | return NULL; |
---|
| 34 | iop = &rtems_libio_iops[fd]; |
---|
| 35 | if ((iop->flags & LIBIO_FLAGS_HANDLER_MASK) != LIBIO_FLAGS_HANDLER_SOCK) |
---|
| 36 | return NULL; |
---|
| 37 | return iop->data1; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | /* |
---|
| 41 | * Create an RTEMS file descriptor for a socket |
---|
| 42 | */ |
---|
| 43 | |
---|
| 44 | int rtems_bsdnet_makeFdForSocket( |
---|
| 45 | void *so |
---|
| 46 | ) |
---|
| 47 | { |
---|
| 48 | rtems_libio_t *iop; |
---|
| 49 | |
---|
| 50 | iop = rtems_libio_allocate(); |
---|
| 51 | if (iop == 0) { |
---|
| 52 | errno = ENFILE; |
---|
| 53 | return -1; |
---|
| 54 | } |
---|
| 55 | iop->flags |= LIBIO_FLAGS_HANDLER_SOCK; |
---|
| 56 | iop->data1 = so; |
---|
| 57 | return iop - rtems_libio_iops; |
---|
| 58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.