Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/lwip/api_msg.h need to be fixed.

0001 /*
0002  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
0003  * All rights reserved. 
0004  * 
0005  * Redistribution and use in source and binary forms, with or without modification, 
0006  * are permitted provided that the following conditions are met:
0007  *
0008  * 1. Redistributions of source code must retain the above copyright notice,
0009  *    this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright notice,
0011  *    this list of conditions and the following disclaimer in the documentation
0012  *    and/or other materials provided with the distribution.
0013  * 3. The name of the author may not be used to endorse or promote products
0014  *    derived from this software without specific prior written permission. 
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
0017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
0018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
0019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
0020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
0021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
0024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
0025  * OF SUCH DAMAGE.
0026  *
0027  * This file is part of the lwIP TCP/IP stack.
0028  * 
0029  * Author: Adam Dunkels <adam@sics.se>
0030  *
0031  */
0032 #ifndef __LWIP_API_MSG_H__
0033 #define __LWIP_API_MSG_H__
0034 
0035 #include "lwip/opt.h"
0036 
0037 #if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
0038 
0039 #include <stddef.h>
0040 
0041 #include "lwip/ip_addr.h"
0042 #include "lwip/err.h"
0043 #include "lwip/sys.h"
0044 #include "lwip/igmp.h"
0045 #include "lwip/api.h"
0046 
0047 #ifdef __cplusplus
0048 extern "C" {
0049 #endif
0050 
0051 /* IP addresses and port numbers are expected to be in
0052  * the same byte order as in the corresponding pcb.
0053  */
0054 /** This struct includes everything that is necessary to execute a function
0055     for a netconn in another thread context (mainly used to process netconns
0056     in the tcpip_thread context to be thread safe). */
0057 struct api_msg_msg {
0058   /** The netconn which to process - always needed: it includes the semaphore
0059       which is used to block the application thread until the function finished. */
0060   struct netconn *conn;
0061   /** Depending on the executed function, one of these union members is used */
0062   union {
0063     /** used for do_send */
0064     struct netbuf *b;
0065     /** used for do_newconn */
0066     struct {
0067       u8_t proto;
0068     } n;
0069     /** used for do_bind and do_connect */
0070     struct {
0071       struct ip_addr *ipaddr;
0072       u16_t port;
0073     } bc;
0074     /** used for do_getaddr */
0075     struct {
0076       struct ip_addr *ipaddr;
0077       u16_t *port;
0078       u8_t local;
0079     } ad;
0080     /** used for do_write */
0081     struct {
0082       const void *dataptr;
0083       size_t len;
0084       u8_t apiflags;
0085     } w;
0086     /** used for do_recv */
0087     struct {
0088       u16_t len;
0089     } r;
0090 #if LWIP_IGMP
0091     /** used for do_join_leave_group */
0092     struct {
0093       struct ip_addr *multiaddr;
0094       struct ip_addr *interface;
0095       enum netconn_igmp join_or_leave;
0096     } jl;
0097 #endif /* LWIP_IGMP */
0098 #if TCP_LISTEN_BACKLOG
0099     struct {
0100       u8_t backlog;
0101     } lb;
0102 #endif /* TCP_LISTEN_BACKLOG */
0103   } msg;
0104 };
0105 
0106 /** This struct contains a function to execute in another thread context and
0107     a struct api_msg_msg that serves as an argument for this function.
0108     This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */
0109 struct api_msg {
0110   /** function to execute in tcpip_thread context */
0111   void (* function)(struct api_msg_msg *msg);
0112   /** arguments for this function */
0113   struct api_msg_msg msg;
0114 };
0115 
0116 #if LWIP_DNS
0117 /** As do_gethostbyname requires more arguments but doesn't require a netconn,
0118     it has its own struct (to avoid struct api_msg getting bigger than necessary).
0119     do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
0120     (see netconn_gethostbyname). */
0121 struct dns_api_msg {
0122   /** Hostname to query or dotted IP address string */
0123   const char *name;
0124   /** Rhe resolved address is stored here */
0125   struct ip_addr *addr;
0126   /** This semaphore is posted when the name is resolved, the application thread
0127       should wait on it. */
0128   sys_sem_t sem;
0129   /** Errors are given back here */
0130   err_t *err;
0131 };
0132 #endif /* LWIP_DNS */
0133 
0134 void do_newconn         ( struct api_msg_msg *msg);
0135 void do_delconn         ( struct api_msg_msg *msg);
0136 void do_bind            ( struct api_msg_msg *msg);
0137 void do_connect         ( struct api_msg_msg *msg);
0138 void do_disconnect      ( struct api_msg_msg *msg);
0139 void do_listen          ( struct api_msg_msg *msg);
0140 void do_send            ( struct api_msg_msg *msg);
0141 void do_recv            ( struct api_msg_msg *msg);
0142 void do_write           ( struct api_msg_msg *msg);
0143 void do_getaddr         ( struct api_msg_msg *msg);
0144 void do_close           ( struct api_msg_msg *msg);
0145 #if LWIP_IGMP
0146 void do_join_leave_group( struct api_msg_msg *msg);
0147 #endif /* LWIP_IGMP */
0148 
0149 #if LWIP_DNS
0150 void do_gethostbyname(void *arg);
0151 #endif /* LWIP_DNS */
0152 
0153 struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
0154 void netconn_free(struct netconn *conn);
0155 
0156 #ifdef __cplusplus
0157 }
0158 #endif
0159 
0160 #endif /* LWIP_NETCONN */
0161 
0162 #endif /* __LWIP_API_MSG_H__ */