Lines Matching defs:pcb
69 raw_input_local_match(struct raw_pcb *pcb, u8_t broadcast)
74 if ((pcb->netif_idx != NETIF_NO_INDEX) &&
75 (pcb->netif_idx != netif_get_index(ip_data.current_input_netif))) {
81 if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) {
83 if ((broadcast != 0) && !ip_get_option(pcb, SOF_BROADCAST)) {
92 if (IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ip_current_dest_addr())) {
98 if (ip_get_option(pcb, SOF_BROADCAST))
101 if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip))) {
108 if (ip_addr_isany(&pcb->local_ip) ||
109 ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr())) {
137 struct raw_pcb *pcb, *prev;
166 pcb = raw_pcbs;
169 while (pcb != NULL) {
171 if (inp_net_group == get_net_group_from_raw_pcb(pcb) &&
172 (pcb->protocol == proto) && raw_input_local_match(pcb, broadcast) &&
174 if ((pcb->protocol == proto) && raw_input_local_match(pcb, broadcast) &&
176 (((pcb->flags & RAW_FLAGS_CONNECTED) == 0) ||
177 ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()))) {
179 if (pcb->recv != NULL) {
186 eaten = pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr());
191 /* move the pcb to the front of raw_pcbs so that is
193 prev->next = pcb->next;
194 pcb->next = raw_pcbs;
195 raw_pcbs = pcb;
200 LWIP_ASSERT("raw pcb recv callback altered pbuf payload pointer without eating packet",
207 prev = pcb;
208 pcb = pcb->next;
217 * @param pcb RAW PCB to be bound with a local address ipaddr.
229 raw_bind(struct raw_pcb *pcb, const ip_addr_t *ipaddr)
232 if ((pcb == NULL) || (ipaddr == NULL)) {
235 ip_addr_set_ipaddr(&pcb->local_ip, ipaddr);
240 if (IP_IS_V6(&pcb->local_ip) &&
241 ip6_addr_lacks_zone(ip_2_ip6(&pcb->local_ip), IP6_UNKNOWN)) {
242 ip6_addr_select_zone(ip_2_ip6(&pcb->local_ip), ip_2_ip6(&pcb->local_ip));
255 * @param pcb RAW PCB to be bound with netif.
261 raw_bind_netif(struct raw_pcb *pcb, const struct netif *netif)
265 pcb->netif_idx = netif_get_index(netif);
267 pcb->netif_idx = NETIF_NO_INDEX;
278 * @param pcb RAW PCB to be connected with remote address ipaddr and port.
286 raw_connect(struct raw_pcb *pcb, const ip_addr_t *ipaddr)
289 if ((pcb == NULL) || (ipaddr == NULL)) {
292 ip_addr_set_ipaddr(&pcb->remote_ip, ipaddr);
296 if (IP_IS_V6(&pcb->remote_ip) &&
297 ip6_addr_lacks_zone(ip_2_ip6(&pcb->remote_ip), IP6_UNKNOWN)) {
298 ip6_addr_select_zone(ip_2_ip6(&pcb->remote_ip), ip_2_ip6(&pcb->local_ip));
301 raw_set_flags(pcb, RAW_FLAGS_CONNECTED);
309 * @param pcb the raw pcb to disconnect.
312 raw_disconnect(struct raw_pcb *pcb)
317 if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) {
318 ip_addr_copy(pcb->remote_ip, *IP_ANY_TYPE);
321 ip_addr_set_any(IP_IS_V6_VAL(pcb->remote_ip), &pcb->remote_ip);
325 pcb->netif_idx = NETIF_NO_INDEX;
327 raw_clear_flags(pcb, RAW_FLAGS_CONNECTED);
342 raw_recv(struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg)
346 pcb->recv = recv;
347 pcb->recv_arg = recv_arg;
356 * @param pcb the raw pcb which to send
362 raw_sendto(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr)
367 if ((pcb == NULL) || (ipaddr == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr)) {
374 struct net_group *group = get_net_group_from_raw_pcb(pcb);
376 if (pcb->netif_idx != NETIF_NO_INDEX) {
378 netif = netif_get_by_index(pcb->netif_idx, group);
380 netif = netif_get_by_index(pcb->netif_idx);
390 netif = netif_get_by_index(pcb->mcast_ifindex, group);
392 netif = netif_get_by_index(pcb->mcast_ifindex);
400 netif = ip_route(&pcb->local_ip, ipaddr, group);
402 netif = ip_route(&pcb->local_ip, ipaddr);
413 if (ip_addr_isany(&pcb->local_ip) || ip_addr_ismulticast(&pcb->local_ip)) {
423 src_ip = &pcb->local_ip;
426 return raw_sendto_if_src(pcb, p, ipaddr, netif, src_ip);
436 * @param pcb RAW PCB used to send the data
443 raw_sendto_if_src(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
453 if ((pcb == NULL) || (dst_ip == NULL) || (netif == NULL) || (src_ip == NULL) ||
454 !IP_ADDR_PCB_VERSION_MATCH(pcb, src_ip) || !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
469 if (pcb->flags & RAW_FLAGS_HDRINCL) {
476 NETIF_SET_HINTS(netif, &pcb->netif_hints);
513 if (!ip_get_option(pcb, SOF_BROADCAST) && ip_addr_isbroadcast(dst_ip, netif)) {
514 LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb));
526 if (((pcb->flags & RAW_FLAGS_MULTICAST_LOOP) != 0) && ip_addr_ismulticast(dst_ip)) {
534 if (IP_IS_V6(dst_ip) && pcb->chksum_reqd) {
535 u16_t chksum = ip6_chksum_pseudo(p, pcb->protocol, p->tot_len, ip_2_ip6(src_ip), ip_2_ip6(dst_ip));
536 LWIP_ASSERT("Checksum must fit into first pbuf", p->len >= (pcb->chksum_offset + 2));
537 SMEMCPY(((u8_t *)p->payload) + pcb->chksum_offset, &chksum, sizeof(u16_t));
543 ttl = (ip_addr_ismulticast(dst_ip) ? raw_get_multicast_ttl(pcb) : pcb->ttl);
545 ttl = pcb->ttl;
548 NETIF_SET_HINTS(netif, &pcb->netif_hints);
549 err = ip_output_if(q, src_ip, dst_ip, ttl, pcb->tos, pcb->protocol, netif);
564 * @param pcb the raw pcb which to send
569 raw_send(struct raw_pcb *pcb, struct pbuf *p)
571 return raw_sendto(pcb, p, &pcb->remote_ip);
578 * @param pcb RAW PCB to be removed. The PCB is removed from the list of
584 raw_remove(struct raw_pcb *pcb)
588 /* pcb to be removed is first in list? */
589 if (raw_pcbs == pcb) {
590 /* make list start at 2nd pcb */
592 /* pcb not 1st in list */
595 /* find pcb in raw_pcbs list */
596 if (pcb2->next != NULL && pcb2->next == pcb) {
597 /* remove pcb from list */
598 pcb2->next = pcb->next;
603 memp_free(MEMP_RAW_PCB, pcb);
607 void set_raw_pcb_net_group(struct raw_pcb *pcb, struct net_group *group)
609 set_ippcb_net_group((struct ip_pcb *)pcb, group);
612 struct net_group *get_net_group_from_raw_pcb(struct raw_pcb *pcb) {
613 return get_net_group_from_ippcb((struct ip_pcb *)pcb);
630 struct raw_pcb *pcb;
635 pcb = (struct raw_pcb *)memp_malloc(MEMP_RAW_PCB);
637 if (pcb != NULL) {
639 memset(pcb, 0, sizeof(struct raw_pcb));
640 pcb->protocol = proto;
641 pcb->ttl = RAW_TTL;
643 raw_set_multicast_ttl(pcb, RAW_TTL);
645 pcb->next = raw_pcbs;
646 raw_pcbs = pcb;
648 return pcb;
669 struct raw_pcb *pcb;
671 pcb = raw_new(proto);
673 if (pcb != NULL) {
674 IP_SET_TYPE_VAL(pcb->local_ip, type);
675 IP_SET_TYPE_VAL(pcb->remote_ip, type);
680 return pcb;