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

Subversion Repositories plasma

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

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 381 rhoads
#define SOCKET_TIMEOUT        15
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 361 rhoads
   void *fileOut;
73
   void *fileIn;
74 155 rhoads
   IPFuncPtr funcPtr;
75
   IPFuncPtr userFunc;
76
   void *userPtr;
77 317 rhoads
   void *userPtr2;
78 155 rhoads
   uint32 userData;
79 317 rhoads
   uint32 userData2;
80 155 rhoads
} IPSocket;
81
 
82
//ethernet.c
83 294 rhoads
void EthernetSendPacket(const unsigned char *packet, int length); //Windows
84
void EthernetInit(unsigned char MacAddress[6]);
85
int EthernetReceive(unsigned char *buffer, int length);
86
void EthernetTransmit(unsigned char *buffer, int length);
87 155 rhoads
 
88
//tcpip.c
89 295 rhoads
void IPInit(IPFuncPtr frameSendFunction, uint8 macAddress[6], char name[6]);
90 156 rhoads
IPFrame *IPFrameGet(int freeCount);
91 247 rhoads
int IPProcessEthernetPacket(IPFrame *frameIn, int length);
92 155 rhoads
void IPTick(void);
93
 
94 208 rhoads
IPSocket *IPOpen(IPMode_e mode, uint32 ipAddress, uint32 port, IPFuncPtr funcPtr);
95
void IPWriteFlush(IPSocket *socket);
96
uint32 IPWrite(IPSocket *socket, const uint8 *buf, uint32 length);
97
uint32 IPRead(IPSocket *socket, uint8 *buf, uint32 length);
98
void IPClose(IPSocket *socket);
99 317 rhoads
#ifdef IPPRINTF
100
void IPPrintf(IPSocket *socket, char *message, int arg0, int arg1, int arg2, int arg3);
101
#else
102
void IPPrintf(IPSocket *socket, char *message, ...);
103
#endif
104 250 rhoads
void IPResolve(char *name, IPFuncPtr resolvedFunc, void *arg);
105 208 rhoads
uint32 IPAddressSelf(void);
106 155 rhoads
 
107
//http.c
108
#define HTML_LENGTH_CALLBACK  -2
109
#define HTML_LENGTH_LIST_END  -1
110
typedef struct PageEntry_s {
111
   const char *name;
112
   int length;
113
   const char *page;
114
} PageEntry_t;
115
void HttpInit(const PageEntry_t *Pages, int UseFiles);
116
 
117 208 rhoads
//html.c
118
void HtmlInit(int UseFiles);
119
 
120
//netutil.c
121
void FtpdInit(int UseFiles);
122
IPSocket *FtpTransfer(uint32 ip, char *user, char *passwd,
123
                      char *filename, uint8 *buf, int size,
124
                      int send, void (*callback)(uint8 *data, int size));
125
void TftpdInit(void);
126
IPSocket *TftpTransfer(uint32 ip, char *filename, uint8 *buffer, int size,
127
                       void (*callback)(uint8 *data, int bytes));
128
void ConsoleInit(void);
129 325 rhoads
void *IPNameValue(const char *name, void *value);
130 208 rhoads
 
131 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.