/* Get one byte from the specified position in a pbuf WARNING: returns zero for offset >= p->tot_len */
u8_t pbuf_get_at(struct pbuf *p, u16_t offset)
/* Get one byte from the specified position in a pbuf WARNING: returns zero for offset >= p->tot_len */
u8_t pbuf_get_at(struct pbuf *p, u16_t offset)
{
  u16_t copy_from = offset;
  struct pbuf* q = p;
  while ((q != NULL) && (q->len <= copy_from)) {
    copy_from -= q->len;
    q = q->next;
  }
  if ((q != NULL) && (q->len > copy_from)) {
    return ((u8_t*)q->payload)[copy_from];
  }
  return 0;
}