40 #include "contiki-net.h"
43 PROCESS(shell_udpsend_process,
"udpsend");
46 "udpsend <host> <remote port> [local port]: send UDP data",
47 &shell_udpsend_process);
50 #define MAX_SERVERLEN 16
54 static uip_ipaddr_t serveraddr;
55 static char server[MAX_SERVERLEN + 1];
57 static unsigned char running;
61 send_line(
char *line,
int len)
63 uip_udp_packet_send(udpconn, line, len);
67 newdata(
char *data, uint16_t len)
74 const char *next, *nextptr;
76 uint16_t port, local_port;
80 next = strchr(data,
' ');
83 "udpsend <server> <port> [localport]: server as address",
"");
86 if(next - (
char *)data >
sizeof(server)) {
90 strncpy(server, data,
sizeof(server));
92 server[next - (
char *)data] = 0;
111 if(input->len1 + input->len2 == 0) {
115 if(input->len1 > 0) {
116 send_line(input->data1, input->len1);
125 if((
char *)data !=
NULL &&
128 telnet_connect(&s, server, serveraddr, nick);
140 shell_udpsend_init(
void)
Hostname is fresh and usable.
void shell_output_str(struct shell_command *c, char *text1, const char *text2)
Output strings from a shell command.
#define PROCESS_EXIT()
Exit the currently running process.
#define PROCESS_BEGIN()
Define the beginning of a process.
CCIF struct uip_udp_conn * udp_new(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate)
Create a new UDP connection.
#define uip_newdata()
Is new incoming data available?
Main header file for the Contiki shell
#define NULL
The null pointer.
#define uiplib_ipaddrconv
Convert a textual representation of an IP address to a numerical representation.
void shell_output(struct shell_command *c, void *data1, int len1, const void *data2, int len2)
Output data from a shell command.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
unsigned long shell_strtolong(const char *str, const char **retstr)
Convert a string to a number.
CCIF process_event_t resolv_event_found
Event that is broadcasted when a DNS name has been resolved.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
Structure for shell input data.
CCIF uint16_t uip_htons(uint16_t val)
Convert a 16-bit quantity from host byte order to network byte order.
void shell_register_command(struct shell_command *c)
Register a command with the shell.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
#define PROCESS(name, strname)
Declare a process.
#define uip_datalen()
The length of any incoming data that is currently available (if available) in the uip_appdata buffer...
int shell_event_input
The event number for shell input data.
process_event_t tcpip_event
The uIP event.
#define udp_bind(conn, port)
Bind a UDP connection to a local port.
Representation of a uIP UDP connection.
#define SHELL_COMMAND(name, command, description, process)
Define a shell command.
uip_appdata
Pointer to the application data in the packet buffer.