summaryrefslogtreecommitdiff
path: root/system/alpha/h/ip.h
blob: c4ccc5de389dc2f10d3550c5e084caac7d07e9a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#ifndef __IP_H_LOADED
#define __IP_H_LOADED
/*****************************************************************************

       Copyright © 1993, 1994 Digital Equipment Corporation,
                       Maynard, Massachusetts.

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the copyright notice and this permission notice appear in all copies
of software and supporting documentation, and that the name of Digital not
be used in advertising or publicity pertaining to distribution of the software
without specific, written prior permission. Digital grants this permission
provided that you prominently mark, as not part of the original, any
modifications made to this software or documentation.

Digital Equipment Corporation disclaims all warranties and/or guarantees
with regard to this software, including all implied warranties of fitness for
a particular purpose and merchantability, and makes no representations
regarding the use of, or the results of the use of, the software and
documentation in terms of correctness, accuracy, reliability, currentness or
otherwise; and you rely on the software, documentation and results solely at
your own risk.

******************************************************************************/

/*
 * $Id: ip.h,v 1.1.1.1 1997/10/30 23:27:15 verghese Exp $
 */

/*
 * MODULE DESCRIPTION:
 *
 *     IP protocol interface for EB64 monitor
 *
 * HISTORY:
 *
 * $Log: ip.h,v $
 * Revision 1.1.1.1  1997/10/30 23:27:15  verghese
 * current 10/29/97
 *
 * Revision 1.5  1994/08/05  20:13:47  fdh
 * Updated Copyright header and RCS $Id: identifier.
 *
 * Revision 1.4  1994/06/28  20:08:21  fdh
 * Modified filenames and build precedure to fit into a FAT filesystem.
 *
 * Revision 1.3  1994/06/20  14:18:59  fdh
 * Fixup header file preprocessor #include conditionals.
 *
 * Revision 1.2  1994/01/21  09:45:59  rusling
 * Added #ifdef <filename>_H around the module.
 * Additionally, any included files are not ifdef'd
 * *before* they're included (ie address.h).
 *
 * Revision 1.1  1993/08/06  10:30:54  berent
 * Initial revision
 *
 *
 */

#include "address.h"


/* ip_init - initialise ip protocol for an ethernet device
 *
 * Argument:
 *    device_no - device for which IP is to be initialised.
 */
extern void ip_init(int device_no);

/* ip_set_device_addr - tells ip a device's ip address.
 *
 * Arguments:
 *     device_no - device number
 *     ip        - ip address
 */
extern void ip_set_device_addr(int device_no,ip_addr ip);

/*
 * Prototype for packet processing functions
 *
 * Arguments to packet processing functions:
 *     protocol_data - protocol data passed to module when protocol registered
 *     device_no     - device on which packet was received;
 *     packet        - packet, with IP header removed;
 *     size          - size of packet;
 *     source        - source IP address of packet;
 *     destination   - IP address to which the packet was addressed; this is needed by UDP.
 *     frame_buffer  - original buffer containing packet.
 *     balance_buffer- buffer returned to maintain buffer balance.
 *
 * DESCRIPTION:
 *     The packet processing functions process a received protocol packet. To avoid
 *     buffer shortages they are always passed the buffer containing the packet in
 *     frame_buffer.  They must return either this buffer, or another buffer, in
 *     balance buffer. The ip module will never access frame_buffer after
 *     calling a packet processing function; and the protocol modules must not
 *     access the returned balance_buffer after returning from this function.
 *
 */
typedef void (* ip_packet_handler)(void * protocol_data,
                                   int device_no,
                                   unsigned char * packet,
                                   int size,
                                   ip_addr source,
                                   ip_addr destination,
                                   unsigned char frame_buffer[ETHER_BUFFER_SIZE],
                                   unsigned char ** balance_buffer);

/* ip_register_protocol - registers an IP protocol to be recognised in received frames by this module
 *
 * Arguments:
 *
 *    device_no             - device number on which this protocol can be received
 *    protocol_id           - protocol id to be recognised by this module
 *    processing_function   - function to process received packets; if NULL cancels registration of protocol.
 *    protocol_data         - arbitrary data to be passed back when a packet is received
 *
 * Returned value:
 *    TRUE   - protocol registered
 *    FALSE  - unable to register protocol
 */
extern int ip_register_protocol(int device_no,
                                ip_protocol_id protocol_id,
                                ip_packet_handler processing_function,
                                void * protocol_data);

/* ip_write - sends a packet on an IP network
 *
 * Arguments:
 *
 *    device_no - device on which to send the packet
 *    packet    - pointer to data packet to be sent
 *    destination - destination address for packet
 *    protocol_id - protocol id for packet
 *    size        - size of packet
 *    frame_buffer - buffer containing packet
 *    balance_buffer - buffer returned to maintain buffer balance
 *
 * Return values:
 *
 *    TRUE  - send successfull
 *    FALSE - Error occured
 *
 * DESCRIPTION:
 *    This function writes an ip data packet to the device  To maintain the caller's
 *    pool of buffers the driver must give the caller an unused buffer (balance_buffer)
 *    in return for the buffer containing the frame to be transmitted.
 *
 *    If the send succeeds then frame_buffer must not be accessed by the caller after this
 *    call.  If the send can't be queued then frame_buffer will remain valid and
 *    the returned value of balance_buffer is undefined and must not be used.
 *
 */
extern int ip_write(int device_no,
                    unsigned char * packet,
                    ip_addr destination,
                    ip_protocol_id protocol_id,
                    int size,
                    unsigned char frame_buffer[ETHER_BUFFER_SIZE],
                    unsigned char ** balance_buffer);


/* ip_data_offset - returns the offset at which ip data should be placed in a new ethernet frame
 *
 * Return value:
 *    Offset.
 */
extern int ip_data_offset(void);

/* ip_get_address - gets the address that will be used as the source address of transmitted packets.
 *
 * Arguments:
 *     device_no - device number of device on which packet is to be sent.
 *     ip        - returned ip address
 *
 * Note:
 *     This function exists so that UDP can calculate header checksums.
 */
extern void ip_get_device_address(int device_no, ip_addr ip);

/* ip_printaddress - utility to print an ethernet address
 *
 * Argument:
 *    address - IP address to be printed
 */
extern void ip_printaddress(mac_addr address);

#endif /* __IP_H_LOADED */