Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/**
22
 ------------
23
 CVS :        $Id: udpip.h,v 1.1.1.1 2002-03-29 14:12:51 pj Exp $
24
 
25
 File:        $File$
26
 Revision:    $Revision: 1.1.1.1 $
27
 Last update: $Date: 2002-03-29 14:12:51 $
28
 ------------
29
 
30
**/
31
 
32
/*
33
 * Copyright (C) 2000 Luca Abeni
34
 *
35
 * This program is free software; you can redistribute it and/or modify
36
 * it under the terms of the GNU General Public License as published by
37
 * the Free Software Foundation; either version 2 of the License, or
38
 * (at your option) any later version.
39
 *
40
 * This program is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43
 * GNU General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU General Public License
46
 * along with this program; if not, write to the Free Software
47
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
48
 *
49
 */
50
 
51
/* Project:     HARTIK 3.0                                      */
52
/* Description: Hard Real TIme Kernel for 8086 compatible       */
53
/* Author:      Luca Abeni                                      */
54
/* Date:        25/9/96                                         */
55
 
56
/* File:        UDPIP.h                                         */
57
/* Revision:    4.0                                             */
58
 
59
 
60
 
61
/* First, include the net general definitions */
62
 
63
#include <modules/hartport.h>
64
#include <drivers/net.h>
65
 
66
#ifndef __UDPIP_H__
67
#define __UDPIP_H__
68
 
69
#ifdef __cplusplus
70
extern "C" {
71
#endif
72
 
73
#define net_setudpip(m,localaddr) {net_setprotocol(&m, ip_init, localaddr); net_setprotocol(&m, udp_init, NULL);}
74
 
75
typedef struct ip_addr{
76
    BYTE ad[4];
77
} IP_ADDR;
78
 
79
#define IP_ERROR_BASE   (ETH_ERROR_BASE + 20)
80
#define IP_INIT_ERROR   (0 + IP_ERROR_BASE)
81
 
82
#define IP_UDP_TYPE     17
83
#define IP_TCP_TYPE     6
84
 
85
#define setIpAddr(q,w) memcpy(q.ad,w.ad,sizeof(IP_ADDR))
86
#define getVers(b)      ((b) >> 4)
87
#define getHlen(b)      (b & 0x0f)
88
#define getFlags(w)     ((w) >> 13)
89
#define getFrOffset(w)  (w & 0x1fff)
90
 
91
typedef struct ip_header {
92
    BYTE vers_hlen;
93
    BYTE servType;
94
    WORD lenght;
95
    WORD ident;
96
    WORD flags_frOffset;
97
    BYTE ttl;
98
    BYTE protocol;
99
    WORD headChecksum;
100
    IP_ADDR source;
101
    IP_ADDR dest;
102
} IP_HEADER;
103
 
104
#define IP_MAX_ENTRIES 2
105
typedef struct ip_table{
106
    BYTE protocol;
107
    void (*rfun)(void *m);
108
} IP_TABLE;
109
 
110
void ip_print_header(IP_HEADER *p);
111
int ip_compAddr(IP_ADDR ip1, IP_ADDR ip2);
112
int ip_str2addr(char *a, IP_ADDR *ip);
113
void *ip_getFDB(void *pkt);
114
int ip_setProtocol(BYTE p, void (*recv)(void *m));
115
void ip_send(IP_ADDR dest, void *pkt, WORD len);
116
void ip_init(void *la);
117
IP_ADDR *ip_getAddr();
118
 
119
 
120
/***************************************************************************/
121
/*                                                                         */
122
/*                              UDP                                        */
123
/*                                                                         */
124
/***************************************************************************/
125
 
126
typedef struct udp_addr{
127
    IP_ADDR s_addr;
128
    WORD s_port;
129
} UDP_ADDR;
130
 
131
 
132
typedef struct udp_header{
133
    WORD s_port;
134
    WORD d_port;
135
    WORD mlen;
136
    WORD checksum;
137
} UDP_HEADER;
138
 
139
typedef struct pseudo_hd {
140
    IP_ADDR source;
141
    IP_ADDR dest;
142
    BYTE zero;
143
    BYTE protocoll;
144
    WORD len;
145
} PSEUDO_HD;
146
 
147
typedef struct udp_msg{
148
    WORD mlen;
149
    UDP_ADDR addr;
150
    void *buff;
151
} UDP_MSG;
152
 
153
typedef struct udp_table{
154
    WORD port;
155
    BYTE valid;
156
    PORT hport;
157
    PORT pport;
158
    BYTE notify;
159
    int (*notify_fun)(int l, BYTE *buff, void *p);
160
    void *notify_par;
161
} UDP_TABLE;
162
 
163
void udp_init(void *dummy);
164
int udp_recvfrom(int s, char *buff, UDP_ADDR *from);
165
int udp_sendto(int s, char *buff, int nbytes, UDP_ADDR *to);
166
int udp_bind(UDP_ADDR *a, IP_ADDR *bindlist);
167
int udp_notify(int s, int (*f)(int len, BYTE *buff, void *p), void *p);
168
 
169
#ifdef __cplusplus
170
};
171
#endif
172
 
173
 
174
#endif
175