44 PROCESS(shell_tcpsend_process,
"tcpsend");
47 "tcpsend <host> <port>: open a TCP connection",
48 &shell_tcpsend_process);
51 #define MAX_SERVERLEN 16
53 static uip_ipaddr_t serveraddr;
54 static char server[MAX_SERVERLEN + 1];
56 static struct telnet_state s;
58 static unsigned char running;
60 #define MAX_LINELEN 80
62 static char outputline[MAX_LINELEN];
63 static uint8_t sending;
66 telnet_text_output(
struct telnet_state *s,
char *text1,
char *text2)
68 char buf1[MAX_SERVERLEN];
71 strncpy(buf1, text1,
sizeof(buf1));
73 if(len <
sizeof(buf1) - 1) {
81 telnet_newdata(
struct telnet_state *s,
char *data, uint16_t len)
87 send_line(
struct telnet_state *s,
char *data,
int len)
90 strncpy(outputline, data, MIN(
sizeof(outputline), len));
91 telnet_send(s, data, len);
94 shell_output_str(&tcpsend_command,
"Cannot send data, still sending previous data",
"");
99 telnet_sent(
struct telnet_state *s)
105 telnet_closed(
struct telnet_state *s)
107 telnet_text_output(s, server,
"connection closed");
112 telnet_aborted(
struct telnet_state *s)
114 telnet_text_output(s, server,
"connection aborted");
119 telnet_timedout(
struct telnet_state *s)
121 telnet_text_output(s, server,
"connection timed out");
126 telnet_connected(
struct telnet_state *s)
128 telnet_text_output(s, server,
"connected");
140 next = strchr(data,
' ');
143 "tcpsend <server> <port>: server as address",
"");
148 strncpy(server, data,
sizeof(server));
154 telnet_connect(&s, &serveraddr, port);
160 if(input->len1 + input->len2 == 0) {
164 if(input->len1 > 0) {
165 send_line(&s, input->data1, input->len1);
172 if((
char *)data !=
NULL &&
175 telnet_connect(&s, server, serveraddr, nick);
187 shell_tcpsend_init(
void)
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
process_event_t tcpip_event
The uIP event.
Default definitions of C compiler quirk work-arounds.
Main header file for the Contiki shell
void shell_output_str(struct shell_command *c, char *text1, const char *text2)
Output strings from a shell command.
#define PROCESS_END()
Define the end of a process.
#define PROCESS(name, strname)
Declare a process.
static void input(void)
Process a received 6lowpan packet.
unsigned long shell_strtolong(const char *str, const char **retstr)
Convert a string to a number.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_EXIT()
Exit the currently running process.
void shell_output(struct shell_command *c, void *data1, int len1, const void *data2, int len2)
Output data from a shell command.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
#define SHELL_COMMAND(name, command, description, process)
Define a shell command.
process_event_t resolv_event_found
Event that is broadcasted when a DNS name has been resolved.
int shell_event_input
The event number for shell input data.
void shell_register_command(struct shell_command *c)
Register a command with the shell.
#define NULL
The null pointer.
resolv_status_t resolv_lookup(const char *name, uip_ipaddr_t **ipaddr)
Look up a hostname in the array of known hostnames.
Structure for shell input data.
Hostname is fresh and usable.
#define uiplib_ipaddrconv
Convert a textual representation of an IP address to a numerical representation.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define PROCESS_BEGIN()
Define the beginning of a process.