source: rtems/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h @ 183af89

4.115
Last change on this file since 183af89 was 58f6655, checked in by Sebastian Huber <sebastian.huber@…>, on 04/03/12 at 14:15:34

networking: socket to/from file descriptor

o Move rtems_bsdnet_fdToSocket() and rtems_bsdnet_makeFdForSocket() to

"cpukit/libnetworking/rtems/rtems_syscall.c".

o The rtems_bsdnet_makeFdForSocket() function is now static.
o Check in rtems_bsdnet_fdToSocket() function that the file descriptor

uses the socket handlers, otherwise an error status will be returned
and errno set to ENOTSOCK.

o New test libtests/syscall01.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 * Declarations to fit FreeBSD to RTEMS.
3 *
4 *******************************************************************
5 *                            WARNING                              *
6 * This file should *never* be included by any application program *
7 *******************************************************************
8 *
9 *  $Id$
10 */
11
12#ifndef _RTEMS_RTEMS_BSDNET_INTERNAL_H
13#define _RTEMS_RTEMS_BSDNET_INTERNAL_H
14
15#include <rtems.h>
16#include <rtems/fs.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22typedef unsigned int            vm_offset_t;
23typedef long long               vm_ooffset_t;
24typedef unsigned int            vm_pindex_t;
25typedef unsigned int            vm_size_t;
26
27#ifndef __ioctl_command_defined
28typedef u_int32_t ioctl_command_t;
29#define __ioctl_command_defined
30#endif
31
32
33#define _BSD_OFF_T_     int32_t
34#define _BSD_PID_T_     rtems_id
35#define _BSD_VA_LIST_   char *
36
37/* make sure we get the network versions of these */
38#include <machine/types.h>
39#include <machine/param.h>
40#include <sys/cdefs.h>
41
42#include <sys/time.h>
43
44struct mdproc {
45        int     md_flags;
46        int     *md_regs;
47};
48
49/*
50 * Other RTEMS/BSD glue
51 */
52struct socket;
53extern int soconnsleep (struct socket *so);
54extern void soconnwakeup (struct socket *so);
55#define splnet()        0
56#define splimp()        0
57#define splx(_s)        do { (_s) = 0; } while(0)
58
59/* to avoid warnings */
60void *memcpy(void *dest, const void *src, size_t n);
61void *memset(void *s, int c, size_t n);
62
63#define ovbcopy(f,t,n) bcopy(f,t,n)
64#define copyout(f,t,n) (memcpy(t,f,n),0)
65#define copyin(f,t,n) (memcpy(t,f,n),0)
66
67#define random()        rtems_bsdnet_random()
68#define panic   rtems_panic
69#define suser(a,b)      0
70
71void    microtime (struct timeval *tv);
72#define hz rtems_bsdnet_ticks_per_second
73#define tick rtems_bsdnet_microseconds_per_tick
74
75#define log     rtems_bsdnet_log
76
77/*
78 * Since we can't have two sys/types.h files, we'll hack around
79 * and copy the contents of the BSD sys/types.h to here....
80 */
81
82typedef u_int64_t       u_quad_t;       /* quads */
83typedef int64_t         quad_t;
84typedef quad_t *        qaddr_t;
85
86typedef void __sighandler_t(int);
87typedef __sighandler_t  *sig_t; /* type of pointer to a signal function */
88#define NSIG    32
89struct  sigaltstack {
90        char    *ss_sp;                 /* signal stack base */
91        int     ss_size;                /* signal stack length */
92        int     ss_flags;               /* SS_DISABLE and/or SS_ONSTACK */
93};
94
95#ifdef _KERNEL
96typedef int             boolean_t;
97#endif
98
99#ifndef _POSIX_SOURCE
100/*
101 * minor() gives a cookie instead of an index since we don't want to
102 * change the meanings of bits 0-15 or waste time and space shifting
103 * bits 16-31 for devices that don't use them.
104 */
105#define major(x)        ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
106#define minor(x)        ((int)((x)&0xffff00ff))         /* minor number */
107#define makedev(x,y)    ((dev_t)(((x) << 8) | (y)))     /* create dev_t */
108#endif
109
110#include <rtems/endian.h>
111
112typedef quad_t          rlim_t;         /* resource limit */
113typedef u_int32_t       fixpt_t;        /* fixed point number */
114
115/*
116 * Forward structure declarations for function prototypes.  We include the
117 * common structures that cross subsystem boundaries here; others are mostly
118 * used in the same place that the structure is defined.
119 */
120struct  proc;
121struct  pgrp;
122struct  ucred;
123struct  rusage;
124struct  buf;
125struct  tty;
126struct  uio;
127struct  rtems_bsdnet_ifconfig;
128
129/*
130 * Redo kernel memory allocation
131 */
132#define malloc(size,type,flags) rtems_bsdnet_malloc(size,type,flags)
133#define free(ptr,type) rtems_bsdnet_free(ptr,type)
134#define timeout(ftn,arg,ticks) rtems_bsdnet_timeout(ftn,arg,ticks)
135
136#define M_NOWAIT        0x0001
137void *rtems_bsdnet_malloc (size_t size, int type, int flags);
138void rtems_bsdnet_free (void *addr, int type);
139
140void rtems_bsdnet_semaphore_obtain (void);
141void rtems_bsdnet_semaphore_release (void);
142void rtems_bsdnet_schednetisr (int n);
143int rtems_bsdnet_parse_driver_name (const struct rtems_bsdnet_ifconfig *config, char **namep);
144
145unsigned long rtems_bsdnet_seconds_since_boot (void);
146unsigned long rtems_bsdnet_random (void);
147
148rtems_id rtems_bsdnet_newproc (
149  char  *name,
150  int   stacksize,
151  void  (*entry)(void *),
152  void  *arg
153);
154
155rtems_status_code rtems_bsdnet_event_receive (
156  rtems_event_set  event_in,
157  rtems_option     option_set,
158  rtems_interval   ticks,
159  rtems_event_set *event_out
160);
161
162/*
163 * Network configuration
164 */
165extern int rtems_bsdnet_ticks_per_second;
166extern int rtems_bsdnet_microseconds_per_tick;
167extern struct in_addr rtems_bsdnet_log_host_address;
168extern char *rtems_bsdnet_domain_name;
169
170/*
171 * Internal IOCTL command
172 */
173#define SIO_RTEMS_SHOW_STATS    _IO('i', 250)
174
175/*
176 * Some extra prototypes
177 */
178int sethostname (char *name, size_t namelen);
179void domaininit (void *);
180void ifinit (void *);
181void ipintr (void);
182void arpintr (void);
183bool bootpc_init(bool, bool);
184int socket (int, int, int);
185int ioctl (int, ioctl_command_t, ...);
186
187/*
188 * Events used by networking routines.
189 * Everything will break if the application
190 * tries to use these events or if the `sleep'
191 * events are equal to any of the NETISR * events.
192 */
193#define SBWAIT_EVENT   RTEMS_EVENT_24
194#define SOSLEEP_EVENT  RTEMS_EVENT_25
195#define NETISR_IP_EVENT        (1L << NETISR_IP)
196#define NETISR_ARP_EVENT       (1L << NETISR_ARP)
197#define NETISR_EVENTS  (NETISR_IP_EVENT|NETISR_ARP_EVENT)
198#if (SBWAIT_EVENT & SOSLEEP_EVENT & NETISR_EVENTS)
199# error "Network event conflict"
200#endif
201
202struct socket *rtems_bsdnet_fdToSocket(int fd);
203
204#ifdef __cplusplus
205}
206#endif
207
208#endif /* _RTEMS_RTEMS_BSDNET_INTERNAL_H */
Note: See TracBrowser for help on using the repository browser.