mbed Phone Platform

Dependencies:   ulaw mbed ConfigFile

Committer:
okini3939
Date:
Sun Dec 26 15:49:07 2010 +0000
Revision:
1:0f82c574096f

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 1:0f82c574096f 1 /*
okini3939 1:0f82c574096f 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
okini3939 1:0f82c574096f 3 * All rights reserved.
okini3939 1:0f82c574096f 4 *
okini3939 1:0f82c574096f 5 * Redistribution and use in source and binary forms, with or without modification,
okini3939 1:0f82c574096f 6 * are permitted provided that the following conditions are met:
okini3939 1:0f82c574096f 7 *
okini3939 1:0f82c574096f 8 * 1. Redistributions of source code must retain the above copyright notice,
okini3939 1:0f82c574096f 9 * this list of conditions and the following disclaimer.
okini3939 1:0f82c574096f 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
okini3939 1:0f82c574096f 11 * this list of conditions and the following disclaimer in the documentation
okini3939 1:0f82c574096f 12 * and/or other materials provided with the distribution.
okini3939 1:0f82c574096f 13 * 3. The name of the author may not be used to endorse or promote products
okini3939 1:0f82c574096f 14 * derived from this software without specific prior written permission.
okini3939 1:0f82c574096f 15 *
okini3939 1:0f82c574096f 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
okini3939 1:0f82c574096f 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
okini3939 1:0f82c574096f 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
okini3939 1:0f82c574096f 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
okini3939 1:0f82c574096f 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
okini3939 1:0f82c574096f 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
okini3939 1:0f82c574096f 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
okini3939 1:0f82c574096f 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
okini3939 1:0f82c574096f 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
okini3939 1:0f82c574096f 25 * OF SUCH DAMAGE.
okini3939 1:0f82c574096f 26 *
okini3939 1:0f82c574096f 27 * This file is part of the lwIP TCP/IP stack.
okini3939 1:0f82c574096f 28 *
okini3939 1:0f82c574096f 29 * Author: Adam Dunkels <adam@sics.se>
okini3939 1:0f82c574096f 30 *
okini3939 1:0f82c574096f 31 */
okini3939 1:0f82c574096f 32 #ifndef __LWIP_API_MSG_H__
okini3939 1:0f82c574096f 33 #define __LWIP_API_MSG_H__
okini3939 1:0f82c574096f 34
okini3939 1:0f82c574096f 35 #include "lwip/opt.h"
okini3939 1:0f82c574096f 36
okini3939 1:0f82c574096f 37 #if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
okini3939 1:0f82c574096f 38
okini3939 1:0f82c574096f 39 #include <stddef.h> /* for size_t */
okini3939 1:0f82c574096f 40
okini3939 1:0f82c574096f 41 #include "lwip/ip_addr.h"
okini3939 1:0f82c574096f 42 #include "lwip/err.h"
okini3939 1:0f82c574096f 43 #include "lwip/sys.h"
okini3939 1:0f82c574096f 44 #include "lwip/igmp.h"
okini3939 1:0f82c574096f 45 #include "lwip/api.h"
okini3939 1:0f82c574096f 46
okini3939 1:0f82c574096f 47 #ifdef __cplusplus
okini3939 1:0f82c574096f 48 extern "C" {
okini3939 1:0f82c574096f 49 #endif
okini3939 1:0f82c574096f 50
okini3939 1:0f82c574096f 51 #define NETCONN_SHUT_RD 1
okini3939 1:0f82c574096f 52 #define NETCONN_SHUT_WR 2
okini3939 1:0f82c574096f 53 #define NETCONN_SHUT_RDWR 3
okini3939 1:0f82c574096f 54
okini3939 1:0f82c574096f 55 /* IP addresses and port numbers are expected to be in
okini3939 1:0f82c574096f 56 * the same byte order as in the corresponding pcb.
okini3939 1:0f82c574096f 57 */
okini3939 1:0f82c574096f 58 /** This struct includes everything that is necessary to execute a function
okini3939 1:0f82c574096f 59 for a netconn in another thread context (mainly used to process netconns
okini3939 1:0f82c574096f 60 in the tcpip_thread context to be thread safe). */
okini3939 1:0f82c574096f 61 struct api_msg_msg {
okini3939 1:0f82c574096f 62 /** The netconn which to process - always needed: it includes the semaphore
okini3939 1:0f82c574096f 63 which is used to block the application thread until the function finished. */
okini3939 1:0f82c574096f 64 struct netconn *conn;
okini3939 1:0f82c574096f 65 /** The return value of the function executed in tcpip_thread. */
okini3939 1:0f82c574096f 66 err_t err;
okini3939 1:0f82c574096f 67 /** Depending on the executed function, one of these union members is used */
okini3939 1:0f82c574096f 68 union {
okini3939 1:0f82c574096f 69 /** used for do_send */
okini3939 1:0f82c574096f 70 struct netbuf *b;
okini3939 1:0f82c574096f 71 /** used for do_newconn */
okini3939 1:0f82c574096f 72 struct {
okini3939 1:0f82c574096f 73 u8_t proto;
okini3939 1:0f82c574096f 74 } n;
okini3939 1:0f82c574096f 75 /** used for do_bind and do_connect */
okini3939 1:0f82c574096f 76 struct {
okini3939 1:0f82c574096f 77 ip_addr_t *ipaddr;
okini3939 1:0f82c574096f 78 u16_t port;
okini3939 1:0f82c574096f 79 } bc;
okini3939 1:0f82c574096f 80 /** used for do_getaddr */
okini3939 1:0f82c574096f 81 struct {
okini3939 1:0f82c574096f 82 ip_addr_t *ipaddr;
okini3939 1:0f82c574096f 83 u16_t *port;
okini3939 1:0f82c574096f 84 u8_t local;
okini3939 1:0f82c574096f 85 } ad;
okini3939 1:0f82c574096f 86 /** used for do_write */
okini3939 1:0f82c574096f 87 struct {
okini3939 1:0f82c574096f 88 const void *dataptr;
okini3939 1:0f82c574096f 89 size_t len;
okini3939 1:0f82c574096f 90 u8_t apiflags;
okini3939 1:0f82c574096f 91 } w;
okini3939 1:0f82c574096f 92 /** used for do_recv */
okini3939 1:0f82c574096f 93 struct {
okini3939 1:0f82c574096f 94 u32_t len;
okini3939 1:0f82c574096f 95 } r;
okini3939 1:0f82c574096f 96 /** used for do_close (/shutdown) */
okini3939 1:0f82c574096f 97 struct {
okini3939 1:0f82c574096f 98 u8_t shut;
okini3939 1:0f82c574096f 99 } sd;
okini3939 1:0f82c574096f 100 #if LWIP_IGMP
okini3939 1:0f82c574096f 101 /** used for do_join_leave_group */
okini3939 1:0f82c574096f 102 struct {
okini3939 1:0f82c574096f 103 ip_addr_t *multiaddr;
okini3939 1:0f82c574096f 104 ip_addr_t *netif_addr;
okini3939 1:0f82c574096f 105 enum netconn_igmp join_or_leave;
okini3939 1:0f82c574096f 106 } jl;
okini3939 1:0f82c574096f 107 #endif /* LWIP_IGMP */
okini3939 1:0f82c574096f 108 #if TCP_LISTEN_BACKLOG
okini3939 1:0f82c574096f 109 struct {
okini3939 1:0f82c574096f 110 u8_t backlog;
okini3939 1:0f82c574096f 111 } lb;
okini3939 1:0f82c574096f 112 #endif /* TCP_LISTEN_BACKLOG */
okini3939 1:0f82c574096f 113 } msg;
okini3939 1:0f82c574096f 114 };
okini3939 1:0f82c574096f 115
okini3939 1:0f82c574096f 116 /** This struct contains a function to execute in another thread context and
okini3939 1:0f82c574096f 117 a struct api_msg_msg that serves as an argument for this function.
okini3939 1:0f82c574096f 118 This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */
okini3939 1:0f82c574096f 119 struct api_msg {
okini3939 1:0f82c574096f 120 /** function to execute in tcpip_thread context */
okini3939 1:0f82c574096f 121 void (* function)(struct api_msg_msg *msg);
okini3939 1:0f82c574096f 122 /** arguments for this function */
okini3939 1:0f82c574096f 123 struct api_msg_msg msg;
okini3939 1:0f82c574096f 124 };
okini3939 1:0f82c574096f 125
okini3939 1:0f82c574096f 126 #if LWIP_DNS
okini3939 1:0f82c574096f 127 /** As do_gethostbyname requires more arguments but doesn't require a netconn,
okini3939 1:0f82c574096f 128 it has its own struct (to avoid struct api_msg getting bigger than necessary).
okini3939 1:0f82c574096f 129 do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
okini3939 1:0f82c574096f 130 (see netconn_gethostbyname). */
okini3939 1:0f82c574096f 131 struct dns_api_msg {
okini3939 1:0f82c574096f 132 /** Hostname to query or dotted IP address string */
okini3939 1:0f82c574096f 133 const char *name;
okini3939 1:0f82c574096f 134 /** Rhe resolved address is stored here */
okini3939 1:0f82c574096f 135 ip_addr_t *addr;
okini3939 1:0f82c574096f 136 /** This semaphore is posted when the name is resolved, the application thread
okini3939 1:0f82c574096f 137 should wait on it. */
okini3939 1:0f82c574096f 138 sys_sem_t *sem;
okini3939 1:0f82c574096f 139 /** Errors are given back here */
okini3939 1:0f82c574096f 140 err_t *err;
okini3939 1:0f82c574096f 141 };
okini3939 1:0f82c574096f 142 #endif /* LWIP_DNS */
okini3939 1:0f82c574096f 143
okini3939 1:0f82c574096f 144 void do_newconn ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 145 void do_delconn ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 146 void do_bind ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 147 void do_connect ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 148 void do_disconnect ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 149 void do_listen ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 150 void do_send ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 151 void do_recv ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 152 void do_write ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 153 void do_getaddr ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 154 void do_close ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 155 void do_shutdown ( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 156 #if LWIP_IGMP
okini3939 1:0f82c574096f 157 void do_join_leave_group( struct api_msg_msg *msg);
okini3939 1:0f82c574096f 158 #endif /* LWIP_IGMP */
okini3939 1:0f82c574096f 159
okini3939 1:0f82c574096f 160 #if LWIP_DNS
okini3939 1:0f82c574096f 161 void do_gethostbyname(void *arg);
okini3939 1:0f82c574096f 162 #endif /* LWIP_DNS */
okini3939 1:0f82c574096f 163
okini3939 1:0f82c574096f 164 struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
okini3939 1:0f82c574096f 165 void netconn_free(struct netconn *conn);
okini3939 1:0f82c574096f 166
okini3939 1:0f82c574096f 167 #ifdef __cplusplus
okini3939 1:0f82c574096f 168 }
okini3939 1:0f82c574096f 169 #endif
okini3939 1:0f82c574096f 170
okini3939 1:0f82c574096f 171 #endif /* LWIP_NETCONN */
okini3939 1:0f82c574096f 172
okini3939 1:0f82c574096f 173 #endif /* __LWIP_API_MSG_H__ */