- Main Page
- Data Structures
- Files
- Directories

- Search for |

- File List
- Globals

# api.h File Reference

`#include "net/opt.h"`
`#include "net/pbuf.h"`
`#include "net/sys.h"`
`#include "net/ipv4/ip.h"`
`#include "net/udp.h"`
`#include "net/tcp.h"`
`#include "net/err.h"`

Go to the source code of this file.

## Data Structures
struct | netbuf
struct | netconn
## Defines
#define | NETCONN_COPY 0x01
#define | NETCONN_NOCOPY 0x00
## Enumerations
enum | netconn_state { NETCONN_NONE, NETCONN_WRITE, NETCONN_ACCEPT, NETCONN_RECV, NETCONN_CONNECT, NETCONN_CLOSE }
enum | netconn_type { NETCONN_TCP, NETCONN_UDP, NETCONN_UDPLITE, NETCONN_UDPNOCHKSUM }
## Functions
void * | netbuf_alloc (struct netbuf *buf, uInt16 size)
void | netbuf_chain (struct netbuf *head, struct netbuf *tail)
void | netbuf_copy (struct netbuf *buf, void *dataptr, uInt16 len)
void | netbuf_copy_partial (struct netbuf *buf, void *dataptr, uInt16 len, uInt16 offset)
err_t | netbuf_data (struct netbuf *buf, void **dataptr, uInt16 *len)
void | netbuf_delete (struct netbuf *buf)
void | netbuf_first (struct netbuf *buf)
void | netbuf_free (struct netbuf *buf)
ip_addr * | netbuf_fromaddr (struct netbuf *buf)
uInt16 | netbuf_fromport (struct netbuf *buf)
uInt16 | netbuf_len (struct netbuf *buf)
netbuf * | netbuf_new (void)
Int8 | netbuf_next (struct netbuf *buf)
void | netbuf_ref (struct netbuf *buf, void *dataptr, uInt16 size)
netconn * | netconn_accept (struct netconn *conn)
err_t | netconn_addr (struct netconn *conn, struct ip_addr **addr, uInt16 *port)
err_t | netconn_bind (struct netconn *conn, struct ip_addr *addr, uInt16 port)
err_t | netconn_close (struct netconn *conn)
err_t | netconn_connect (struct netconn *conn, struct ip_addr *addr, uInt16 port)
err_t | netconn_delete (struct netconn *conn)
err_t | netconn_err (struct netconn *conn)
err_t | netconn_listen (struct netconn *conn)
netconn * | netconn_new (enum netconn_type type)
err_t | netconn_peer (struct netconn *conn, struct ip_addr **addr, uInt16 *port)
netbuf * | netconn_recv (struct netconn *conn)
err_t | netconn_send (struct netconn *conn, struct netbuf *buf)
enum netconn_type | netconn_type (struct netconn *conn)
err_t | netconn_write (struct netconn *conn, void *dataptr, uInt16 size, uInt8 copy)

## Define Documentation

#define NETCONN_COPY 0x01

Definition at line 50 of file api.h.

Referenced by lwip_send(), and lwip_write().

#define NETCONN_NOCOPY 0x00

Definition at line 49 of file api.h.

Referenced by sendstr().

## Enumeration Type Documentation

enum netconn_state

Enumerator:

  NETCONN_NONE |
  NETCONN_WRITE |
  NETCONN_ACCEPT |
  NETCONN_RECV |
  NETCONN_CONNECT |
  NETCONN_CLOSE |

Definition at line 59 of file api.h.

enum netconn_type

Enumerator:

  NETCONN_TCP |
  NETCONN_UDP |
  NETCONN_UDPLITE |
  NETCONN_UDPNOCHKSUM |

Definition at line 52 of file api.h.

## Function Documentation

void* netbuf_alloc | ( | struct netbuf * | buf,
|  | uInt16 | size |
| ) |  |  |

Definition at line 78 of file api_lib.c.

References NULL, netbuf::p, pbuf::payload, pbuf_alloc(), pbuf_free(), PBUF_RAM, PBUF_TRANSPORT, and netbuf::ptr.

void netbuf_chain | ( | struct netbuf * | head,
|  | struct netbuf * | tail |
| ) |  |  |

Definition at line 114 of file api_lib.c.

References memp_freep(), MEMP_NETBUF, netbuf::p, pbuf_chain(), and netbuf::ptr.

void netbuf_copy | ( | struct netbuf * | buf,
|  | void * | dataptr,
|  | uInt16 | len |
| ) |  |  |

Definition at line 186 of file api_lib.c.

References netbuf_copy_partial().

Referenced by bot_thread(), shell_main(), and udpecho_thread().

void netbuf_copy_partial | ( | struct netbuf * | buf,
|  | void * | dataptr,
|  | uInt16 | len,
|  | uInt16 | offset |
| ) |  |  |

Definition at line 158 of file api_lib.c.

References pbuf::len, pbuf::next, NULL, netbuf::p, and pbuf::payload.

Referenced by lwip_recvfrom(), and netbuf_copy().

err_t netbuf_data | ( | struct netbuf * | buf,
|  | void ** | dataptr,
|  | uInt16 * | len |
| ) |  |  |

Definition at line 128 of file api_lib.c.

References ERR_BUF, ERR_OK, pbuf::len, NULL, pbuf::payload, and netbuf::ptr.

void netbuf_delete | ( | struct netbuf * | buf | ) |

Definition at line 66 of file api_lib.c.

References memp_freep(), MEMP_NETBUF, NULL, netbuf::p, pbuf_free(), and netbuf::ptr.

Referenced by bot_thread(), lwip_close(), lwip_recvfrom(), lwip_send(), netconn_delete(), shell_main(), and udpecho_thread().

void netbuf_first | ( | struct netbuf * | buf | ) |

Definition at line 152 of file api_lib.c.

References netbuf::p, and netbuf::ptr.

void netbuf_free | ( | struct netbuf * | buf | ) |

Definition at line 93 of file api_lib.c.

References NULL, netbuf::p, pbuf_free(), and netbuf::ptr.

struct ip_addr* netbuf_fromaddr | ( | struct netbuf * | buf | ) |

Definition at line 192 of file api_lib.c.

References netbuf::fromaddr.

Referenced by lwip_recvfrom(), and udpecho_thread().

uInt16 netbuf_fromport | ( | struct netbuf * | buf | ) |

Definition at line 198 of file api_lib.c.

References netbuf::fromport.

Referenced by lwip_recvfrom(), and udpecho_thread().

uInt16 netbuf_len | ( | struct netbuf * | buf | ) |

Definition at line 122 of file api_lib.c.

References netbuf::p, and pbuf::tot_len.

Referenced by bot_thread(), lwip_recvfrom(), and shell_main().

struct netbuf* netbuf_new | ( | void |  | ) |

Definition at line 51 of file api_lib.c.

References memp_mallocp(), MEMP_NETBUF, NULL, netbuf::p, and netbuf::ptr.

Referenced by lwip_send().

Int8 netbuf_next | ( | struct netbuf * | buf | ) |

Definition at line 139 of file api_lib.c.

References pbuf::next, NULL, and netbuf::ptr.

void netbuf_ref | ( | struct netbuf * | buf,
|  | void * | dataptr,
|  | uInt16 | size |
| ) |  |  |

Definition at line 102 of file api_lib.c.

References pbuf::len, NULL, netbuf::p, pbuf::payload, pbuf_alloc(), pbuf_free(), PBUF_ROM, PBUF_TRANSPORT, netbuf::ptr, and pbuf::tot_len.

Referenced by lwip_send().

struct netconn* netconn_accept | ( | struct netconn * | conn | ) |

Definition at line 416 of file api_lib.c.

References netconn::acceptmbox, NULL, and sys_mbox_fetch().

Referenced by lwip_accept(), and shell_thread().

err_t netconn_addr | ( | struct netconn * | conn,
|  | struct ip_addr ** | addr,
|  | uInt16 * | port |
| ) |  |  |

Definition at line 306 of file api_lib.c.

References netconn::err, ERR_OK, tcp_pcb::local_ip, udp_pcb::local_port, tcp_pcb::local_port, NETCONN_TCP, NETCONN_UDP, NETCONN_UDPLITE, NETCONN_UDPNOCHKSUM, netconn::pcb, netconn::tcp, netconn::type, and netconn::udp.

err_t netconn_bind | ( | struct netconn * | conn,
|  | struct ip_addr * | addr,
|  | uInt16 | port |
| ) |  |  |

Definition at line 325 of file api_lib.c.

References API_MSG_BIND, api_msg_post(), api_msg_msg::bc, api_msg_msg::conn, netconn::err, ERR_MEM, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), api_msg::msg, api_msg_msg::msg, NETCONN_TCP, NULL, netconn::recvmbox, sys_mbox_fetch(), sys_mbox_new(), SYS_MBOX_NULL, and netconn::type.

Referenced by lwip_bind(), shell_thread(), and udpecho_thread().

err_t netconn_close | ( | struct netconn * | conn | ) |

Definition at line 612 of file api_lib.c.

References API_MSG_CLOSE, api_msg_post(), api_msg_msg::conn, netconn::err, ERR_MEM, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), api_msg::msg, api_msg_msg::msg, NETCONN_CLOSE, NETCONN_NONE, NULL, netconn::sem, netconn::state, sys_mbox_fetch(), SYS_SEM_NULL, and sys_sem_wait().

Referenced by shell_main().

err_t netconn_connect | ( | struct netconn * | conn,
|  | struct ip_addr * | addr,
|  | uInt16 | port |
| ) |  |  |

Definition at line 355 of file api_lib.c.

References API_MSG_CONNECT, api_msg_post(), api_msg_msg::bc, api_msg_msg::conn, netconn::err, ERR_MEM, ERR_VAL, kprintf(), netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), api_msg::msg, api_msg_msg::msg, NULL, netconn::recvmbox, sys_mbox_fetch(), sys_mbox_new(), and SYS_MBOX_NULL.

Referenced by bot_thread(), lwip_connect(), lwip_sendto(), and udpecho_thread().

err_t netconn_delete | ( | struct netconn * | conn | ) |

Definition at line 227 of file api_lib.c.

References netconn::acceptmbox, API_MSG_DELCONN, api_msg_post(), api_msg_msg::conn, ERR_MEM, ERR_OK, netconn::mbox, MEMP_API_MSG, memp_free(), memp_freep(), memp_mallocp(), MEMP_NETCONN, api_msg::msg, api_msg_msg::msg, netbuf_delete(), netconn_delete(), NETCONN_TCP, NULL, pbuf_free(), netconn::recvmbox, netconn::sem, sys_arch_mbox_fetch(), sys_mbox_fetch(), sys_mbox_free(), SYS_MBOX_NULL, sys_sem_free(), SYS_SEM_NULL, and netconn::type.

Referenced by lwip_accept(), lwip_close(), lwip_socket(), and netconn_delete().

err_t netconn_err | ( | struct netconn * | conn | ) |

Definition at line 640 of file api_lib.c.

References netconn::err.

err_t netconn_listen | ( | struct netconn * | conn | ) |

Definition at line 389 of file api_lib.c.

References netconn::acceptmbox, API_MSG_LISTEN, api_msg_post(), api_msg_msg::conn, netconn::err, ERR_MEM, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), api_msg::msg, api_msg_msg::msg, NULL, sys_mbox_fetch(), sys_mbox_new(), and SYS_MBOX_NULL.

Referenced by lwip_listen(), and shell_thread().

struct netconn* netconn_new | ( | enum netconn_type | type | ) |

Definition at line 204 of file api_lib.c.

References netconn::acceptmbox, netconn::mbox, memp_freep(), memp_mallocp(), MEMP_NETCONN, NETCONN_NONE, NULL, netconn::pcb, netconn::recvmbox, netconn::sem, netconn::state, sys_mbox_new(), SYS_MBOX_NULL, SYS_SEM_NULL, netconn::tcp, and netconn::type.

Referenced by bot_thread(), lwip_socket(), shell_thread(), and udpecho_thread().

err_t netconn_peer | ( | struct netconn * | conn,
|  | struct ip_addr ** | addr,
|  | uInt16 * | port |
| ) |  |  |

Definition at line 287 of file api_lib.c.

References netconn::err, ERR_OK, NETCONN_TCP, NETCONN_UDP, NETCONN_UDPLITE, NETCONN_UDPNOCHKSUM, netconn::pcb, udp_pcb::remote_ip, tcp_pcb::remote_ip, udp_pcb::remote_port, tcp_pcb::remote_port, netconn::tcp, netconn::type, and netconn::udp.

Referenced by lwip_accept(), and lwip_sendto().

struct netbuf* netconn_recv | ( | struct netconn * | conn | ) |

Definition at line 430 of file api_lib.c.

References API_LIB_DEBUG, api_msg_post(), API_MSG_RECV, api_msg_msg::conn, DEBUGF, netconn::err, ERR_CONN, ERR_MEM, ERR_OK, netbuf::fromaddr, netbuf::fromport, api_msg_msg::len, LISTEN, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), MEMP_NETBUF, api_msg::msg, api_msg_msg::msg, NETCONN_TCP, NULL, netbuf::p, netconn::pcb, netbuf::ptr, netconn::recvmbox, tcp_pcb::state, sys_mbox_fetch(), sys_mbox_free(), SYS_MBOX_NULL, netconn::tcp, pbuf::tot_len, netconn::type, and api_msg::type.

Referenced by bot_thread(), lwip_recvfrom(), shell_main(), and udpecho_thread().

err_t netconn_send | ( | struct netconn * | conn,
|  | struct netbuf * | buf |
| ) |  |  |

Definition at line 509 of file api_lib.c.

References API_LIB_DEBUG, api_msg_post(), API_MSG_SEND, api_msg_msg::conn, DEBUGF, netconn::err, ERR_MEM, ERR_OK, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), api_msg::msg, api_msg_msg::msg, NULL, netbuf::p, api_msg_msg::p, sys_mbox_fetch(), and pbuf::tot_len.

Referenced by lwip_send(), and udpecho_thread().

enum netconn_type netconn_type | ( | struct netconn * | conn | ) |

Definition at line 281 of file api_lib.c.

References netconn::type.

Referenced by lwip_recvfrom(), lwip_send(), and lwip_write().

err_t netconn_write | ( | struct netconn * | conn,
|  | void * | dataptr,
|  | uInt16 | size,
|  | uInt8 | copy |
| ) |  |  |

Definition at line 537 of file api_lib.c.

References API_LIB_DEBUG, api_msg_post(), API_MSG_WRITE, api_msg_msg::conn, DEBUGF, netconn::err, ERR_MEM, ERR_OK, ERR_VAL, netconn::mbox, MEMP_API_MSG, memp_freep(), memp_mallocp(), api_msg::msg, api_msg_msg::msg, NETCONN_NONE, NETCONN_TCP, NETCONN_WRITE, NULL, netconn::pcb, netconn::sem, netconn::state, sys_mbox_fetch(), sys_sem_free(), sys_sem_new(), SYS_SEM_NULL, sys_sem_wait(), netconn::tcp, tcp_sndbuf, netconn::type, and api_msg_msg::w.

Referenced by lwip_send(), lwip_write(), and sendstr().