Experimental HTTPClient with proxy support

Committer:
igorsk
Date:
Wed Jun 29 16:01:58 2011 +0000
Revision:
0:b56b6a05cad4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
igorsk 0:b56b6a05cad4 1 /**
igorsk 0:b56b6a05cad4 2 * @file
igorsk 0:b56b6a05cad4 3 * Ethernet Interface Skeleton
igorsk 0:b56b6a05cad4 4 *
igorsk 0:b56b6a05cad4 5 */
igorsk 0:b56b6a05cad4 6
igorsk 0:b56b6a05cad4 7 /*
igorsk 0:b56b6a05cad4 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
igorsk 0:b56b6a05cad4 9 * All rights reserved.
igorsk 0:b56b6a05cad4 10 *
igorsk 0:b56b6a05cad4 11 * Redistribution and use in source and binary forms, with or without modification,
igorsk 0:b56b6a05cad4 12 * are permitted provided that the following conditions are met:
igorsk 0:b56b6a05cad4 13 *
igorsk 0:b56b6a05cad4 14 * 1. Redistributions of source code must retain the above copyright notice,
igorsk 0:b56b6a05cad4 15 * this list of conditions and the following disclaimer.
igorsk 0:b56b6a05cad4 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
igorsk 0:b56b6a05cad4 17 * this list of conditions and the following disclaimer in the documentation
igorsk 0:b56b6a05cad4 18 * and/or other materials provided with the distribution.
igorsk 0:b56b6a05cad4 19 * 3. The name of the author may not be used to endorse or promote products
igorsk 0:b56b6a05cad4 20 * derived from this software without specific prior written permission.
igorsk 0:b56b6a05cad4 21 *
igorsk 0:b56b6a05cad4 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
igorsk 0:b56b6a05cad4 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
igorsk 0:b56b6a05cad4 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
igorsk 0:b56b6a05cad4 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
igorsk 0:b56b6a05cad4 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
igorsk 0:b56b6a05cad4 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
igorsk 0:b56b6a05cad4 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
igorsk 0:b56b6a05cad4 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
igorsk 0:b56b6a05cad4 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
igorsk 0:b56b6a05cad4 31 * OF SUCH DAMAGE.
igorsk 0:b56b6a05cad4 32 *
igorsk 0:b56b6a05cad4 33 * This file is part of the lwIP TCP/IP stack.
igorsk 0:b56b6a05cad4 34 *
igorsk 0:b56b6a05cad4 35 * Author: Adam Dunkels <adam@sics.se>
igorsk 0:b56b6a05cad4 36 *
igorsk 0:b56b6a05cad4 37 */
igorsk 0:b56b6a05cad4 38
igorsk 0:b56b6a05cad4 39 /*
igorsk 0:b56b6a05cad4 40 * This file is a skeleton for developing Ethernet network interface
igorsk 0:b56b6a05cad4 41 * drivers for lwIP. Add code to the low_level functions and do a
igorsk 0:b56b6a05cad4 42 * search-and-replace for the word "ethernetif" to replace it with
igorsk 0:b56b6a05cad4 43 * something that better describes your network interface.
igorsk 0:b56b6a05cad4 44 */
igorsk 0:b56b6a05cad4 45
igorsk 0:b56b6a05cad4 46 #include "lwip/opt.h"
igorsk 0:b56b6a05cad4 47
igorsk 0:b56b6a05cad4 48 #if 0 /* don't build, this is only a skeleton, see previous comment */
igorsk 0:b56b6a05cad4 49
igorsk 0:b56b6a05cad4 50 #include "lwip/def.h"
igorsk 0:b56b6a05cad4 51 #include "lwip/mem.h"
igorsk 0:b56b6a05cad4 52 #include "lwip/pbuf.h"
igorsk 0:b56b6a05cad4 53 #include "lwip/sys.h"
igorsk 0:b56b6a05cad4 54 #include <lwip/stats.h>
igorsk 0:b56b6a05cad4 55 #include <lwip/snmp.h>
igorsk 0:b56b6a05cad4 56 #include "netif/etharp.h"
igorsk 0:b56b6a05cad4 57 #include "netif/ppp_oe.h"
igorsk 0:b56b6a05cad4 58
igorsk 0:b56b6a05cad4 59 /* Define those to better describe your network interface. */
igorsk 0:b56b6a05cad4 60 #define IFNAME0 'e'
igorsk 0:b56b6a05cad4 61 #define IFNAME1 'n'
igorsk 0:b56b6a05cad4 62
igorsk 0:b56b6a05cad4 63 /**
igorsk 0:b56b6a05cad4 64 * Helper struct to hold private data used to operate your ethernet interface.
igorsk 0:b56b6a05cad4 65 * Keeping the ethernet address of the MAC in this struct is not necessary
igorsk 0:b56b6a05cad4 66 * as it is already kept in the struct netif.
igorsk 0:b56b6a05cad4 67 * But this is only an example, anyway...
igorsk 0:b56b6a05cad4 68 */
igorsk 0:b56b6a05cad4 69 struct ethernetif {
igorsk 0:b56b6a05cad4 70 struct eth_addr *ethaddr;
igorsk 0:b56b6a05cad4 71 /* Add whatever per-interface state that is needed here. */
igorsk 0:b56b6a05cad4 72 };
igorsk 0:b56b6a05cad4 73
igorsk 0:b56b6a05cad4 74 /* Forward declarations. */
igorsk 0:b56b6a05cad4 75 static void ethernetif_input(struct netif *netif);
igorsk 0:b56b6a05cad4 76
igorsk 0:b56b6a05cad4 77 /**
igorsk 0:b56b6a05cad4 78 * In this function, the hardware should be initialized.
igorsk 0:b56b6a05cad4 79 * Called from ethernetif_init().
igorsk 0:b56b6a05cad4 80 *
igorsk 0:b56b6a05cad4 81 * @param netif the already initialized lwip network interface structure
igorsk 0:b56b6a05cad4 82 * for this ethernetif
igorsk 0:b56b6a05cad4 83 */
igorsk 0:b56b6a05cad4 84 static void
igorsk 0:b56b6a05cad4 85 low_level_init(struct netif *netif)
igorsk 0:b56b6a05cad4 86 {
igorsk 0:b56b6a05cad4 87 struct ethernetif *ethernetif = netif->state;
igorsk 0:b56b6a05cad4 88
igorsk 0:b56b6a05cad4 89 /* set MAC hardware address length */
igorsk 0:b56b6a05cad4 90 netif->hwaddr_len = ETHARP_HWADDR_LEN;
igorsk 0:b56b6a05cad4 91
igorsk 0:b56b6a05cad4 92 /* set MAC hardware address */
igorsk 0:b56b6a05cad4 93 netif->hwaddr[0] = ;
igorsk 0:b56b6a05cad4 94 ...
igorsk 0:b56b6a05cad4 95 netif->hwaddr[5] = ;
igorsk 0:b56b6a05cad4 96
igorsk 0:b56b6a05cad4 97 /* maximum transfer unit */
igorsk 0:b56b6a05cad4 98 netif->mtu = 1500;
igorsk 0:b56b6a05cad4 99
igorsk 0:b56b6a05cad4 100 /* device capabilities */
igorsk 0:b56b6a05cad4 101 /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
igorsk 0:b56b6a05cad4 102 netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
igorsk 0:b56b6a05cad4 103
igorsk 0:b56b6a05cad4 104 /* Do whatever else is needed to initialize interface. */
igorsk 0:b56b6a05cad4 105 }
igorsk 0:b56b6a05cad4 106
igorsk 0:b56b6a05cad4 107 /**
igorsk 0:b56b6a05cad4 108 * This function should do the actual transmission of the packet. The packet is
igorsk 0:b56b6a05cad4 109 * contained in the pbuf that is passed to the function. This pbuf
igorsk 0:b56b6a05cad4 110 * might be chained.
igorsk 0:b56b6a05cad4 111 *
igorsk 0:b56b6a05cad4 112 * @param netif the lwip network interface structure for this ethernetif
igorsk 0:b56b6a05cad4 113 * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
igorsk 0:b56b6a05cad4 114 * @return ERR_OK if the packet could be sent
igorsk 0:b56b6a05cad4 115 * an err_t value if the packet couldn't be sent
igorsk 0:b56b6a05cad4 116 *
igorsk 0:b56b6a05cad4 117 * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
igorsk 0:b56b6a05cad4 118 * strange results. You might consider waiting for space in the DMA queue
igorsk 0:b56b6a05cad4 119 * to become availale since the stack doesn't retry to send a packet
igorsk 0:b56b6a05cad4 120 * dropped because of memory failure (except for the TCP timers).
igorsk 0:b56b6a05cad4 121 */
igorsk 0:b56b6a05cad4 122
igorsk 0:b56b6a05cad4 123 static err_t
igorsk 0:b56b6a05cad4 124 low_level_output(struct netif *netif, struct pbuf *p)
igorsk 0:b56b6a05cad4 125 {
igorsk 0:b56b6a05cad4 126 struct ethernetif *ethernetif = netif->state;
igorsk 0:b56b6a05cad4 127 struct pbuf *q;
igorsk 0:b56b6a05cad4 128
igorsk 0:b56b6a05cad4 129 initiate transfer();
igorsk 0:b56b6a05cad4 130
igorsk 0:b56b6a05cad4 131 #if ETH_PAD_SIZE
igorsk 0:b56b6a05cad4 132 pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
igorsk 0:b56b6a05cad4 133 #endif
igorsk 0:b56b6a05cad4 134
igorsk 0:b56b6a05cad4 135 for(q = p; q != NULL; q = q->next) {
igorsk 0:b56b6a05cad4 136 /* Send the data from the pbuf to the interface, one pbuf at a
igorsk 0:b56b6a05cad4 137 time. The size of the data in each pbuf is kept in the ->len
igorsk 0:b56b6a05cad4 138 variable. */
igorsk 0:b56b6a05cad4 139 send data from(q->payload, q->len);
igorsk 0:b56b6a05cad4 140 }
igorsk 0:b56b6a05cad4 141
igorsk 0:b56b6a05cad4 142 signal that packet should be sent();
igorsk 0:b56b6a05cad4 143
igorsk 0:b56b6a05cad4 144 #if ETH_PAD_SIZE
igorsk 0:b56b6a05cad4 145 pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
igorsk 0:b56b6a05cad4 146 #endif
igorsk 0:b56b6a05cad4 147
igorsk 0:b56b6a05cad4 148 LINK_STATS_INC(link.xmit);
igorsk 0:b56b6a05cad4 149
igorsk 0:b56b6a05cad4 150 return ERR_OK;
igorsk 0:b56b6a05cad4 151 }
igorsk 0:b56b6a05cad4 152
igorsk 0:b56b6a05cad4 153 /**
igorsk 0:b56b6a05cad4 154 * Should allocate a pbuf and transfer the bytes of the incoming
igorsk 0:b56b6a05cad4 155 * packet from the interface into the pbuf.
igorsk 0:b56b6a05cad4 156 *
igorsk 0:b56b6a05cad4 157 * @param netif the lwip network interface structure for this ethernetif
igorsk 0:b56b6a05cad4 158 * @return a pbuf filled with the received packet (including MAC header)
igorsk 0:b56b6a05cad4 159 * NULL on memory error
igorsk 0:b56b6a05cad4 160 */
igorsk 0:b56b6a05cad4 161 static struct pbuf *
igorsk 0:b56b6a05cad4 162 low_level_input(struct netif *netif)
igorsk 0:b56b6a05cad4 163 {
igorsk 0:b56b6a05cad4 164 struct ethernetif *ethernetif = netif->state;
igorsk 0:b56b6a05cad4 165 struct pbuf *p, *q;
igorsk 0:b56b6a05cad4 166 u16_t len;
igorsk 0:b56b6a05cad4 167
igorsk 0:b56b6a05cad4 168 /* Obtain the size of the packet and put it into the "len"
igorsk 0:b56b6a05cad4 169 variable. */
igorsk 0:b56b6a05cad4 170 len = ;
igorsk 0:b56b6a05cad4 171
igorsk 0:b56b6a05cad4 172 #if ETH_PAD_SIZE
igorsk 0:b56b6a05cad4 173 len += ETH_PAD_SIZE; /* allow room for Ethernet padding */
igorsk 0:b56b6a05cad4 174 #endif
igorsk 0:b56b6a05cad4 175
igorsk 0:b56b6a05cad4 176 /* We allocate a pbuf chain of pbufs from the pool. */
igorsk 0:b56b6a05cad4 177 p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
igorsk 0:b56b6a05cad4 178
igorsk 0:b56b6a05cad4 179 if (p != NULL) {
igorsk 0:b56b6a05cad4 180
igorsk 0:b56b6a05cad4 181 #if ETH_PAD_SIZE
igorsk 0:b56b6a05cad4 182 pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
igorsk 0:b56b6a05cad4 183 #endif
igorsk 0:b56b6a05cad4 184
igorsk 0:b56b6a05cad4 185 /* We iterate over the pbuf chain until we have read the entire
igorsk 0:b56b6a05cad4 186 * packet into the pbuf. */
igorsk 0:b56b6a05cad4 187 for(q = p; q != NULL; q = q->next) {
igorsk 0:b56b6a05cad4 188 /* Read enough bytes to fill this pbuf in the chain. The
igorsk 0:b56b6a05cad4 189 * available data in the pbuf is given by the q->len
igorsk 0:b56b6a05cad4 190 * variable.
igorsk 0:b56b6a05cad4 191 * This does not necessarily have to be a memcpy, you can also preallocate
igorsk 0:b56b6a05cad4 192 * pbufs for a DMA-enabled MAC and after receiving truncate it to the
igorsk 0:b56b6a05cad4 193 * actually received size. In this case, ensure the tot_len member of the
igorsk 0:b56b6a05cad4 194 * pbuf is the sum of the chained pbuf len members.
igorsk 0:b56b6a05cad4 195 */
igorsk 0:b56b6a05cad4 196 read data into(q->payload, q->len);
igorsk 0:b56b6a05cad4 197 }
igorsk 0:b56b6a05cad4 198 acknowledge that packet has been read();
igorsk 0:b56b6a05cad4 199
igorsk 0:b56b6a05cad4 200 #if ETH_PAD_SIZE
igorsk 0:b56b6a05cad4 201 pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
igorsk 0:b56b6a05cad4 202 #endif
igorsk 0:b56b6a05cad4 203
igorsk 0:b56b6a05cad4 204 LINK_STATS_INC(link.recv);
igorsk 0:b56b6a05cad4 205 } else {
igorsk 0:b56b6a05cad4 206 drop packet();
igorsk 0:b56b6a05cad4 207 LINK_STATS_INC(link.memerr);
igorsk 0:b56b6a05cad4 208 LINK_STATS_INC(link.drop);
igorsk 0:b56b6a05cad4 209 }
igorsk 0:b56b6a05cad4 210
igorsk 0:b56b6a05cad4 211 return p;
igorsk 0:b56b6a05cad4 212 }
igorsk 0:b56b6a05cad4 213
igorsk 0:b56b6a05cad4 214 /**
igorsk 0:b56b6a05cad4 215 * This function should be called when a packet is ready to be read
igorsk 0:b56b6a05cad4 216 * from the interface. It uses the function low_level_input() that
igorsk 0:b56b6a05cad4 217 * should handle the actual reception of bytes from the network
igorsk 0:b56b6a05cad4 218 * interface. Then the type of the received packet is determined and
igorsk 0:b56b6a05cad4 219 * the appropriate input function is called.
igorsk 0:b56b6a05cad4 220 *
igorsk 0:b56b6a05cad4 221 * @param netif the lwip network interface structure for this ethernetif
igorsk 0:b56b6a05cad4 222 */
igorsk 0:b56b6a05cad4 223 static void
igorsk 0:b56b6a05cad4 224 ethernetif_input(struct netif *netif)
igorsk 0:b56b6a05cad4 225 {
igorsk 0:b56b6a05cad4 226 struct ethernetif *ethernetif;
igorsk 0:b56b6a05cad4 227 struct eth_hdr *ethhdr;
igorsk 0:b56b6a05cad4 228 struct pbuf *p;
igorsk 0:b56b6a05cad4 229
igorsk 0:b56b6a05cad4 230 ethernetif = netif->state;
igorsk 0:b56b6a05cad4 231
igorsk 0:b56b6a05cad4 232 /* move received packet into a new pbuf */
igorsk 0:b56b6a05cad4 233 p = low_level_input(netif);
igorsk 0:b56b6a05cad4 234 /* no packet could be read, silently ignore this */
igorsk 0:b56b6a05cad4 235 if (p == NULL) return;
igorsk 0:b56b6a05cad4 236 /* points to packet payload, which starts with an Ethernet header */
igorsk 0:b56b6a05cad4 237 ethhdr = p->payload;
igorsk 0:b56b6a05cad4 238
igorsk 0:b56b6a05cad4 239 switch (htons(ethhdr->type)) {
igorsk 0:b56b6a05cad4 240 /* IP or ARP packet? */
igorsk 0:b56b6a05cad4 241 case ETHTYPE_IP:
igorsk 0:b56b6a05cad4 242 case ETHTYPE_ARP:
igorsk 0:b56b6a05cad4 243 #if PPPOE_SUPPORT
igorsk 0:b56b6a05cad4 244 /* PPPoE packet? */
igorsk 0:b56b6a05cad4 245 case ETHTYPE_PPPOEDISC:
igorsk 0:b56b6a05cad4 246 case ETHTYPE_PPPOE:
igorsk 0:b56b6a05cad4 247 #endif /* PPPOE_SUPPORT */
igorsk 0:b56b6a05cad4 248 /* full packet send to tcpip_thread to process */
igorsk 0:b56b6a05cad4 249 if (netif->input(p, netif)!=ERR_OK)
igorsk 0:b56b6a05cad4 250 { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
igorsk 0:b56b6a05cad4 251 pbuf_free(p);
igorsk 0:b56b6a05cad4 252 p = NULL;
igorsk 0:b56b6a05cad4 253 }
igorsk 0:b56b6a05cad4 254 break;
igorsk 0:b56b6a05cad4 255
igorsk 0:b56b6a05cad4 256 default:
igorsk 0:b56b6a05cad4 257 pbuf_free(p);
igorsk 0:b56b6a05cad4 258 p = NULL;
igorsk 0:b56b6a05cad4 259 break;
igorsk 0:b56b6a05cad4 260 }
igorsk 0:b56b6a05cad4 261 }
igorsk 0:b56b6a05cad4 262
igorsk 0:b56b6a05cad4 263 /**
igorsk 0:b56b6a05cad4 264 * Should be called at the beginning of the program to set up the
igorsk 0:b56b6a05cad4 265 * network interface. It calls the function low_level_init() to do the
igorsk 0:b56b6a05cad4 266 * actual setup of the hardware.
igorsk 0:b56b6a05cad4 267 *
igorsk 0:b56b6a05cad4 268 * This function should be passed as a parameter to netif_add().
igorsk 0:b56b6a05cad4 269 *
igorsk 0:b56b6a05cad4 270 * @param netif the lwip network interface structure for this ethernetif
igorsk 0:b56b6a05cad4 271 * @return ERR_OK if the loopif is initialized
igorsk 0:b56b6a05cad4 272 * ERR_MEM if private data couldn't be allocated
igorsk 0:b56b6a05cad4 273 * any other err_t on error
igorsk 0:b56b6a05cad4 274 */
igorsk 0:b56b6a05cad4 275 err_t
igorsk 0:b56b6a05cad4 276 ethernetif_init(struct netif *netif)
igorsk 0:b56b6a05cad4 277 {
igorsk 0:b56b6a05cad4 278 struct ethernetif *ethernetif;
igorsk 0:b56b6a05cad4 279
igorsk 0:b56b6a05cad4 280 LWIP_ASSERT("netif != NULL", (netif != NULL));
igorsk 0:b56b6a05cad4 281
igorsk 0:b56b6a05cad4 282 ethernetif = mem_malloc(sizeof(struct ethernetif));
igorsk 0:b56b6a05cad4 283 if (ethernetif == NULL) {
igorsk 0:b56b6a05cad4 284 LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n"));
igorsk 0:b56b6a05cad4 285 return ERR_MEM;
igorsk 0:b56b6a05cad4 286 }
igorsk 0:b56b6a05cad4 287
igorsk 0:b56b6a05cad4 288 #if LWIP_NETIF_HOSTNAME
igorsk 0:b56b6a05cad4 289 /* Initialize interface hostname */
igorsk 0:b56b6a05cad4 290 netif->hostname = "lwip";
igorsk 0:b56b6a05cad4 291 #endif /* LWIP_NETIF_HOSTNAME */
igorsk 0:b56b6a05cad4 292
igorsk 0:b56b6a05cad4 293 /*
igorsk 0:b56b6a05cad4 294 * Initialize the snmp variables and counters inside the struct netif.
igorsk 0:b56b6a05cad4 295 * The last argument should be replaced with your link speed, in units
igorsk 0:b56b6a05cad4 296 * of bits per second.
igorsk 0:b56b6a05cad4 297 */
igorsk 0:b56b6a05cad4 298 NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
igorsk 0:b56b6a05cad4 299
igorsk 0:b56b6a05cad4 300 netif->state = ethernetif;
igorsk 0:b56b6a05cad4 301 netif->name[0] = IFNAME0;
igorsk 0:b56b6a05cad4 302 netif->name[1] = IFNAME1;
igorsk 0:b56b6a05cad4 303 /* We directly use etharp_output() here to save a function call.
igorsk 0:b56b6a05cad4 304 * You can instead declare your own function an call etharp_output()
igorsk 0:b56b6a05cad4 305 * from it if you have to do some checks before sending (e.g. if link
igorsk 0:b56b6a05cad4 306 * is available...) */
igorsk 0:b56b6a05cad4 307 netif->output = etharp_output;
igorsk 0:b56b6a05cad4 308 netif->linkoutput = low_level_output;
igorsk 0:b56b6a05cad4 309
igorsk 0:b56b6a05cad4 310 ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
igorsk 0:b56b6a05cad4 311
igorsk 0:b56b6a05cad4 312 /* initialize the hardware */
igorsk 0:b56b6a05cad4 313 low_level_init(netif);
igorsk 0:b56b6a05cad4 314
igorsk 0:b56b6a05cad4 315 return ERR_OK;
igorsk 0:b56b6a05cad4 316 }
igorsk 0:b56b6a05cad4 317
igorsk 0:b56b6a05cad4 318 #endif /* 0 */