Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Thu Sep 26 00:44:20 2013 -0500
Revision:
5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 5:3f93dd1d4cb3 1 /*
sam_grove 5:3f93dd1d4cb3 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
sam_grove 5:3f93dd1d4cb3 3 * All rights reserved.
sam_grove 5:3f93dd1d4cb3 4 *
sam_grove 5:3f93dd1d4cb3 5 * Redistribution and use in source and binary forms, with or without modification,
sam_grove 5:3f93dd1d4cb3 6 * are permitted provided that the following conditions are met:
sam_grove 5:3f93dd1d4cb3 7 *
sam_grove 5:3f93dd1d4cb3 8 * 1. Redistributions of source code must retain the above copyright notice,
sam_grove 5:3f93dd1d4cb3 9 * this list of conditions and the following disclaimer.
sam_grove 5:3f93dd1d4cb3 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
sam_grove 5:3f93dd1d4cb3 11 * this list of conditions and the following disclaimer in the documentation
sam_grove 5:3f93dd1d4cb3 12 * and/or other materials provided with the distribution.
sam_grove 5:3f93dd1d4cb3 13 * 3. The name of the author may not be used to endorse or promote products
sam_grove 5:3f93dd1d4cb3 14 * derived from this software without specific prior written permission.
sam_grove 5:3f93dd1d4cb3 15 *
sam_grove 5:3f93dd1d4cb3 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
sam_grove 5:3f93dd1d4cb3 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
sam_grove 5:3f93dd1d4cb3 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
sam_grove 5:3f93dd1d4cb3 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
sam_grove 5:3f93dd1d4cb3 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
sam_grove 5:3f93dd1d4cb3 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
sam_grove 5:3f93dd1d4cb3 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
sam_grove 5:3f93dd1d4cb3 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
sam_grove 5:3f93dd1d4cb3 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
sam_grove 5:3f93dd1d4cb3 25 * OF SUCH DAMAGE.
sam_grove 5:3f93dd1d4cb3 26 *
sam_grove 5:3f93dd1d4cb3 27 * This file is part of the lwIP TCP/IP stack.
sam_grove 5:3f93dd1d4cb3 28 *
sam_grove 5:3f93dd1d4cb3 29 * Author: Adam Dunkels <adam@sics.se>
sam_grove 5:3f93dd1d4cb3 30 *
sam_grove 5:3f93dd1d4cb3 31 */
sam_grove 5:3f93dd1d4cb3 32 #ifndef __LWIP_IP_H__
sam_grove 5:3f93dd1d4cb3 33 #define __LWIP_IP_H__
sam_grove 5:3f93dd1d4cb3 34
sam_grove 5:3f93dd1d4cb3 35 #include "lwip/opt.h"
sam_grove 5:3f93dd1d4cb3 36
sam_grove 5:3f93dd1d4cb3 37 #include "lwip/def.h"
sam_grove 5:3f93dd1d4cb3 38 #include "lwip/pbuf.h"
sam_grove 5:3f93dd1d4cb3 39 #include "lwip/ip_addr.h"
sam_grove 5:3f93dd1d4cb3 40 #include "lwip/err.h"
sam_grove 5:3f93dd1d4cb3 41 #include "lwip/netif.h"
sam_grove 5:3f93dd1d4cb3 42
sam_grove 5:3f93dd1d4cb3 43 #ifdef __cplusplus
sam_grove 5:3f93dd1d4cb3 44 extern "C" {
sam_grove 5:3f93dd1d4cb3 45 #endif
sam_grove 5:3f93dd1d4cb3 46
sam_grove 5:3f93dd1d4cb3 47 /** Currently, the function ip_output_if_opt() is only used with IGMP */
sam_grove 5:3f93dd1d4cb3 48 #define IP_OPTIONS_SEND LWIP_IGMP
sam_grove 5:3f93dd1d4cb3 49
sam_grove 5:3f93dd1d4cb3 50 #define IP_HLEN 20
sam_grove 5:3f93dd1d4cb3 51
sam_grove 5:3f93dd1d4cb3 52 #define IP_PROTO_ICMP 1
sam_grove 5:3f93dd1d4cb3 53 #define IP_PROTO_IGMP 2
sam_grove 5:3f93dd1d4cb3 54 #define IP_PROTO_UDP 17
sam_grove 5:3f93dd1d4cb3 55 #define IP_PROTO_UDPLITE 136
sam_grove 5:3f93dd1d4cb3 56 #define IP_PROTO_TCP 6
sam_grove 5:3f93dd1d4cb3 57
sam_grove 5:3f93dd1d4cb3 58 /* This is passed as the destination address to ip_output_if (not
sam_grove 5:3f93dd1d4cb3 59 to ip_output), meaning that an IP header already is constructed
sam_grove 5:3f93dd1d4cb3 60 in the pbuf. This is used when TCP retransmits. */
sam_grove 5:3f93dd1d4cb3 61 #ifdef IP_HDRINCL
sam_grove 5:3f93dd1d4cb3 62 #undef IP_HDRINCL
sam_grove 5:3f93dd1d4cb3 63 #endif /* IP_HDRINCL */
sam_grove 5:3f93dd1d4cb3 64 #define IP_HDRINCL NULL
sam_grove 5:3f93dd1d4cb3 65
sam_grove 5:3f93dd1d4cb3 66 #if LWIP_NETIF_HWADDRHINT
sam_grove 5:3f93dd1d4cb3 67 #define IP_PCB_ADDRHINT ;u8_t addr_hint
sam_grove 5:3f93dd1d4cb3 68 #else
sam_grove 5:3f93dd1d4cb3 69 #define IP_PCB_ADDRHINT
sam_grove 5:3f93dd1d4cb3 70 #endif /* LWIP_NETIF_HWADDRHINT */
sam_grove 5:3f93dd1d4cb3 71
sam_grove 5:3f93dd1d4cb3 72 /* This is the common part of all PCB types. It needs to be at the
sam_grove 5:3f93dd1d4cb3 73 beginning of a PCB type definition. It is located here so that
sam_grove 5:3f93dd1d4cb3 74 changes to this common part are made in one location instead of
sam_grove 5:3f93dd1d4cb3 75 having to change all PCB structs. */
sam_grove 5:3f93dd1d4cb3 76 #define IP_PCB \
sam_grove 5:3f93dd1d4cb3 77 /* ip addresses in network byte order */ \
sam_grove 5:3f93dd1d4cb3 78 ip_addr_t local_ip; \
sam_grove 5:3f93dd1d4cb3 79 ip_addr_t remote_ip; \
sam_grove 5:3f93dd1d4cb3 80 /* Socket options */ \
sam_grove 5:3f93dd1d4cb3 81 u8_t so_options; \
sam_grove 5:3f93dd1d4cb3 82 /* Type Of Service */ \
sam_grove 5:3f93dd1d4cb3 83 u8_t tos; \
sam_grove 5:3f93dd1d4cb3 84 /* Time To Live */ \
sam_grove 5:3f93dd1d4cb3 85 u8_t ttl \
sam_grove 5:3f93dd1d4cb3 86 /* link layer address resolution hint */ \
sam_grove 5:3f93dd1d4cb3 87 IP_PCB_ADDRHINT
sam_grove 5:3f93dd1d4cb3 88
sam_grove 5:3f93dd1d4cb3 89 struct ip_pcb {
sam_grove 5:3f93dd1d4cb3 90 /* Common members of all PCB types */
sam_grove 5:3f93dd1d4cb3 91 IP_PCB;
sam_grove 5:3f93dd1d4cb3 92 };
sam_grove 5:3f93dd1d4cb3 93
sam_grove 5:3f93dd1d4cb3 94 /*
sam_grove 5:3f93dd1d4cb3 95 * Option flags per-socket. These are the same like SO_XXX.
sam_grove 5:3f93dd1d4cb3 96 */
sam_grove 5:3f93dd1d4cb3 97 /*#define SOF_DEBUG (u8_t)0x01U Unimplemented: turn on debugging info recording */
sam_grove 5:3f93dd1d4cb3 98 #define SOF_ACCEPTCONN (u8_t)0x02U /* socket has had listen() */
sam_grove 5:3f93dd1d4cb3 99 #define SOF_REUSEADDR (u8_t)0x04U /* allow local address reuse */
sam_grove 5:3f93dd1d4cb3 100 #define SOF_KEEPALIVE (u8_t)0x08U /* keep connections alive */
sam_grove 5:3f93dd1d4cb3 101 /*#define SOF_DONTROUTE (u8_t)0x10U Unimplemented: just use interface addresses */
sam_grove 5:3f93dd1d4cb3 102 #define SOF_BROADCAST (u8_t)0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
sam_grove 5:3f93dd1d4cb3 103 /*#define SOF_USELOOPBACK (u8_t)0x40U Unimplemented: bypass hardware when possible */
sam_grove 5:3f93dd1d4cb3 104 #define SOF_LINGER (u8_t)0x80U /* linger on close if data present */
sam_grove 5:3f93dd1d4cb3 105 /*#define SOF_OOBINLINE (u16_t)0x0100U Unimplemented: leave received OOB data in line */
sam_grove 5:3f93dd1d4cb3 106 /*#define SOF_REUSEPORT (u16_t)0x0200U Unimplemented: allow local address & port reuse */
sam_grove 5:3f93dd1d4cb3 107
sam_grove 5:3f93dd1d4cb3 108 /* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */
sam_grove 5:3f93dd1d4cb3 109 #define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/)
sam_grove 5:3f93dd1d4cb3 110
sam_grove 5:3f93dd1d4cb3 111
sam_grove 5:3f93dd1d4cb3 112 #ifdef PACK_STRUCT_USE_INCLUDES
sam_grove 5:3f93dd1d4cb3 113 # include "arch/bpstruct.h"
sam_grove 5:3f93dd1d4cb3 114 #endif
sam_grove 5:3f93dd1d4cb3 115 PACK_STRUCT_BEGIN
sam_grove 5:3f93dd1d4cb3 116 struct ip_hdr {
sam_grove 5:3f93dd1d4cb3 117 /* version / header length / type of service */
sam_grove 5:3f93dd1d4cb3 118 PACK_STRUCT_FIELD(u16_t _v_hl_tos);
sam_grove 5:3f93dd1d4cb3 119 /* total length */
sam_grove 5:3f93dd1d4cb3 120 PACK_STRUCT_FIELD(u16_t _len);
sam_grove 5:3f93dd1d4cb3 121 /* identification */
sam_grove 5:3f93dd1d4cb3 122 PACK_STRUCT_FIELD(u16_t _id);
sam_grove 5:3f93dd1d4cb3 123 /* fragment offset field */
sam_grove 5:3f93dd1d4cb3 124 PACK_STRUCT_FIELD(u16_t _offset);
sam_grove 5:3f93dd1d4cb3 125 #define IP_RF 0x8000U /* reserved fragment flag */
sam_grove 5:3f93dd1d4cb3 126 #define IP_DF 0x4000U /* dont fragment flag */
sam_grove 5:3f93dd1d4cb3 127 #define IP_MF 0x2000U /* more fragments flag */
sam_grove 5:3f93dd1d4cb3 128 #define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */
sam_grove 5:3f93dd1d4cb3 129 /* time to live */
sam_grove 5:3f93dd1d4cb3 130 PACK_STRUCT_FIELD(u8_t _ttl);
sam_grove 5:3f93dd1d4cb3 131 /* protocol*/
sam_grove 5:3f93dd1d4cb3 132 PACK_STRUCT_FIELD(u8_t _proto);
sam_grove 5:3f93dd1d4cb3 133 /* checksum */
sam_grove 5:3f93dd1d4cb3 134 PACK_STRUCT_FIELD(u16_t _chksum);
sam_grove 5:3f93dd1d4cb3 135 /* source and destination IP addresses */
sam_grove 5:3f93dd1d4cb3 136 PACK_STRUCT_FIELD(ip_addr_p_t src);
sam_grove 5:3f93dd1d4cb3 137 PACK_STRUCT_FIELD(ip_addr_p_t dest);
sam_grove 5:3f93dd1d4cb3 138 } PACK_STRUCT_STRUCT;
sam_grove 5:3f93dd1d4cb3 139 PACK_STRUCT_END
sam_grove 5:3f93dd1d4cb3 140 #ifdef PACK_STRUCT_USE_INCLUDES
sam_grove 5:3f93dd1d4cb3 141 # include "arch/epstruct.h"
sam_grove 5:3f93dd1d4cb3 142 #endif
sam_grove 5:3f93dd1d4cb3 143
sam_grove 5:3f93dd1d4cb3 144 #define IPH_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12)
sam_grove 5:3f93dd1d4cb3 145 #define IPH_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f)
sam_grove 5:3f93dd1d4cb3 146 #define IPH_TOS(hdr) (ntohs((hdr)->_v_hl_tos) & 0xff)
sam_grove 5:3f93dd1d4cb3 147 #define IPH_LEN(hdr) ((hdr)->_len)
sam_grove 5:3f93dd1d4cb3 148 #define IPH_ID(hdr) ((hdr)->_id)
sam_grove 5:3f93dd1d4cb3 149 #define IPH_OFFSET(hdr) ((hdr)->_offset)
sam_grove 5:3f93dd1d4cb3 150 #define IPH_TTL(hdr) ((hdr)->_ttl)
sam_grove 5:3f93dd1d4cb3 151 #define IPH_PROTO(hdr) ((hdr)->_proto)
sam_grove 5:3f93dd1d4cb3 152 #define IPH_CHKSUM(hdr) ((hdr)->_chksum)
sam_grove 5:3f93dd1d4cb3 153
sam_grove 5:3f93dd1d4cb3 154 #define IPH_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos)))
sam_grove 5:3f93dd1d4cb3 155 #define IPH_LEN_SET(hdr, len) (hdr)->_len = (len)
sam_grove 5:3f93dd1d4cb3 156 #define IPH_ID_SET(hdr, id) (hdr)->_id = (id)
sam_grove 5:3f93dd1d4cb3 157 #define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off)
sam_grove 5:3f93dd1d4cb3 158 #define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl)
sam_grove 5:3f93dd1d4cb3 159 #define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto)
sam_grove 5:3f93dd1d4cb3 160 #define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum)
sam_grove 5:3f93dd1d4cb3 161
sam_grove 5:3f93dd1d4cb3 162 /** The interface that provided the packet for the current callback invocation. */
sam_grove 5:3f93dd1d4cb3 163 extern struct netif *current_netif;
sam_grove 5:3f93dd1d4cb3 164 /** Header of the input packet currently being processed. */
sam_grove 5:3f93dd1d4cb3 165 extern const struct ip_hdr *current_header;
sam_grove 5:3f93dd1d4cb3 166 /** Source IP address of current_header */
sam_grove 5:3f93dd1d4cb3 167 extern ip_addr_t current_iphdr_src;
sam_grove 5:3f93dd1d4cb3 168 /** Destination IP address of current_header */
sam_grove 5:3f93dd1d4cb3 169 extern ip_addr_t current_iphdr_dest;
sam_grove 5:3f93dd1d4cb3 170
sam_grove 5:3f93dd1d4cb3 171 #define ip_init() /* Compatibility define, not init needed. */
sam_grove 5:3f93dd1d4cb3 172 struct netif *ip_route(ip_addr_t *dest);
sam_grove 5:3f93dd1d4cb3 173 err_t ip_input(struct pbuf *p, struct netif *inp);
sam_grove 5:3f93dd1d4cb3 174 err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
sam_grove 5:3f93dd1d4cb3 175 u8_t ttl, u8_t tos, u8_t proto);
sam_grove 5:3f93dd1d4cb3 176 err_t ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
sam_grove 5:3f93dd1d4cb3 177 u8_t ttl, u8_t tos, u8_t proto,
sam_grove 5:3f93dd1d4cb3 178 struct netif *netif);
sam_grove 5:3f93dd1d4cb3 179 #if LWIP_NETIF_HWADDRHINT
sam_grove 5:3f93dd1d4cb3 180 err_t ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
sam_grove 5:3f93dd1d4cb3 181 u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint);
sam_grove 5:3f93dd1d4cb3 182 #endif /* LWIP_NETIF_HWADDRHINT */
sam_grove 5:3f93dd1d4cb3 183 #if IP_OPTIONS_SEND
sam_grove 5:3f93dd1d4cb3 184 err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
sam_grove 5:3f93dd1d4cb3 185 u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options,
sam_grove 5:3f93dd1d4cb3 186 u16_t optlen);
sam_grove 5:3f93dd1d4cb3 187 #endif /* IP_OPTIONS_SEND */
sam_grove 5:3f93dd1d4cb3 188 /** Get the interface that received the current packet.
sam_grove 5:3f93dd1d4cb3 189 * This function must only be called from a receive callback (udp_recv,
sam_grove 5:3f93dd1d4cb3 190 * raw_recv, tcp_accept). It will return NULL otherwise. */
sam_grove 5:3f93dd1d4cb3 191 #define ip_current_netif() (current_netif)
sam_grove 5:3f93dd1d4cb3 192 /** Get the IP header of the current packet.
sam_grove 5:3f93dd1d4cb3 193 * This function must only be called from a receive callback (udp_recv,
sam_grove 5:3f93dd1d4cb3 194 * raw_recv, tcp_accept). It will return NULL otherwise. */
sam_grove 5:3f93dd1d4cb3 195 #define ip_current_header() (current_header)
sam_grove 5:3f93dd1d4cb3 196 /** Source IP address of current_header */
sam_grove 5:3f93dd1d4cb3 197 #define ip_current_src_addr() (&current_iphdr_src)
sam_grove 5:3f93dd1d4cb3 198 /** Destination IP address of current_header */
sam_grove 5:3f93dd1d4cb3 199 #define ip_current_dest_addr() (&current_iphdr_dest)
sam_grove 5:3f93dd1d4cb3 200
sam_grove 5:3f93dd1d4cb3 201 #if IP_DEBUG
sam_grove 5:3f93dd1d4cb3 202 void ip_debug_print(struct pbuf *p);
sam_grove 5:3f93dd1d4cb3 203 #else
sam_grove 5:3f93dd1d4cb3 204 #define ip_debug_print(p)
sam_grove 5:3f93dd1d4cb3 205 #endif /* IP_DEBUG */
sam_grove 5:3f93dd1d4cb3 206
sam_grove 5:3f93dd1d4cb3 207 #ifdef __cplusplus
sam_grove 5:3f93dd1d4cb3 208 }
sam_grove 5:3f93dd1d4cb3 209 #endif
sam_grove 5:3f93dd1d4cb3 210
sam_grove 5:3f93dd1d4cb3 211 #endif /* __LWIP_IP_H__ */
sam_grove 5:3f93dd1d4cb3 212
sam_grove 5:3f93dd1d4cb3 213