Ilya I / iva2k_NetHttpServerTcpSockets

Description: Example program with HTTPServer and sensor data streaming over TCPSockets, using Donatien Garnier's Net APIs and services code on top of LWIP. Files StreamServer.h and .cpp encapsulate streaming over TCPSockets. Broadcast is done by sendToAll(), and all incoming data is echoed back to the client. Echo code can be replaced with some remote control of the streaming interface. See main() that shows how to periodically send some data to all subscribed clients. To subscribe, a client should open a socket at <mbed_ip> port 123. I used few lines in TCL code to set up a quick sink for the data. HTTP files are served on port 80 concurrently to the streaming.

Embed: (wiki syntax)

« Back to documentation index

msg_out.c File Reference

msg_out.c File Reference

SNMP output message processing (RFC1157). More...

Go to the source code of this file.

Functions

static u16_t snmp_resp_header_sum (struct snmp_msg_pstat *m_stat, u16_t vb_len)
 Sums response header field lengths from tail to head and returns resp_header_lengths for second encoding pass.
static u16_t snmp_trap_header_sum (struct snmp_msg_trap *m_trap, u16_t vb_len)
 Sums trap header field lengths from tail to head and returns trap_header_lengths for second encoding pass.
static u16_t snmp_varbind_list_sum (struct snmp_varbind_root *root)
 Sums varbind lengths from tail to head and annotates lengths in varbind for second encoding pass.
static u16_t snmp_resp_header_enc (struct snmp_msg_pstat *m_stat, struct pbuf *p)
 Encodes response header from head to tail.
static u16_t snmp_trap_header_enc (struct snmp_msg_trap *m_trap, struct pbuf *p)
 Encodes trap header from head to tail.
static u16_t snmp_varbind_list_enc (struct snmp_varbind_root *root, struct pbuf *p, u16_t ofs)
 Encodes varbind list from head to tail.
void snmp_trap_dst_enable (u8_t dst_idx, u8_t enable)
 Sets enable switch for this trap destination.
void snmp_trap_dst_ip_set (u8_t dst_idx, ip_addr_t *dst)
 Sets IPv4 address for this trap destination.
err_t snmp_send_response (struct snmp_msg_pstat *m_stat)
 Sends a 'getresponse' message to the request originator.
err_t snmp_send_trap (s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap)
 Sends an generic or enterprise specific trap message.

Variables

struct snmp_msg_trap trap_msg
 TRAP message structure.

Detailed Description

SNMP output message processing (RFC1157).

Output responses and traps are build in two passes:

Pass 0: iterate over the output message backwards to determine encoding lengths Pass 1: the actual forward encoding of internal form into ASN1

The single-pass encoding method described by Comer & Stevens requires extra buffer space and copying for reversal of the packet. The buffer requirement can be prohibitively large for big payloads (>= 484) therefore we use the two encoding passes.

Definition in file msg_out.c.


Function Documentation

static u16_t snmp_resp_header_enc ( struct snmp_msg_pstat *  m_stat,
struct pbuf *  p 
) [static]

Encodes response header from head to tail.

Definition at line 490 of file msg_out.c.

static u16_t snmp_resp_header_sum ( struct snmp_msg_pstat *  m_stat,
u16_t  vb_len 
) [static]

Sums response header field lengths from tail to head and returns resp_header_lengths for second encoding pass.

Parameters:
vb_lenvarbind-list length
rhlpoints to returned header lengths
Returns:
the required lenght for encoding the response header

Definition at line 322 of file msg_out.c.

err_t snmp_send_response ( struct snmp_msg_pstat *  m_stat )

Sends a 'getresponse' message to the request originator.

Parameters:
m_statpoints to the current message request state source
Returns:
ERR_OK when success, ERR_MEM if we're out of memory
Note:
the caller is responsible for filling in outvb in the m_stat and provide error-status and index (except for tooBig errors) ...

connect to the originating source

disassociate remote address and port with this pcb

Definition at line 113 of file msg_out.c.

err_t snmp_send_trap ( s8_t  generic_trap,
struct snmp_obj_id eoid,
s32_t  specific_trap 
)

Sends an generic or enterprise specific trap message.

Parameters:
generic_trapis the trap code
eoidpoints to enterprise object identifier
specific_trapused for enterprise traps when generic_trap == 6
Returns:
ERR_OK when success, ERR_MEM if we're out of memory
Note:
the caller is responsible for filling in outvb in the trap_msg
the use of the enterpise identifier field is per RFC1215. Use .iso.org.dod.internet.mgmt.mib-2.snmp for generic traps and .iso.org.dod.internet.private.enterprises.yourenterprise (sysObjectID) for specific traps.

connect to the TRAP destination

disassociate remote address and port with this pcb

Definition at line 220 of file msg_out.c.

void snmp_trap_dst_enable ( u8_t  dst_idx,
u8_t  enable 
)

Sets enable switch for this trap destination.

Parameters:
dst_idxindex in 0 .. SNMP_TRAP_DESTINATIONS-1
enableswitch if 0 destination is disabled >0 enabled.

Definition at line 81 of file msg_out.c.

void snmp_trap_dst_ip_set ( u8_t  dst_idx,
ip_addr_t *  dst 
)

Sets IPv4 address for this trap destination.

Parameters:
dst_idxindex in 0 .. SNMP_TRAP_DESTINATIONS-1
dstIPv4 address in host order.

Definition at line 95 of file msg_out.c.

static u16_t snmp_trap_header_enc ( struct snmp_msg_trap *  m_trap,
struct pbuf *  p 
) [static]

Encodes trap header from head to tail.

Definition at line 547 of file msg_out.c.

static u16_t snmp_trap_header_sum ( struct snmp_msg_trap *  m_trap,
u16_t  vb_len 
) [static]

Sums trap header field lengths from tail to head and returns trap_header_lengths for second encoding pass.

Parameters:
vb_lenvarbind-list length
thlpoints to returned header lengths
Returns:
the required lenght for encoding the trap header

Definition at line 369 of file msg_out.c.

static u16_t snmp_varbind_list_enc ( struct snmp_varbind_root *  root,
struct pbuf *  p,
u16_t  ofs 
) [static]

Encodes varbind list from head to tail.

Definition at line 618 of file msg_out.c.

static u16_t snmp_varbind_list_sum ( struct snmp_varbind_root *  root ) [static]

Sums varbind lengths from tail to head and annotates lengths in varbind for second encoding pass.

Parameters:
rootpoints to the root of the variable binding list
Returns:
the required lenght for encoding the variable bindings

Definition at line 424 of file msg_out.c.


Variable Documentation

struct snmp_msg_trap trap_msg

TRAP message structure.

Definition at line 65 of file msg_out.c.