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

Subversion Repositories plasma

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

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

Line No. Rev Author Line
1 155 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 205 rhoads
#ifndef __TCPIP_H__
13
#define __TCPIP_H__
14 155 rhoads
#define PACKET_SIZE           600
15 164 rhoads
#define FRAME_COUNT           100
16 173 rhoads
#define FRAME_COUNT_SYNC      50
17
#define FRAME_COUNT_SEND      10
18
#define FRAME_COUNT_RCV       5
19 294 rhoads
#define RETRANSMIT_TIME       110
20 173 rhoads
#define SOCKET_TIMEOUT        12
21 317 rhoads
#define SEND_WINDOW           7000
22
#define RECEIVE_WINDOW        5120
23 155 rhoads
 
24
typedef enum IPMode_e {
25
   IP_MODE_UDP,
26 208 rhoads
   IP_MODE_TCP,
27
   IP_MODE_PING
28 155 rhoads
} IPMode_e;
29
 
30
typedef enum IPState_e {
31
   IP_LISTEN,
32 208 rhoads
   IP_PING,
33 155 rhoads
   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 void (*IPFuncPtr)();
42
 
43
typedef struct IPFrame {
44
   uint8 packet[PACKET_SIZE];
45
   struct IPFrame *next, *prev;
46
   struct IPSocket *socket;
47
   uint32 seqEnd;
48 294 rhoads
   uint16 length;
49
   short  timeout;
50 155 rhoads
   uint8 state, retryCnt;
51
} IPFrame;
52
 
53
typedef struct IPSocket {
54
   struct IPSocket *next, *prev;
55
   IPState_e state;
56
   uint32 seq;
57
   uint32 seqReceived;
58 164 rhoads
   uint32 seqWindow;
59 155 rhoads
   uint32 ack;
60 317 rhoads
   uint32 ackProcessed;
61 155 rhoads
   uint32 timeout;
62 230 rhoads
   uint32 timeoutReset;
63 318 rhoads
   int resentDone;
64 317 rhoads
   int dontFlush;
65 155 rhoads
   uint8 headerSend[38];
66
   uint8 headerRcv[38];
67
   struct IPFrame *frameReadHead;
68
   struct IPFrame *frameReadTail;
69
   int readOffset;
70
   struct IPFrame *frameSend;
71
   int sendOffset;
72
   IPFuncPtr funcPtr;
73
   IPFuncPtr userFunc;
74
   void *userPtr;
75 317 rhoads
   void *userPtr2;
76 155 rhoads
   uint32 userData;
77 317 rhoads
   uint32 userData2;
78 155 rhoads
} IPSocket;
79
 
80
//ethernet.c
81 294 rhoads
void EthernetSendPacket(const unsigned char *packet, int length); //Windows
82
void EthernetInit(unsigned char MacAddress[6]);
83
int EthernetReceive(unsigned char *buffer, int length);
84
void EthernetTransmit(unsigned char *buffer, int length);
85 155 rhoads
 
86
//tcpip.c
87 295 rhoads
void IPInit(IPFuncPtr frameSendFunction, uint8 macAddress[6], char name[6]);
88 156 rhoads
IPFrame *IPFrameGet(int freeCount);
89 247 rhoads
int IPProcessEthernetPacket(IPFrame *frameIn, int length);
90 155 rhoads
void IPTick(void);
91
 
92 208 rhoads
IPSocket *IPOpen(IPMode_e mode, uint32 ipAddress, uint32 port, IPFuncPtr funcPtr);
93
void IPWriteFlush(IPSocket *socket);
94
uint32 IPWrite(IPSocket *socket, const uint8 *buf, uint32 length);
95
uint32 IPRead(IPSocket *socket, uint8 *buf, uint32 length);
96
void IPClose(IPSocket *socket);
97 317 rhoads
#ifdef IPPRINTF
98
void IPPrintf(IPSocket *socket, char *message, int arg0, int arg1, int arg2, int arg3);
99
#else
100
void IPPrintf(IPSocket *socket, char *message, ...);
101
#endif
102 250 rhoads
void IPResolve(char *name, IPFuncPtr resolvedFunc, void *arg);
103 208 rhoads
uint32 IPAddressSelf(void);
104 155 rhoads
 
105
//http.c
106
#define HTML_LENGTH_CALLBACK  -2
107
#define HTML_LENGTH_LIST_END  -1
108
typedef struct PageEntry_s {
109
   const char *name;
110
   int length;
111
   const char *page;
112
} PageEntry_t;
113
void HttpInit(const PageEntry_t *Pages, int UseFiles);
114
 
115 208 rhoads
//html.c
116
void HtmlInit(int UseFiles);
117
 
118
//netutil.c
119
void FtpdInit(int UseFiles);
120
IPSocket *FtpTransfer(uint32 ip, char *user, char *passwd,
121
                      char *filename, uint8 *buf, int size,
122
                      int send, void (*callback)(uint8 *data, int size));
123
void TftpdInit(void);
124
IPSocket *TftpTransfer(uint32 ip, char *filename, uint8 *buffer, int size,
125
                       void (*callback)(uint8 *data, int bytes));
126
void ConsoleInit(void);
127 325 rhoads
void *IPNameValue(const char *name, void *value);
128 208 rhoads
 
129 205 rhoads
#endif //__TCPIP_H__

powered by: WebSVN 2.1.0

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