84 static struct raw_pcb *raw_pcbs;
87 raw_input_match(
struct raw_pcb *pcb, u8_t broadcast)
91 #if LWIP_IPV4 && LWIP_IPV6 93 if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) {
94 #if IP_SOF_BROADCAST_RECV 108 if (broadcast != 0) {
109 #if IP_SOF_BROADCAST_RECV 113 if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip))) {
120 if (ip_addr_isany(&pcb->local_ip) ||
147 raw_input(
struct pbuf *p,
struct netif *inp)
149 struct raw_pcb *pcb, *prev;
162 proto = IP6H_NEXTH(ip6hdr);
178 while ((eaten == 0) && (pcb != NULL)) {
179 if ((pcb->protocol == proto) && raw_input_match(pcb, broadcast)) {
181 if (pcb->recv != NULL) {
182 #ifndef LWIP_NOASSERT 183 void* old_payload = p->
payload;
194 prev->next = pcb->next;
195 pcb->next = raw_pcbs;
200 LWIP_ASSERT(
"raw pcb recv callback altered pbuf payload pointer without eating packet",
229 raw_bind(
struct raw_pcb *pcb,
const ip_addr_t *ipaddr)
231 if ((pcb == NULL) || (ipaddr == NULL)) {
234 ip_addr_set_ipaddr(&pcb->local_ip, ipaddr);
253 raw_connect(
struct raw_pcb *pcb,
const ip_addr_t *ipaddr)
255 if ((pcb == NULL) || (ipaddr == NULL)) {
258 ip_addr_set_ipaddr(&pcb->remote_ip, ipaddr);
274 raw_recv(
struct raw_pcb *pcb, raw_recv_fn recv,
void *recv_arg)
278 pcb->recv_arg = recv_arg;
295 raw_sendto(
struct raw_pcb *pcb,
struct pbuf *p,
const ip_addr_t *ipaddr)
299 const ip_addr_t *src_ip;
303 if ((pcb == NULL) || (ipaddr == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr)) {
310 #if LWIP_IPV4 && LWIP_IPV6 311 IP_IS_V6(ipaddr) ? IP6_HLEN : IP_HLEN);
332 LWIP_DEBUGF(
RAW_DEBUG, (
"raw_sendto: added header pbuf %p before given pbuf %p\n", (
void *)q, (
void *)p));
337 LWIP_ASSERT(
"Can't restore header we just removed!", 0);
342 if(IP_IS_ANY_TYPE_VAL(pcb->local_ip)) {
344 netif = ip_route(IP46_ADDR_ANY(IP_GET_TYPE(ipaddr)), ipaddr);
346 netif = ip_route(&pcb->local_ip, ipaddr);
360 if (IP_IS_V4(ipaddr))
363 if (!
ip_get_option(pcb, SOF_BROADCAST) && ip_addr_isbroadcast(ipaddr, netif)) {
374 if (ip_addr_isany(&pcb->local_ip)) {
376 src_ip = ip_netif_get_local_ip(netif, ipaddr);
378 if (src_ip == NULL) {
387 src_ip = &pcb->local_ip;
393 if (IP_IS_V6(ipaddr) && pcb->chksum_reqd) {
394 u16_t chksum = ip6_chksum_pseudo(p, pcb->protocol, p->
tot_len, ip_2_ip6(src_ip), ip_2_ip6(ipaddr));
395 LWIP_ASSERT(
"Checksum must fit into first pbuf", p->
len >= (pcb->chksum_offset + 2));
396 SMEMCPY(((u8_t *)p->
payload) + pcb->chksum_offset, &chksum,
sizeof(u16_t));
400 NETIF_SET_HWADDRHINT(netif, &pcb->addr_hint);
401 err = ip_output_if(q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif);
402 NETIF_SET_HWADDRHINT(netif, NULL);
421 raw_send(
struct raw_pcb *pcb,
struct pbuf *p)
423 return raw_sendto(pcb, p, &pcb->remote_ip);
436 raw_remove(
struct raw_pcb *pcb)
438 struct raw_pcb *pcb2;
440 if (raw_pcbs == pcb) {
442 raw_pcbs = raw_pcbs->next;
445 for (pcb2 = raw_pcbs; pcb2 != NULL; pcb2 = pcb2->next) {
447 if (pcb2->next != NULL && pcb2->next == pcb) {
449 pcb2->next = pcb->next;
479 memset(pcb, 0,
sizeof(
struct raw_pcb));
480 pcb->protocol = proto;
482 pcb->next = raw_pcbs;
504 raw_new_ip_type(u8_t type, u8_t proto)
507 pcb = raw_new(proto);
508 #if LWIP_IPV4 && LWIP_IPV6 510 IP_SET_TYPE_VAL(pcb->local_ip, type);
511 IP_SET_TYPE_VAL(pcb->remote_ip, type);
524 void raw_netif_ip_addr_changed(
const ip_addr_t* old_addr,
const ip_addr_t* new_addr)
526 struct raw_pcb* rpcb;
528 if (!ip_addr_isany(old_addr) && !ip_addr_isany(new_addr)) {
529 for (rpcb = raw_pcbs; rpcb != NULL; rpcb = rpcb->next) {
531 if (ip_addr_cmp(&rpcb->local_ip, old_addr)) {
534 ip_addr_copy(rpcb->local_ip, *new_addr);
#define ip_current_src_addr()
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
#define ip_current_netif()
void memp_free(memp_t type, void *mem)
#define ip_current_dest_addr()
#define LWIP_DBG_LEVEL_SERIOUS
void pbuf_chain(struct pbuf *h, struct pbuf *t)
#define LWIP_DEBUGF(debug, message)
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
#define LWIP_DBG_LEVEL_WARNING
#define LWIP_UNUSED_ARG(x)
u8_t pbuf_free(struct pbuf *p)
void * memp_malloc(memp_t type)
#define ip_get_option(pcb, opt)
#define IP_HDR_GET_VERSION(ptr)