Microchip® Advanced Software Framework

wireless/SmartConnect_6LoWPAN/apps/ip64-webserver/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().

void httpd_init ( void  )

Referenced by main(), and PROCESS_THREAD().

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, result, uip_ip6addr_t::u16, and uip_ntohs.

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)

const uip_ipaddr_t* addr = NULL
s file data = s->len
do
Initial value:
{
#define PSOCK_GENERATOR_SEND(psock, generator, arg)
Generate data with a function and send it.
Definition: psock.h:225
static unsigned short generate(void *state)
Definition: wireless/SmartConnect_6LoWPAN/apps/ip64-webserver/httpd.c:107
PSOCK_END & s
Definition: wireless/SmartConnect_6LoWPAN/apps/ip64-webserver/httpd.c:132
else
Initial value:
{
const char ip64_webserver_http_content_type_plain[29]
Definition: ip64-webserver-http-strings.c:55
ptr
Definition: wireless/SmartConnect_6LoWPAN/apps/ip64-webserver/httpd.c:236
struct udp_socket led_socket

Referenced by httpd_init().

s file len = s->len

Referenced by _read(), _write(), acked(), app_wifi_init(), base64decode(), ble_trans_service_send_buf(), casecmp(), cbcmac_calc(), cbcmac_verify(), cgi_GetStaus(), crc16_data(), crc7(), create(), csc_app_send_buf(), csc_serv_init(), cycle(), dao_input(), decodePacket(), dio_input(), dsu_crc32_cal(), dump_hex_buffer(), eddystone_set_encoded_url(), event(), fetch_data(), fmp_target_connected_state_handler(), get_length(), get_match_length(), getLenStringLen(), handle_incoming_rreq(), handlePublish(), handlePubrec(), hid_get_reportchar(), hid_get_reportid(), hid_serv_report_map(), http_send_data(), http_write(), input_callback(), iot_tls_read(), iot_tls_write(), isSubStr(), keepalive(), ksz8851snl_read(), ksz8851snl_update(), m2m_wifi_ble_api_send(), m2m_wifi_connect_sc(), main(), MQTTConnect(), MQTTDeserialize_connect(), MQTTDisconnect(), MQTTPacket_decode(), MQTTPacket_read(), MQTTPublish(), MQTTResubscribe(), MQTTSerialize_connect(), MQTTSerialize_connectLength(), MQTTSerialize_GetConnectLength(), MQTTSerialize_GetPublishLength(), MQTTSerialize_GetSubscribePacketLength(), MQTTSerialize_GetUnsubscribePacketLength(), MQTTSerialize_publishLength(), MQTTSerialize_subscribeLength(), MQTTSerialize_unsubscribeLength(), MQTTstrlen(), MQTTSubscribe(), MQTTUnsubscribe(), newdata(), numtostring(), output(), packetbuf_compact(), packetbuf_copyfrom(), packetbuf_reference(), packetbuf_set_datalen(), parse(), parse_headers(), parse_options(), parse_statusline(), pbuf_clen(), pbuf_copy(), pbuf_copy_partial(), pbuf_header(), pbuf_take(), pds_calc_crc(), pds_nvm_read(), pds_write(), platform_interface_callback(), platform_send_sync(), PROCESS_THREAD(), PT_THREAD(), pxp_reporter_connected_state_handler(), read(), readInt(), readPacket(), readPacketId(), receive_header_byte(), rf212_read(), rf233_read(), rpl_set_prefix(), send_one_packet(), send_packet(), send_rreq(), senddata(), sensors_find(), set_dev_name_to_mac(), slip_poll_handler(), slip_write(), slipdev_init(), slipdev_poll(), tcp_socket_send(), uhc_enumeration_step17_lpm(), uip_packetqueue_set_buflen(), uip_udp_packet_send(), uiplib_ip6addrconv(), uncompress_hdr_hc06(), uncompress_hdr_hc1(), websocket_http_client_datahandler(), websocket_http_client_send(), wifiscan_print_char(), WINC1500_read(), WINC1500_write(), window_copy(), and writeCString().

uint8_t nbr_action
uint8_t nbr_id
void* uptr
Initial value:
{
char *ptr ,*ptr2
ptr
Definition: wireless/SmartConnect_6LoWPAN/apps/ip64-webserver/httpd.c:236