Microchip® Advanced Software Framework

tinyservices.c File Reference

Tiny DNS Server.

Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.

#include "conf_tinyservices.h"
#include "tinyservices.h"
#include "wifi_private.h"
#include <string.h>

Functions

uint32_t pbuf_read16be (struct pbuf *pbuf, uint32_t offset, uint16_t *pval)
 Read two bytes (big-endian) from a pbuf. More...
 
uint32_t pbuf_read32le (struct pbuf *pbuf, uint32_t offset, uint32_t *pval)
 Read four bytes (little-endian) from a pbuf. More...
 
uint32_t pbuf_read8 (struct pbuf *pbuf, uint32_t offset, uint8_t *pval)
 Read a byte from a pbuf. More...
 
err_t pbuf_take_partial (struct pbuf *pbuf, uint32_t offset, const void *dataptr, u16_t len)
 Copy application supplied data into a pbuf. More...
 
uint32_t pbuf_write16be (struct pbuf *pbuf, uint32_t offset, uint16_t val)
 Write two bytes (big-endian) to a pbuf. More...
 
uint32_t pbuf_write32be (struct pbuf *pbuf, uint32_t offset, uint32_t val)
 Write four bytes (big-endian) to a pbuf. More...
 
uint32_t pbuf_write32le (struct pbuf *pbuf, uint32_t offset, uint32_t val)
 Write four bytes (little-endian) to a pbuf. More...
 
uint32_t pbuf_write8 (struct pbuf *pbuf, uint32_t offset, uint8_t val)
 Write a byte to a pbuf. More...
 

uint32_t pbuf_read16be ( struct pbuf pbuf,
uint32_t  offset,
uint16_t *  pval 
)

Read two bytes (big-endian) from a pbuf.

If the read is beyond the end of the pbuf chain's payload, then return an error instead.

Parameters
bufpbuf to read data from.
offsetlogical offset into pbuf to start reading from
pvalmemory to place the read bytes into.
Returns
0 if successful, 1 if the read offset is beyond the end of the pbuf chain's total length.

References _wifi_get16_be(), pbuf_copy_partial(), and pbuf::tot_len.

uint32_t pbuf_read32le ( struct pbuf pbuf,
uint32_t  offset,
uint32_t *  pval 
)

Read four bytes (little-endian) from a pbuf.

If the requested read is beyond the * end of the pbuf chain's payload, then this function does not perform the read. It returns an error instead.

Parameters
bufpbuf to read data from.
offsetlogical offset into pbuf to start reading from.
valthe data to read from the pbuf.
Returns
0 if successful, 1 if the read offset is beyond the end of the pbuf chain's total length.

References _wifi_get32_le(), pbuf_copy_partial(), and pbuf::tot_len.

Referenced by pbuf_read_ip().

uint32_t pbuf_read8 ( struct pbuf pbuf,
uint32_t  offset,
uint8_t *  pval 
)

Read a byte from a pbuf.

If the read is beyond the end of the pbuf chain's payload, then return an error instead.

Parameters
bufpbuf to read data from.
offsetlogical offset into pbuf to start reading from
pvalmemory to place the read byte into.
Returns
0 if successful, 1 if the read offset is beyond the end of the pbuf chain's total length.

References pbuf_get_at(), and pbuf::tot_len.

err_t pbuf_take_partial ( struct pbuf pbuf,
uint32_t  offset,
const void *  dataptr,
u16_t  len 
)

Copy application supplied data into a pbuf.

This function can only be used to copy the equivalent of buf->tot_len data.

Parameters
bufpbuf to fill with data
offsetlogical offset into pbuf to start writing data into
dataptrapplication supplied data buffer
lenlength of the application supplied data buffer
Returns
ERR_OK if successful, ERR_MEM if the pbuf is not big enough

References Assert, ERR_ARG, ERR_OK, pbuf::len, pbuf::next, NULL, and pbuf::payload.

Referenced by pbuf_write16be(), pbuf_write32be(), pbuf_write32le(), and pbuf_write8().

uint32_t pbuf_write16be ( struct pbuf pbuf,
uint32_t  offset,
uint16_t  val 
)

Write two bytes (big-endian) to a pbuf.

If the requested write is beyond the * end of the pbuf chain's payload, then this function does not perform the write. It returns an error instead.

Parameters
bufpbuf to write data to.
offsetlogical offset into pbuf to start writing to.
valthe data to write to the pbuf.
Returns
0 if successful, 1 if the write offset is beyond the end of the pbuf chain's total length.

References _wifi_put16_be(), ERR_OK, pbuf_take_partial(), and pbuf::tot_len.

uint32_t pbuf_write32be ( struct pbuf pbuf,
uint32_t  offset,
uint32_t  val 
)

Write four bytes (big-endian) to a pbuf.

If the requested write is beyond the * end of the pbuf chain's payload, then this function does not perform the write. It returns an error instead.

Parameters
bufpbuf to write data to.
offsetlogical offset into pbuf to start writing to.
valthe data to write to the pbuf.
Returns
0 if successful, 1 if the write offset is beyond the end of the pbuf chain's total length.

References _wifi_put32_be(), ERR_OK, pbuf_take_partial(), and pbuf::tot_len.

uint32_t pbuf_write32le ( struct pbuf pbuf,
uint32_t  offset,
uint32_t  val 
)

Write four bytes (little-endian) to a pbuf.

If the requested write is beyond the * end of the pbuf chain's payload, then this function does not perform the write. It returns an error instead.

Parameters
bufpbuf to write data to.
offsetlogical offset into pbuf to start writing to.
valthe data to write to the pbuf.
Returns
0 if successful, 1 if the write offset is beyond the end of the pbuf chain's total length.

References _wifi_put32_le(), ERR_OK, pbuf_take_partial(), and pbuf::tot_len.

Referenced by pbuf_write_ip().

uint32_t pbuf_write8 ( struct pbuf pbuf,
uint32_t  offset,
uint8_t  val 
)

Write a byte to a pbuf.

If the requested write is beyond the end of the pbuf chain's payload, then this function does not perform the write. It returns an error instead.

Parameters
bufpbuf to write data to.
offsetlogical offset into pbuf to start writing to.
valthe data to write to the pbuf.
Returns
0 if successful, 1 if the write offset is beyond the end of the pbuf chain's total length.

References ERR_OK, pbuf_take_partial(), and pbuf::tot_len.