OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [kernel/] [tcpip.h] - Blame information for rev 425

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 400 rhoads
/*--------------------------------------------------------------------
2
 * TITLE: Plasma TCP/IP Protocol Stack
3
 * AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
 * DATE CREATED: 4/22/06
5
 * FILENAME: tcpip.h
6
 * PROJECT: Plasma CPU core
7
 * COPYRIGHT: Software placed into the public domain by the author.
8
 *    Software 'as is' without warranty.  Author liable for nothing.
9
 * DESCRIPTION:
10
 *    Plasma TCP/IP Protocol Stack
11
 *--------------------------------------------------------------------*/
12
#ifndef __TCPIP_H__
13
#define __TCPIP_H__
14
#define PACKET_SIZE           600
15
#define FRAME_COUNT           100
16 419 rhoads
#define FRAME_COUNT_SYNC      15
17 400 rhoads
#define FRAME_COUNT_SEND      10
18
#define FRAME_COUNT_RCV       5
19 423 rhoads
#define RETRANSMIT_TIME       60
20 416 rhoads
#define SOCKET_TIMEOUT        10
21 400 rhoads
#define SEND_WINDOW           7000
22 422 rhoads
#define RECEIVE_WINDOW        (536*10)
23 400 rhoads
 
24
typedef enum IPMode_e {
25
   IP_MODE_UDP,
26
   IP_MODE_TCP,
27
   IP_MODE_PING
28
} IPMode_e;
29
 
30
typedef enum IPState_e {
31
   IP_LISTEN,
32
   IP_PING,
33
   IP_UDP,
34
   IP_SYN,
35
   IP_TCP,
36
   IP_FIN_CLIENT,
37
   IP_FIN_SERVER,
38
   IP_CLOSED
39
} IPState_e;
40
 
41
typedef struct IPSocket IPSocket;
42
typedef void (*IPSendFuncPtr)(uint8 *packet, int length);
43
typedef void (*IPSockFuncPtr)(IPSocket *sock);
44
typedef void (*IPCallbackPtr)(IPSocket *sock, uint8 *buf, int bytes);
45
 
46
typedef struct IPFrame {
47
   uint8 packet[PACKET_SIZE];
48
   struct IPFrame *next, *prev;
49
   struct IPSocket *socket;
50
   uint32 seqEnd;
51
   uint16 length;
52
   short  timeout;
53
   uint8 state, retryCnt;
54
   uint8 pad1, pad2;
55
} IPFrame;
56
 
57
struct IPSocket {
58
   struct IPSocket *next, *prev;
59
   IPState_e state;
60
   uint32 seq;
61
   uint32 seqReceived;
62
   uint32 seqWindow;
63
   uint32 ack;
64
   uint32 ackProcessed;
65
   uint32 timeout;
66
   uint32 timeoutReset;
67
   int resentDone;
68
   int dontFlush;
69
   uint8 headerSend[38];
70
   uint8 headerRcv[38];
71
   struct IPFrame *frameReadHead;
72
   struct IPFrame *frameReadTail;
73 419 rhoads
   struct IPFrame *frameFutureHead;
74
   struct IPFrame *frameFutureTail;
75 400 rhoads
   int readOffset;
76
   struct IPFrame *frameSend;
77
   int sendOffset;
78 361 rhoads
   void *fileOut;
79
   void *fileIn;
80 400 rhoads
   IPSockFuncPtr funcPtr;
81
   IPCallbackPtr userFunc;
82
   void *userPtr;
83
   void *userPtr2;
84
   uint32 userData;
85
   uint32 userData2;
86 416 rhoads
   OS_Semaphore_t *userSemaphore;
87 400 rhoads
};
88
 
89
//ethernet.c
90
void EthernetSendPacket(const unsigned char *packet, int length); //Windows
91
void EthernetInit(unsigned char MacAddress[6]);
92
int EthernetReceive(unsigned char *buffer, int length);
93
void EthernetTransmit(unsigned char *buffer, int length);
94
 
95
//tcpip.c
96
void IPInit(IPSendFuncPtr frameSendFunction, uint8 macAddress[6], char name[6]);
97
IPFrame *IPFrameGet(int freeCount);
98
int IPProcessEthernetPacket(IPFrame *frameIn, int length);
99
void IPTick(void);
100
 
101
IPSocket *IPOpen(IPMode_e mode, uint32 ipAddress, uint32 port, IPSockFuncPtr funcPtr);
102
void IPWriteFlush(IPSocket *socket);
103
uint32 IPWrite(IPSocket *socket, const uint8 *buf, uint32 length);
104
uint32 IPRead(IPSocket *socket, uint8 *buf, uint32 length);
105
void IPClose(IPSocket *socket);
106 416 rhoads
#ifdef INSIDE_TCPIP
107
int IPPrintf(IPSocket *socket, char *message,
108
   int arg0, int arg1, int arg2, int arg3,
109
   int arg4, int arg5, int arg6, int arg7);
110 400 rhoads
#else
111 416 rhoads
int IPPrintf(IPSocket *socket, char *message, ...);
112 400 rhoads
#endif
113
void IPResolve(char *name, IPCallbackPtr resolvedFunc, void *arg);
114
uint32 IPAddressSelf(void);
115
 
116
//http.c
117
#define HTML_LENGTH_CALLBACK  -2
118
#define HTML_LENGTH_LIST_END  -1
119
typedef struct PageEntry_s {
120
   const char *name;
121
   int length;
122
   const char *page;
123
} PageEntry_t;
124
void HttpInit(const PageEntry_t *Pages, int UseFiles);
125
 
126
//html.c
127
void HtmlInit(int UseFiles);
128
 
129
//netutil.c
130
void FtpdInit(int UseFiles);
131
IPSocket *FtpTransfer(uint32 ip, char *user, char *passwd,
132
                      char *filename, uint8 *buf, int size,
133
                      int send, IPCallbackPtr callback);
134
void TftpdInit(void);
135
IPSocket *TftpTransfer(uint32 ip, char *filename, uint8 *buffer, int size,
136
                       IPCallbackPtr callback);
137
void ConsoleInit(void);
138
void *IPNameValue(const char *name, void *value);
139 416 rhoads
int ConsoleGetch(void);
140 424 rhoads
void ConsoleRun(IPSocket *socket, char *argv[]);
141 416 rhoads
#ifndef INSIDE_NETUTIL
142
int ConsoleScanf(char *format, ...);
143
int ConsolePrintf(char *format, ...);
144
#endif
145 400 rhoads
 
146
#endif //__TCPIP_H__

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.