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

Subversion Repositories mlite

[/] [mlite/] [trunk/] [kernel/] [tcpip.h] - Blame information for rev 205

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
   IP_MODE_TCP
26
} IPMode_e;
27
 
28
typedef enum IPState_e {
29
   IP_LISTEN,
30
   IP_UDP,
31
   IP_SYN,
32
   IP_TCP,
33
   IP_FIN_CLIENT,
34
   IP_FIN_SERVER,
35
   IP_CLOSED
36
} IPState_e;
37
 
38
typedef void (*IPFuncPtr)();
39
 
40
typedef struct IPFrame {
41
   uint8 packet[PACKET_SIZE];
42
   struct IPFrame *next, *prev;
43
   struct IPSocket *socket;
44
   uint32 seqEnd;
45
   uint16 length, timeout;
46
   uint8 state, retryCnt;
47
} IPFrame;
48
 
49
typedef struct IPSocket {
50
   struct IPSocket *next, *prev;
51
   IPState_e state;
52
   uint32 seq;
53
   uint32 seqReceived;
54 164 rhoads
   uint32 seqWindow;
55 155 rhoads
   uint32 ack;
56
   uint32 timeout;
57
   uint8 headerSend[38];
58
   uint8 headerRcv[38];
59
   struct IPFrame *frameReadHead;
60
   struct IPFrame *frameReadTail;
61
   int readOffset;
62
   struct IPFrame *frameSend;
63
   int sendOffset;
64
   IPFuncPtr funcPtr;
65
   IPFuncPtr userFunc;
66
   void *userPtr;
67
   uint32 userData;
68
} IPSocket;
69
 
70
//ethernet.c
71
void EthernetSendPacket(const unsigned char *packet, int length);
72
 
73
//tcpip.c
74
void IPInit(IPFuncPtr FrameSendFunction);
75 156 rhoads
IPFrame *IPFrameGet(int freeCount);
76 155 rhoads
int IPProcessEthernetPacket(IPFrame *frameIn);
77
void IPTick(void);
78
 
79
IPSocket *IPOpen(IPMode_e Mode, uint32 IPAddress, uint32 Port, IPFuncPtr funcPtr);
80
void IPWriteFlush(IPSocket *Socket);
81
uint32 IPWrite(IPSocket *Socket, const uint8 *Buf, uint32 Length);
82
uint32 IPRead(IPSocket *Socket, uint8 *Buf, uint32 Length);
83
void IPClose(IPSocket *Socket);
84
uint32 IPResolve(char *Name, IPFuncPtr resolvedFunc);
85
 
86
//http.c
87
#define HTML_LENGTH_CALLBACK  -2
88
#define HTML_LENGTH_LIST_END  -1
89
typedef struct PageEntry_s {
90
   const char *name;
91
   int length;
92
   const char *page;
93
} PageEntry_t;
94
void HttpInit(const PageEntry_t *Pages, int UseFiles);
95
 
96 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.