NetBurner 3.1
iointernal.h
Go to the documentation of this file.
1 /*NB_REVISION*/
2 
3 /*NB_COPYRIGHT*/
4 
16 #ifndef _NB_IOINTERNALS_H
17 #define _NB_IOINTERNALS_H
18 
19 /*
20  ******************************************************************************
21  *
22  * Definitions
23  *
24  ******************************************************************************
25  */
26 #define IOINTERNALS_FRAMEWORK_TAG ((unsigned int)0x10127EB6)
27 
28 /*
29  ******************************************************************************
30  *
31  * Structures
32  *
33  ******************************************************************************
34  */
35 /*
36  * Extra FD Framework
37  * tag - Unique tag (Must be IOINTERNALS_FRAMEWORK_TAG)
38  * ioSocketNumber - I/O socket number
39  * extraSocketNumber - Extra socket number
40  *
41  * Notes:
42  * Must be at the very beginning of any extra data passed to GetExtraFD
43  */
44 typedef struct _IoFrameworkStruct
45 {
46  unsigned int tag;
47  int ioSocketNumber;
48  int extraSocketNumber;
49 
50 } __attribute__((packed)) IoFrameworkStruct;
51 
52 /*
53  * I/O Expansion Structure
54  * read - read function
55  * write - write function
56  * close - close function
57  * extra - Control struct starts with IoFrameworkStruct
58  *
59  * Notes:
60  * Expanded routines for library read, write and close
61  */
62 struct IoExpandStruct
63 {
64  int (*read)(int fd, char *buf, int nbytes);
65  int (*write)(int fd, const char *buf, int nbytes);
66  int (*close)(int fd);
67  int (*peek)(int fd, char *buf);
68  void *extra;
69  uint8_t bPeeked;
70  char peekdata;
71 } __attribute__((packed));
72 
73 /****************************************************************************
74 
75  Acquire/Release/Access expansion file descriptor
76 
77  Parameters:
78  extra_data - Control data structure beginning with
79  IoFrameworkStruct
80  pFuncs - Expanded I/O routines
81 
82  fd - Expanded file descriptor
83 
84  Return:
85  Acquired fd > EXTRA_IO_OFFSET OK, else -1 for none
86 
87  ****************************************************************************/
88 
99 int GetExtraFD(void *extra_data, struct IoExpandStruct *pFuncs);
100 
108 void *GetExtraData(int fd);
109 
116 void FreeExtraFd(int fd);
117 
124 int GetFreeExtraFDCount();
125 
126 /*
127  ***************************************************************************
128 
129  I/O subsystem notification support for use by expanded I/O routines
130 
131  Parameters:
132  fd - Expanded file descriptor
133 
134  Return:
135  None
136 
137  ***************************************************************************
138  */
139 void SetDataAvail(int fd);
140 void ClrDataAvail(int fd);
141 
142 void SetWriteAvail(int fd);
143 void ClrWriteAvail(int fd);
144 
145 void SetHaveError(int fd);
146 void ClrHaveError(int fd);
147 
148 #endif
int GetFreeExtraFDCount()
Returns the number of free file descriptors.
Definition: extraio.cpp:104
int write(int fd, const char *buf, int nbytes)
This function writes data to the stream associated with a file descriptor (fd).
Definition: fileio.cpp:152
void * GetExtraData(int fd)
Returns the extra structure value from IoExpandStruct associated with the file descriptor.
Definition: extraio.cpp:92
void FreeExtraFd(int fd)
Free a file descriptor and associated resources.
Definition: extraio.cpp:81
int read(int fd, char *buf, int nbytes)
This function reads data from a file descriptor (fd), and will block forever until at least one byte ...
Definition: fileio.cpp:288
int peek(int fd, char *c)
This function peeks at data from a file descriptor (fd), and will block forever until at least one by...
Definition: fileio.cpp:232
int close(int fd)
This function closes the resources associated with a file descriptor (fd). This can be a TCP socket o...
Definition: fileio.cpp:99
int GetExtraFD(void *extra_data, struct IoExpandStruct *pFuncs)
Returns a file descriptor for the structure passed as the IoExpandStruct. FreeExtraFd( ) will release...
Definition: extraio.cpp:58