User | Revision | Line number | New contents of line |
mbed714 |
0:d616ece2d859
|
1
|
/*
|
mbed714 |
0:d616ece2d859
|
2
|
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
mbed714 |
0:d616ece2d859
|
3
|
* All rights reserved.
|
mbed714 |
0:d616ece2d859
|
4
|
*
|
mbed714 |
0:d616ece2d859
|
5
|
* Redistribution and use in source and binary forms, with or without modification,
|
mbed714 |
0:d616ece2d859
|
6
|
* are permitted provided that the following conditions are met:
|
mbed714 |
0:d616ece2d859
|
7
|
*
|
mbed714 |
0:d616ece2d859
|
8
|
* 1. Redistributions of source code must retain the above copyright notice,
|
mbed714 |
0:d616ece2d859
|
9
|
* this list of conditions and the following disclaimer.
|
mbed714 |
0:d616ece2d859
|
10
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
mbed714 |
0:d616ece2d859
|
11
|
* this list of conditions and the following disclaimer in the documentation
|
mbed714 |
0:d616ece2d859
|
12
|
* and/or other materials provided with the distribution.
|
mbed714 |
0:d616ece2d859
|
13
|
* 3. The name of the author may not be used to endorse or promote products
|
mbed714 |
0:d616ece2d859
|
14
|
* derived from this software without specific prior written permission.
|
mbed714 |
0:d616ece2d859
|
15
|
*
|
mbed714 |
0:d616ece2d859
|
16
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
mbed714 |
0:d616ece2d859
|
17
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
mbed714 |
0:d616ece2d859
|
18
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
mbed714 |
0:d616ece2d859
|
19
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
mbed714 |
0:d616ece2d859
|
20
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
mbed714 |
0:d616ece2d859
|
21
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
mbed714 |
0:d616ece2d859
|
22
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
mbed714 |
0:d616ece2d859
|
23
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
mbed714 |
0:d616ece2d859
|
24
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
mbed714 |
0:d616ece2d859
|
25
|
* OF SUCH DAMAGE.
|
mbed714 |
0:d616ece2d859
|
26
|
*
|
mbed714 |
0:d616ece2d859
|
27
|
* This file is part of the lwIP TCP/IP stack.
|
mbed714 |
0:d616ece2d859
|
28
|
*
|
mbed714 |
0:d616ece2d859
|
29
|
* Author: Adam Dunkels <adam@sics.se>
|
mbed714 |
0:d616ece2d859
|
30
|
*
|
mbed714 |
0:d616ece2d859
|
31
|
*/
|
mbed714 |
0:d616ece2d859
|
32
|
#ifndef __LWIP_RAW_H__
|
mbed714 |
0:d616ece2d859
|
33
|
#define __LWIP_RAW_H__
|
mbed714 |
0:d616ece2d859
|
34
|
|
mbed714 |
0:d616ece2d859
|
35
|
#include "lwip/opt.h"
|
mbed714 |
0:d616ece2d859
|
36
|
|
mbed714 |
0:d616ece2d859
|
37
|
#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
|
mbed714 |
0:d616ece2d859
|
38
|
|
mbed714 |
0:d616ece2d859
|
39
|
#include "lwip/pbuf.h"
|
mbed714 |
0:d616ece2d859
|
40
|
#include "lwip/def.h"
|
mbed714 |
0:d616ece2d859
|
41
|
#include "lwip/ip.h"
|
mbed714 |
0:d616ece2d859
|
42
|
#include "lwip/ip_addr.h"
|
mbed714 |
0:d616ece2d859
|
43
|
|
mbed714 |
0:d616ece2d859
|
44
|
#ifdef __cplusplus
|
mbed714 |
0:d616ece2d859
|
45
|
extern "C" {
|
mbed714 |
0:d616ece2d859
|
46
|
#endif
|
mbed714 |
0:d616ece2d859
|
47
|
|
mbed714 |
0:d616ece2d859
|
48
|
struct raw_pcb;
|
mbed714 |
0:d616ece2d859
|
49
|
|
mbed714 |
0:d616ece2d859
|
50
|
/** Function prototype for raw pcb receive callback functions.
|
mbed714 |
0:d616ece2d859
|
51
|
* @param arg user supplied argument (raw_pcb.recv_arg)
|
mbed714 |
0:d616ece2d859
|
52
|
* @param pcb the raw_pcb which received data
|
mbed714 |
0:d616ece2d859
|
53
|
* @param p the packet buffer that was received
|
mbed714 |
0:d616ece2d859
|
54
|
* @param addr the remote IP address from which the packet was received
|
mbed714 |
0:d616ece2d859
|
55
|
* @return 1 if the packet was 'eaten' (aka. deleted),
|
mbed714 |
0:d616ece2d859
|
56
|
* 0 if the packet lives on
|
mbed714 |
0:d616ece2d859
|
57
|
* If returning 1, the callback is responsible for freeing the pbuf
|
mbed714 |
0:d616ece2d859
|
58
|
* if it's not used any more.
|
mbed714 |
0:d616ece2d859
|
59
|
*/
|
mbed714 |
0:d616ece2d859
|
60
|
typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
mbed714 |
0:d616ece2d859
|
61
|
ip_addr_t *addr);
|
mbed714 |
0:d616ece2d859
|
62
|
|
mbed714 |
0:d616ece2d859
|
63
|
struct raw_pcb {
|
mbed714 |
0:d616ece2d859
|
64
|
/* Common members of all PCB types */
|
mbed714 |
0:d616ece2d859
|
65
|
IP_PCB;
|
mbed714 |
0:d616ece2d859
|
66
|
|
mbed714 |
0:d616ece2d859
|
67
|
struct raw_pcb *next;
|
mbed714 |
0:d616ece2d859
|
68
|
|
mbed714 |
0:d616ece2d859
|
69
|
u8_t protocol;
|
mbed714 |
0:d616ece2d859
|
70
|
|
mbed714 |
0:d616ece2d859
|
71
|
/** receive callback function */
|
mbed714 |
0:d616ece2d859
|
72
|
raw_recv_fn recv;
|
mbed714 |
0:d616ece2d859
|
73
|
/* user-supplied argument for the recv callback */
|
mbed714 |
0:d616ece2d859
|
74
|
void *recv_arg;
|
mbed714 |
0:d616ece2d859
|
75
|
};
|
mbed714 |
0:d616ece2d859
|
76
|
|
mbed714 |
0:d616ece2d859
|
77
|
/* The following functions is the application layer interface to the
|
mbed714 |
0:d616ece2d859
|
78
|
RAW code. */
|
mbed714 |
0:d616ece2d859
|
79
|
struct raw_pcb * raw_new (u8_t proto);
|
mbed714 |
0:d616ece2d859
|
80
|
void raw_remove (struct raw_pcb *pcb);
|
mbed714 |
0:d616ece2d859
|
81
|
err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr);
|
mbed714 |
0:d616ece2d859
|
82
|
err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr);
|
mbed714 |
0:d616ece2d859
|
83
|
|
mbed714 |
0:d616ece2d859
|
84
|
void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg);
|
mbed714 |
0:d616ece2d859
|
85
|
err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr);
|
mbed714 |
0:d616ece2d859
|
86
|
err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
|
mbed714 |
0:d616ece2d859
|
87
|
|
mbed714 |
0:d616ece2d859
|
88
|
/* The following functions are the lower layer interface to RAW. */
|
mbed714 |
0:d616ece2d859
|
89
|
u8_t raw_input (struct pbuf *p, struct netif *inp);
|
mbed714 |
0:d616ece2d859
|
90
|
#define raw_init() /* Compatibility define, not init needed. */
|
mbed714 |
0:d616ece2d859
|
91
|
|
mbed714 |
0:d616ece2d859
|
92
|
#ifdef __cplusplus
|
mbed714 |
0:d616ece2d859
|
93
|
}
|
mbed714 |
0:d616ece2d859
|
94
|
#endif
|
mbed714 |
0:d616ece2d859
|
95
|
|
mbed714 |
0:d616ece2d859
|
96
|
#endif /* LWIP_RAW */
|
mbed714 |
0:d616ece2d859
|
97
|
|
mbed714 |
0:d616ece2d859
|
98
|
#endif /* __LWIP_RAW_H__ */
|