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

Subversion Repositories plasma

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

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

powered by: WebSVN 2.1.0

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