blob: ee1c37bc7824578f1706ce4eacc8d2bcbddb0622 [file] [log] [blame]
adamdunkels4b706112003-09-23 08:57:40 +00001#ifndef __UIP_FW_H__
2#define __UIP_FW_H__
3
4/**
5 * Representation of a uIP network interface.
6 */
7struct uip_fw_netif {
8 struct uip_fw_netif *next; /**< Pointer to the next interface when
9 linked in a list. */
10 u16_t ipaddr[2]; /**< The IP address of this interface. */
11 u16_t netmask[2]; /**< The netmask of the interface. */
adamdunkels5f132992003-11-27 15:49:53 +000012 u8_t (* output)(void);
adamdunkelsb489e7a2003-10-14 11:12:50 +000013 /**< A pointer to the function that
adamdunkels4b706112003-09-23 08:57:40 +000014 sends a packet. */
15};
16
17/**
18 * Intantiating macro for a uIP network interface.
19 *
20 * Example:
21 \code
22 struct uip_fw_netif slipnetif =
23 {UIP_FW_NETIF(192,168,76,1, 255,255,255,0, slip_output)};
24 \endcode
25 * \param ip1,ip2,ip3,ip4 The IP address of the network interface.
26 *
27 * \param nm1,nm2,nm3,nm4 The netmask of the network interface.
28 *
29 * \param outputfunc A pointer to the output function of the network interface.
30 *
adamdunkels5f132992003-11-27 15:49:53 +000031 * \hideinitializer
adamdunkels4b706112003-09-23 08:57:40 +000032 */
33#define UIP_FW_NETIF(ip1,ip2,ip3,ip4, nm1,nm2,nm3,nm4, outputfunc) \
34 NULL, \
35 {HTONS((ip1 << 8) | ip2), HTONS((ip3 << 8) | ip4)}, \
36 {HTONS((nm1 << 8) | nm2), HTONS((nm3 << 8) | nm4)}, \
37 outputfunc
38
adamdunkels5f132992003-11-27 15:49:53 +000039/**
40 * Set the IP address of a network interface.
41 *
42 * \param netif A pointer to the uip_fw_netif structure for the network interface.
43 *
44 * \param addr A pointer to an IP address.
45 *
46 * \hideinitializer
47 */
48#define uip_fw_setipaddr(netif, addr) \
49 do { (netif)->ipaddr[0] = ((u16_t *)(addr))[0]; \
50 (netif)->ipaddr[1] = ((u16_t *)(addr))[1]; } while(0)
51/**
52 * Set the netmask of a network interface.
53 *
54 * \param netif A pointer to the uip_fw_netif structure for the network interface.
55 *
56 * \param addr A pointer to an IP address representing the netmask.
57 *
58 * \hideinitializer
59 */
60#define uip_fw_setnetmask(netif, addr) \
61 do { (netif)->netmask[0] = ((u16_t *)(addr))[0]; \
62 (netif)->netmask[1] = ((u16_t *)(addr))[1]; } while(0)
63
adamdunkels4b706112003-09-23 08:57:40 +000064void uip_fw_init(void);
adamdunkels5f132992003-11-27 15:49:53 +000065u8_t uip_fw_forward(void);
66u8_t uip_fw_output(void);
adamdunkels4b706112003-09-23 08:57:40 +000067void uip_fw_register(struct uip_fw_netif *netif);
68void uip_fw_default(struct uip_fw_netif *netif);
adamdunkels048a33f2004-02-16 20:48:53 +000069void uip_fw_periodic(void);
adamdunkels4b706112003-09-23 08:57:40 +000070
adamdunkels5f132992003-11-27 15:49:53 +000071
72/**
73 * A non-error message that indicates that a packet should be
74 * processed locally.
75 *
76 * \hideinitializer
77 */
78#define UIP_FW_LOCAL 0
79
80/**
81 * A non-error message that indicates that something went OK.
82 *
83 * \hideinitializer
84 */
85#define UIP_FW_OK 0
86
87/**
88 * A non-error message that indicates that a packet was forwarded.
89 *
90 * \hideinitializer
91 */
92#define UIP_FW_FORWARDED 1
93
94/**
95 * A non-error message that indicates that a zero-length packet
96 * transmission was attempted, and that no packet was sent.
97 *
98 * \hideinitializer
99 */
100#define UIP_FW_ZEROLEN 2
101
102/**
103 * An error message that indicates that a packet that was too large
104 * for the outbound network interface was detected.
105 *
106 * \hideinitializer
107 */
108#define UIP_FW_TOOLARGE 3
109
110/**
111 * An error message that indicates that no suitable interface could be
112 * found for an outbound packet.
113 *
114 * \hideinitializer
115 */
116#define UIP_FW_NOROUTE 4
117
118/**
119 * An error message that indicates that a packet that should be
120 * forwarded or output was dropped.
121 *
122 * \hideinitializer
123 */
124#define UIP_FW_DROPPED 5
125
adamdunkels048a33f2004-02-16 20:48:53 +0000126
adamdunkels4b706112003-09-23 08:57:40 +0000127#endif /* __UIP_FW_H__ */