I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tax 0:66300c77c6e9 1 /*****************************************************************************
tax 0:66300c77c6e9 2 * ppp_oe.h - PPP Over Ethernet implementation for lwIP.
tax 0:66300c77c6e9 3 *
tax 0:66300c77c6e9 4 * Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc.
tax 0:66300c77c6e9 5 *
tax 0:66300c77c6e9 6 * The authors hereby grant permission to use, copy, modify, distribute,
tax 0:66300c77c6e9 7 * and license this software and its documentation for any purpose, provided
tax 0:66300c77c6e9 8 * that existing copyright notices are retained in all copies and that this
tax 0:66300c77c6e9 9 * notice and the following disclaimer are included verbatim in any
tax 0:66300c77c6e9 10 * distributions. No written agreement, license, or royalty fee is required
tax 0:66300c77c6e9 11 * for any of the authorized uses.
tax 0:66300c77c6e9 12 *
tax 0:66300c77c6e9 13 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
tax 0:66300c77c6e9 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
tax 0:66300c77c6e9 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
tax 0:66300c77c6e9 16 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
tax 0:66300c77c6e9 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
tax 0:66300c77c6e9 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
tax 0:66300c77c6e9 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
tax 0:66300c77c6e9 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
tax 0:66300c77c6e9 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
tax 0:66300c77c6e9 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
tax 0:66300c77c6e9 23 *
tax 0:66300c77c6e9 24 ******************************************************************************
tax 0:66300c77c6e9 25 * REVISION HISTORY
tax 0:66300c77c6e9 26 *
tax 0:66300c77c6e9 27 * 06-01-01 Marc Boucher <marc@mbsi.ca>
tax 0:66300c77c6e9 28 * Ported to lwIP.
tax 0:66300c77c6e9 29 *****************************************************************************/
tax 0:66300c77c6e9 30
tax 0:66300c77c6e9 31
tax 0:66300c77c6e9 32
tax 0:66300c77c6e9 33 /* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */
tax 0:66300c77c6e9 34
tax 0:66300c77c6e9 35 /*-
tax 0:66300c77c6e9 36 * Copyright (c) 2002 The NetBSD Foundation, Inc.
tax 0:66300c77c6e9 37 * All rights reserved.
tax 0:66300c77c6e9 38 *
tax 0:66300c77c6e9 39 * This code is derived from software contributed to The NetBSD Foundation
tax 0:66300c77c6e9 40 * by Martin Husemann <martin@NetBSD.org>.
tax 0:66300c77c6e9 41 *
tax 0:66300c77c6e9 42 * Redistribution and use in source and binary forms, with or without
tax 0:66300c77c6e9 43 * modification, are permitted provided that the following conditions
tax 0:66300c77c6e9 44 * are met:
tax 0:66300c77c6e9 45 * 1. Redistributions of source code must retain the above copyright
tax 0:66300c77c6e9 46 * notice, this list of conditions and the following disclaimer.
tax 0:66300c77c6e9 47 * 2. Redistributions in binary form must reproduce the above copyright
tax 0:66300c77c6e9 48 * notice, this list of conditions and the following disclaimer in the
tax 0:66300c77c6e9 49 * documentation and/or other materials provided with the distribution.
tax 0:66300c77c6e9 50 * 3. All advertising materials mentioning features or use of this software
tax 0:66300c77c6e9 51 * must display the following acknowledgement:
tax 0:66300c77c6e9 52 * This product includes software developed by the NetBSD
tax 0:66300c77c6e9 53 * Foundation, Inc. and its contributors.
tax 0:66300c77c6e9 54 * 4. Neither the name of The NetBSD Foundation nor the names of its
tax 0:66300c77c6e9 55 * contributors may be used to endorse or promote products derived
tax 0:66300c77c6e9 56 * from this software without specific prior written permission.
tax 0:66300c77c6e9 57 *
tax 0:66300c77c6e9 58 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
tax 0:66300c77c6e9 59 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
tax 0:66300c77c6e9 60 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
tax 0:66300c77c6e9 61 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
tax 0:66300c77c6e9 62 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
tax 0:66300c77c6e9 63 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
tax 0:66300c77c6e9 64 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
tax 0:66300c77c6e9 65 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
tax 0:66300c77c6e9 66 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
tax 0:66300c77c6e9 67 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
tax 0:66300c77c6e9 68 * POSSIBILITY OF SUCH DAMAGE.
tax 0:66300c77c6e9 69 */
tax 0:66300c77c6e9 70 #ifndef PPP_OE_H
tax 0:66300c77c6e9 71 #define PPP_OE_H
tax 0:66300c77c6e9 72
tax 0:66300c77c6e9 73 #include "lwip/opt.h"
tax 0:66300c77c6e9 74
tax 0:66300c77c6e9 75 #if PPPOE_SUPPORT > 0
tax 0:66300c77c6e9 76
tax 0:66300c77c6e9 77 #include "netif/etharp.h"
tax 0:66300c77c6e9 78
tax 0:66300c77c6e9 79 #ifdef PACK_STRUCT_USE_INCLUDES
tax 0:66300c77c6e9 80 # include "arch/bpstruct.h"
tax 0:66300c77c6e9 81 #endif
tax 0:66300c77c6e9 82 PACK_STRUCT_BEGIN
tax 0:66300c77c6e9 83 struct pppoehdr {
tax 0:66300c77c6e9 84 PACK_STRUCT_FIELD(u8_t vertype);
tax 0:66300c77c6e9 85 PACK_STRUCT_FIELD(u8_t code);
tax 0:66300c77c6e9 86 PACK_STRUCT_FIELD(u16_t session);
tax 0:66300c77c6e9 87 PACK_STRUCT_FIELD(u16_t plen);
tax 0:66300c77c6e9 88 } PACK_STRUCT_STRUCT;
tax 0:66300c77c6e9 89 PACK_STRUCT_END
tax 0:66300c77c6e9 90 #ifdef PACK_STRUCT_USE_INCLUDES
tax 0:66300c77c6e9 91 # include "arch/epstruct.h"
tax 0:66300c77c6e9 92 #endif
tax 0:66300c77c6e9 93
tax 0:66300c77c6e9 94 #ifdef PACK_STRUCT_USE_INCLUDES
tax 0:66300c77c6e9 95 # include "arch/bpstruct.h"
tax 0:66300c77c6e9 96 #endif
tax 0:66300c77c6e9 97 PACK_STRUCT_BEGIN
tax 0:66300c77c6e9 98 struct pppoetag {
tax 0:66300c77c6e9 99 PACK_STRUCT_FIELD(u16_t tag);
tax 0:66300c77c6e9 100 PACK_STRUCT_FIELD(u16_t len);
tax 0:66300c77c6e9 101 } PACK_STRUCT_STRUCT;
tax 0:66300c77c6e9 102 PACK_STRUCT_END
tax 0:66300c77c6e9 103 #ifdef PACK_STRUCT_USE_INCLUDES
tax 0:66300c77c6e9 104 # include "arch/epstruct.h"
tax 0:66300c77c6e9 105 #endif
tax 0:66300c77c6e9 106
tax 0:66300c77c6e9 107
tax 0:66300c77c6e9 108 #define PPPOE_STATE_INITIAL 0
tax 0:66300c77c6e9 109 #define PPPOE_STATE_PADI_SENT 1
tax 0:66300c77c6e9 110 #define PPPOE_STATE_PADR_SENT 2
tax 0:66300c77c6e9 111 #define PPPOE_STATE_SESSION 3
tax 0:66300c77c6e9 112 #define PPPOE_STATE_CLOSING 4
tax 0:66300c77c6e9 113 /* passive */
tax 0:66300c77c6e9 114 #define PPPOE_STATE_PADO_SENT 1
tax 0:66300c77c6e9 115
tax 0:66300c77c6e9 116 #define PPPOE_HEADERLEN sizeof(struct pppoehdr)
tax 0:66300c77c6e9 117 #define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */
tax 0:66300c77c6e9 118
tax 0:66300c77c6e9 119 #define PPPOE_TAG_EOL 0x0000 /* end of list */
tax 0:66300c77c6e9 120 #define PPPOE_TAG_SNAME 0x0101 /* service name */
tax 0:66300c77c6e9 121 #define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */
tax 0:66300c77c6e9 122 #define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */
tax 0:66300c77c6e9 123 #define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */
tax 0:66300c77c6e9 124 #define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */
tax 0:66300c77c6e9 125 #define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */
tax 0:66300c77c6e9 126 #define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */
tax 0:66300c77c6e9 127 #define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */
tax 0:66300c77c6e9 128 #define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */
tax 0:66300c77c6e9 129
tax 0:66300c77c6e9 130 #define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */
tax 0:66300c77c6e9 131 #define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */
tax 0:66300c77c6e9 132 #define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */
tax 0:66300c77c6e9 133 #define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */
tax 0:66300c77c6e9 134 #define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */
tax 0:66300c77c6e9 135
tax 0:66300c77c6e9 136 #ifndef ETHERMTU
tax 0:66300c77c6e9 137 #define ETHERMTU 1500
tax 0:66300c77c6e9 138 #endif
tax 0:66300c77c6e9 139
tax 0:66300c77c6e9 140 /* two byte PPP protocol discriminator, then IP data */
tax 0:66300c77c6e9 141 #define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2)
tax 0:66300c77c6e9 142
tax 0:66300c77c6e9 143 #ifndef PPPOE_MAX_AC_COOKIE_LEN
tax 0:66300c77c6e9 144 #define PPPOE_MAX_AC_COOKIE_LEN 64
tax 0:66300c77c6e9 145 #endif
tax 0:66300c77c6e9 146
tax 0:66300c77c6e9 147 struct pppoe_softc {
tax 0:66300c77c6e9 148 struct pppoe_softc *next;
tax 0:66300c77c6e9 149 struct netif *sc_ethif; /* ethernet interface we are using */
tax 0:66300c77c6e9 150 int sc_pd; /* ppp unit number */
tax 0:66300c77c6e9 151 void (*sc_linkStatusCB)(int pd, int up);
tax 0:66300c77c6e9 152
tax 0:66300c77c6e9 153 int sc_state; /* discovery phase or session connected */
tax 0:66300c77c6e9 154 struct eth_addr sc_dest; /* hardware address of concentrator */
tax 0:66300c77c6e9 155 u16_t sc_session; /* PPPoE session id */
tax 0:66300c77c6e9 156
tax 0:66300c77c6e9 157 #ifdef PPPOE_TODO
tax 0:66300c77c6e9 158 char *sc_service_name; /* if != NULL: requested name of service */
tax 0:66300c77c6e9 159 char *sc_concentrator_name; /* if != NULL: requested concentrator id */
tax 0:66300c77c6e9 160 #endif /* PPPOE_TODO */
tax 0:66300c77c6e9 161 u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */
tax 0:66300c77c6e9 162 size_t sc_ac_cookie_len; /* length of cookie data */
tax 0:66300c77c6e9 163 #ifdef PPPOE_SERVER
tax 0:66300c77c6e9 164 u8_t *sc_hunique; /* content of host unique we must echo back */
tax 0:66300c77c6e9 165 size_t sc_hunique_len; /* length of host unique */
tax 0:66300c77c6e9 166 #endif
tax 0:66300c77c6e9 167 int sc_padi_retried; /* number of PADI retries already done */
tax 0:66300c77c6e9 168 int sc_padr_retried; /* number of PADR retries already done */
tax 0:66300c77c6e9 169 };
tax 0:66300c77c6e9 170
tax 0:66300c77c6e9 171
tax 0:66300c77c6e9 172 #define pppoe_init() /* compatibility define, no initialization needed */
tax 0:66300c77c6e9 173
tax 0:66300c77c6e9 174 err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
tax 0:66300c77c6e9 175 err_t pppoe_destroy(struct netif *ifp);
tax 0:66300c77c6e9 176
tax 0:66300c77c6e9 177 int pppoe_connect(struct pppoe_softc *sc);
tax 0:66300c77c6e9 178 void pppoe_disconnect(struct pppoe_softc *sc);
tax 0:66300c77c6e9 179
tax 0:66300c77c6e9 180 void pppoe_disc_input(struct netif *netif, struct pbuf *p);
tax 0:66300c77c6e9 181 void pppoe_data_input(struct netif *netif, struct pbuf *p);
tax 0:66300c77c6e9 182
tax 0:66300c77c6e9 183 err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb);
tax 0:66300c77c6e9 184
tax 0:66300c77c6e9 185 /** used in ppp.c */
tax 0:66300c77c6e9 186 #define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN)
tax 0:66300c77c6e9 187
tax 0:66300c77c6e9 188 #endif /* PPPOE_SUPPORT */
tax 0:66300c77c6e9 189
tax 0:66300c77c6e9 190 #endif /* PPP_OE_H */