Hello all,
i have it ! i am happy now ;-)
here my changes for my multi_app solution.
*in the uip-conf.h i include my apps.*
/* Here we include the header file for the application(s) we use in
our project. */
#include <uip_app_router.h>
#include <cmd_server.h>
#include <telnetd.h>
#endif /* __UIP_CONF_H__ */
*my app_router.c*
#include <global.h>
#include <uip/uip.h>
void uip_router_init(void){
telnetd_init();
cmd_server_init();
}
void uip_router_udp_appcall(void){
}
void uip_router_tcp_appcall(void){
switch(uip_conn->lport) {
case HTONS(23):
telnetd_appcall();
break;
case HTONS(86):
cmd_server_appcall();
break;
}
}
*app_router.h*
#ifndef __UIP_APP_ROUTER_H__
#define __UIP_APP_ROUTER_H__
#include <uip/uipopt.h>
struct router_state {
u8_t state;
}__attribute__((packed)) uip_router_s;
#ifdef UIP_APPCALL
/* If UIP_APPCALL is already defined from another uIP App */
#undef UIP_APPCALL
/* then undefine it and force uIP apps to register */
#endif
#ifndef UIP_APPCALL
#define UIP_APPCALL uip_router_tcp_appcall
#endif
#ifdef UIP_UDP_APPCALL
/* If UIP_UDP_APPCALL is already defined from an uIP App */
#undef UIP_UDP_APPCALL
/* then undefine it and redefine it as specified below */
#endif
#ifndef UIP_UDP_APPCALL
#define UIP_UDP_APPCALL uip_router_tcp_appcall
#endif
/* Finally we define the application function to be called by uIP. */
void uip_router_tcp_appcall(void);
void uip_router_udp_appcall(void);
void uip_router_init(void);
#endif /* __TELNETD_H__ */
*
and my cmd_server.c application*
#include <global.h>
#include <uip/uip.h>
#include <cmd_server.h>
/*---------------------------------------------------------------------------*/
void cmd_server_init(void){
uip_listen(HTONS(86));
}
/*---------------------------------------------------------------------------*/
static void newdata(void){
u16_t len;
char *dataptr;
len = uip_datalen();
dataptr = (char *)uip_appdata;
}
/*---------------------------------------------------------------------------*/
void cmd_server_appcall(void){
if(uip_connected()) {
}
if(uip_closed() || uip_aborted() || uip_timedout()) {
closed();
}
if(uip_acked()) {
acked();
}
if(uip_newdata()) {
newdata();
}
if(uip_rexmit() || uip_newdata() || uip_acked() || uip_connected() ||
uip_poll()) {
senddata();
}
}
/*---------------------------------------------------------------------------*/
static void senddata(void){
uip_send("Welcome!\n", 9);
}
static void closed(void){
}
static void acked(void){
}
*and the uip.h changes*
struct uip_conn {
uip_ipaddr_t ripaddr; /**< The IP address of the remote host. */
u16_t lport; /**< The local TCP port, in network byte order. */
u16_t rport; /**< The local remote TCP port, in network byte
order. */
u8_t rcv_nxt[4]; /**< The sequence number that we expect to
receive next. */
u8_t snd_nxt[4]; /**< The sequence number that was last sent by
us. */
u16_t len; /**< Length of the data that was previously sent. */
u16_t mss; /**< Current maximum segment size for the
connection. */
u16_t initialmss; /**< Initial maximum segment size for the
connection. */
u8_t sa; /**< Retransmission time-out calculation state
variable. */
u8_t sv; /**< Retransmission time-out calculation state
variable. */
u8_t rto; /**< Retransmission time-out. */
u8_t tcpstateflags; /**< TCP state and flags. */
u8_t timer; /**< The retransmission timer. */
u8_t nrtx; /**< The number of retransmissions for the last
segment sent. */
/** The application state. */
union{
struct router_state router_appstate;
struct telnetd_state telnetd_appstate;
struct cmd_server_state cmd_server_appstate;
}__attribute__((packed)) ;
}__attribute__ ((packed)) ;
Kai Klein schrieb:
hi all,
i like to use a multi application scenario,
i tried to implement the example from the application documentation.
but i get an error if i compile it. and my knowledge of c is quit low.
so maybe is only a c knowledge problem .
hope somone can help.
regards
kai
here my header file of the switch application who shell be called from
the stack.
#ifndef __UIP_APP_ROUTER_H__
#define __UIP_APP_ROUTER_H__
#include <uip/uipopt.h>
//struct uip_router_state {
// u8_t state;
//};
struct uip_router_state {
enum {WELCOME_SENT, WELCOME_ACKED} state;
};
^ "empty declaration" <<<<<<<<<< error is here <<<<<<<<<<<<<<
//typedef struct uip_router_state uip_tcp_appstate_t;
#ifndef UIP_APPCALL
#define UIP_APPCALL uip_router_appcall
#endif
/* Finally we define the application function to be called by uIP. */
void uip_router_appcall(void);
void uip_router_init(void);
#endif /* __TELNETD_H__ */
and here the c file:
#include <global.h>
#include <uip/uip.h>
void uip_router_init(void){
telnetd_init();
cmd_server_init();
}
void uip_router_appcall(void){
struct uip_router_state *s;
s = (struct uip_router_state *)uip_conn->appstate;
// struct uip_router_state *s = &(uip_conn->appstate);
switch(uip_conn->lport) {
// case HTONS(23):
// telnetd_appcall();
// break;
// case HTONS(86):
// cmd_server_appcall();
// break;
}
}