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

Subversion Repositories plasma

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

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_WINDOW    50
17
#define FRAME_COUNT_SYNC      50
18
#define FRAME_COUNT_SEND      10
19
#define FRAME_COUNT_RCV       5
20 164 rhoads
#define RETRANSMIT_TIME       3
21 173 rhoads
#define SOCKET_TIMEOUT        12
22 155 rhoads
 
23
typedef enum IPMode_e {
24
   IP_MODE_UDP,
25 208 rhoads
   IP_MODE_TCP,
26
   IP_MODE_PING
27 155 rhoads
} IPMode_e;
28
 
29
typedef enum IPState_e {
30
   IP_LISTEN,
31 208 rhoads
   IP_PING,
32 155 rhoads
   IP_UDP,
33
   IP_SYN,
34
   IP_TCP,
35
   IP_FIN_CLIENT,
36
   IP_FIN_SERVER,
37
   IP_CLOSED
38
} IPState_e;
39
 
40
typedef void (*IPFuncPtr)();
41
 
42
typedef struct IPFrame {
43
   uint8 packet[PACKET_SIZE];
44
   struct IPFrame *next, *prev;
45
   struct IPSocket *socket;
46
   uint32 seqEnd;
47
   uint16 length, timeout;
48
   uint8 state, retryCnt;
49
} IPFrame;
50
 
51
typedef struct IPSocket {
52
   struct IPSocket *next, *prev;
53
   IPState_e state;
54
   uint32 seq;
55
   uint32 seqReceived;
56 164 rhoads
   uint32 seqWindow;
57 155 rhoads
   uint32 ack;
58
   uint32 timeout;
59
   uint8 headerSend[38];
60
   uint8 headerRcv[38];
61
   struct IPFrame *frameReadHead;
62
   struct IPFrame *frameReadTail;
63
   int readOffset;
64
   struct IPFrame *frameSend;
65
   int sendOffset;
66
   IPFuncPtr funcPtr;
67
   IPFuncPtr userFunc;
68
   void *userPtr;
69
   uint32 userData;
70
} IPSocket;
71
 
72
//ethernet.c
73
void EthernetSendPacket(const unsigned char *packet, int length);
74
 
75
//tcpip.c
76 208 rhoads
void IPInit(IPFuncPtr frameSendFunction);
77 156 rhoads
IPFrame *IPFrameGet(int freeCount);
78 155 rhoads
int IPProcessEthernetPacket(IPFrame *frameIn);
79
void IPTick(void);
80
 
81 208 rhoads
IPSocket *IPOpen(IPMode_e mode, uint32 ipAddress, uint32 port, IPFuncPtr funcPtr);
82
void IPWriteFlush(IPSocket *socket);
83
uint32 IPWrite(IPSocket *socket, const uint8 *buf, uint32 length);
84
uint32 IPRead(IPSocket *socket, uint8 *buf, uint32 length);
85
void IPClose(IPSocket *socket);
86
void IPPrintf(IPSocket *socket, char *message);
87
uint32 IPResolve(char *mame, IPFuncPtr resolvedFunc, void *arg);
88
uint32 IPAddressSelf(void);
89 155 rhoads
 
90
//http.c
91
#define HTML_LENGTH_CALLBACK  -2
92
#define HTML_LENGTH_LIST_END  -1
93
typedef struct PageEntry_s {
94
   const char *name;
95
   int length;
96
   const char *page;
97
} PageEntry_t;
98
void HttpInit(const PageEntry_t *Pages, int UseFiles);
99
 
100 208 rhoads
//html.c
101
void HtmlInit(int UseFiles);
102
 
103
//netutil.c
104
typedef struct {
105
   char *name;
106
   int mode;
107
   void (*func)();
108
} TelnetFunc_t;
109
void FtpdInit(int UseFiles);
110
IPSocket *FtpTransfer(uint32 ip, char *user, char *passwd,
111
                      char *filename, uint8 *buf, int size,
112
                      int send, void (*callback)(uint8 *data, int size));
113
void TftpdInit(void);
114
IPSocket *TftpTransfer(uint32 ip, char *filename, uint8 *buffer, int size,
115
                       void (*callback)(uint8 *data, int bytes));
116
void TelnetInit(TelnetFunc_t *funcList);
117
void ConsoleInit(void);
118
 
119 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.