Microchip® Advanced Software Framework

httpd.c File Reference
#include <stdio.h>
#include <string.h>
#include "contiki-net.h"
#include "httpd-fs.h"
#include "httpd-cgi.h"
#include "lib/petsciiconv.h"
#include "ip64-webserver-http-strings.h"
#include "httpd.h"
#include "ledctrl.h"

Macros

#define CONNS   UIP_CONNS
 
#define ISO_ampersand   0x26
 
#define ISO_bang   0x21
 
#define ISO_colon   0x3a
 
#define ISO_nl   0x0a
 
#define ISO_percent   0x25
 
#define ISO_period   0x2e
 
#define ISO_question   0x3F
 
#define ISO_slash   0x2f
 
#define ISO_space   0x20
 
#define SEND_STRING(s, str)   PSOCK_SEND(s, (uint8_t *)str, (unsigned int)strlen(str))
 
#define STATE_OUTPUT   1
 
#define STATE_WAITING   0
 

Functions

static unsigned short generate (void *state)
 
static void handle_connection (struct httpd_state *s)
 
void httpd_appcall (void *state)
 
void httpd_init (void)
 
uint8_t httpd_sprint_ip4 (const uip_ip4addr_t *addr, char *result)
 
uint8_t httpd_sprint_ip6 (const uip_ip6addr_t *addr, char *result)
 
 if (ptr==NULL)
 
else if (strncmp(ip64_webserver_http_html, ptr, 5)==0||strncmp(ip64_webserver_http_shtml, ptr, 6)==0)
 
else if (strncmp(ip64_webserver_http_css, ptr, 4)==0)
 
else if (strncmp(ip64_webserver_http_png, ptr, 4)==0)
 
else if (strncmp(ip64_webserver_http_gif, ptr, 4)==0)
 
else if (strncmp(ip64_webserver_http_jpg, ptr, 4)==0)
 
 if (!httpd_fs_open(s->filename,&s->file))
 
 if (ptr!=NULL &&strncmp(ptr, ip64_webserver_http_shtml, 6)==0)
 
 if (strncmp(s->inputbuf, ip64_webserver_http_get, 4)!=0)
 
 if (s->inputbuf[0]!=ISO_slash)
 
 if (s->inputbuf[1]==ISO_space)
 
void led_socket_callback (struct udp_socket *c, void *ptr, const uip_ipaddr_t *source_addr, uint16_t source_port, const uip_ipaddr_t *dest_addr, uint16_t dest_port, const uint8_t *data, uint16_t datalen)
 
 MEMB (conns, struct httpd_state, CONNS)
 
static void next_scriptstate (struct httpd_state *s)
 
 petsciiconv_toascii (s->filename, sizeof(s->filename))
 
 petsciiconv_topetscii (s->filename, sizeof(s->filename))
 
static PSOCK_SENDs (uint8_t *) s->file.data, s->len
 
int simple_udp_ping_send_ping (const uip_ipaddr_t *addr)
 
 strncpy (s->filename, s->inputbuf, sizeof(s->filename))
 
 while (s->file.len > 0)
 
 while (1)
 

Variables

const uip_ipaddr_taddr = NULL
 
s file data = s->len
 
static do
 
 else
 
struct udp_socket led_socket
 
s file len = s->len
 
uint8_t nbr_action
 
uint8_t nbr_id
 
 ptr = strrchr(s->filename, ISO_period)
 
PSOCK_ENDs
 
s state = STATE_OUTPUT
 
static void * uptr
 

#define CONNS   UIP_CONNS
#define ISO_ampersand   0x26
#define ISO_bang   0x21

Referenced by while().

#define ISO_colon   0x3a

Referenced by while().

#define ISO_nl   0x0a

Referenced by next_scriptstate(), and while().

#define ISO_percent   0x25

Referenced by while().

#define ISO_period   0x2e
#define ISO_question   0x3F
#define ISO_slash   0x2f
#define ISO_space   0x20
#define SEND_STRING (   s,
  str 
)    PSOCK_SEND(s, (uint8_t *)str, (unsigned int)strlen(str))
#define STATE_OUTPUT   1

Referenced by handle_connection().

#define STATE_WAITING   0

Referenced by httpd_appcall().

static unsigned short generate ( void *  state)
static
static void handle_connection ( struct httpd_state s)
static

References httpd_state::state, and STATE_OUTPUT.

Referenced by httpd_appcall().

uint8_t httpd_sprint_ip4 ( const uip_ip4addr_t addr,
char *  result 
)

References uip_ipaddr_to_quad.

Referenced by make_addrmap().

uint8_t httpd_sprint_ip6 ( const uip_ip6addr_t addr,
char *  result 
)

References i, and uip_ip6addr_t::u16.

Referenced by make_tcp_stats().

else if ( strncmp(ip64_webserver_http_html, ptr, 5)  = = 0 || strncmp(ip64_webserver_http_shtmlptr, 6) == 0)
else if ( strncmp(ip64_webserver_http_css, ptr, 4)  = = 0)
else if ( strncmp(ip64_webserver_http_png, ptr, 4)  = = 0)
else if ( strncmp(ip64_webserver_http_gif, ptr, 4)  = = 0)
else if ( strncmp(ip64_webserver_http_jpg, ptr, 4)  = = 0)
if ( ptr!  = NULL && strncmp(ptrip64_webserver_http_shtml, 6) == 0)
if ( strncmp(s->inputbuf, ip64_webserver_http_get, 4)!  = 0)

References PSOCK_CLOSE_EXIT.

if ( s->inputbuf!  [0] = ISO_slash)

References PSOCK_CLOSE_EXIT.

if ( s->  inputbuf[1] = ISO_space)
void led_socket_callback ( struct udp_socket c,
void *  ptr,
const uip_ipaddr_t source_addr,
uint16_t  source_port,
const uip_ipaddr_t dest_addr,
uint16_t  dest_port,
const uint8_t *  data,
uint16_t  datalen 
)

Referenced by httpd_init().

MEMB ( conns  ,
struct httpd_state  ,
CONNS   
)
static void next_scriptstate ( struct httpd_state s)
static
petsciiconv_toascii ( s->  filename,
sizeof(s->filename)   
)

Referenced by make_processes().

petsciiconv_topetscii ( s->  filename,
sizeof(s->filename)   
)

Referenced by while().

static PSOCK_SEND& s ( uint8_t *  ) -> file.data, s->len
int simple_udp_ping_send_ping ( const uip_ipaddr_t addr)

do
Initial value:
{
static unsigned short generate(void *state)
Definition: httpd.c:107
#define PSOCK_GENERATOR_SEND(psock, generator, arg)
Generate data with a function and send it.
Definition: psock.h:225
static struct dhcpc_state s
Definition: dhcpc.c:45
else
Initial value:
{
ptr
Definition: httpd.c:236
const char ip64_webserver_http_content_type_plain[29]
Definition: ip64-webserver-http-strings.c:55
struct udp_socket led_socket

Referenced by httpd_init().

uint8_t nbr_action
uint8_t nbr_id
Initial value:
{
char *ptr
ptr
Definition: httpd.c:236
s state = STATE_OUTPUT
void* uptr
Initial value:
{
char *ptr ,*ptr2
ptr
Definition: httpd.c:236