Lines Matching refs:pcb
103 struct udp_pcb *pcb; in udp_new_port() local
110 for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { in udp_new_port()
111 if (pcb->local_port == udp_port) { in udp_new_port()
130 udp_input_local_match(struct udp_pcb *pcb, struct netif *inp, u8_t broadcast) in udp_input_local_match() argument
135 LWIP_ASSERT("udp_input_local_match: invalid pcb", pcb != NULL); in udp_input_local_match()
139 if ((pcb->netif_idx != NETIF_NO_INDEX) && in udp_input_local_match()
140 (pcb->netif_idx != netif_get_index(ip_data.current_input_netif))) { in udp_input_local_match()
145 if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) { in udp_input_local_match()
147 if ((broadcast != 0) && !ip_get_option(pcb, SOF_BROADCAST)) { in udp_input_local_match()
155 if (IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ip_current_dest_addr())) { in udp_input_local_match()
161 if (ip_get_option(pcb, SOF_BROADCAST)) in udp_input_local_match()
164 if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) || in udp_input_local_match()
166 … ip4_addr_netcmp(ip_2_ip4(&pcb->local_ip), ip4_current_dest_addr(), netif_ip4_netmask(inp))) { in udp_input_local_match()
173 if (ip_addr_isany(&pcb->local_ip) || ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr())) { in udp_input_local_match()
197 struct udp_pcb *pcb, *prev; in udp_input() local
246 pcb = NULL; in udp_input()
253 for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { in udp_input()
256 ip_addr_debug_print_val(UDP_DEBUG, pcb->local_ip); in udp_input()
257 LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F") <-- (", pcb->local_port)); in udp_input()
258 ip_addr_debug_print_val(UDP_DEBUG, pcb->remote_ip); in udp_input()
259 LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F")\n", pcb->remote_port)); in udp_input()
262 if ((pcb->local_port == dest) && in udp_input()
263 (udp_input_local_match(pcb, inp, broadcast) != 0)) { in udp_input()
264 if ((pcb->flags & UDP_FLAGS_CONNECTED) == 0) { in udp_input()
267 uncon_pcb = pcb; in udp_input()
273 … if (IP_IS_V4_VAL(pcb->local_ip) && ip4_addr_cmp(ip_2_ip4(&pcb->local_ip), netif_ip4_addr(inp))) { in udp_input()
275 uncon_pcb = pcb; in udp_input()
281 else if (!ip_addr_isany(&pcb->local_ip)) { in udp_input()
283 uncon_pcb = pcb; in udp_input()
289 if ((pcb->remote_port == src) && in udp_input()
290 (ip_addr_isany_val(pcb->remote_ip) || in udp_input()
291 ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()))) { in udp_input()
296 prev->next = pcb->next; in udp_input()
297 pcb->next = udp_pcbs; in udp_input()
298 udp_pcbs = pcb; in udp_input()
306 prev = pcb; in udp_input()
309 if (pcb == NULL) { in udp_input()
310 pcb = uncon_pcb; in udp_input()
314 if (pcb != NULL) { in udp_input()
375 if (pcb != NULL) { in udp_input()
378 if (ip_get_option(pcb, SOF_REUSEADDR) && in udp_input()
384 if (mpcb != pcb) { in udp_input()
406 if (pcb->recv != NULL) { in udp_input()
408 pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr(), src); in udp_input()
471 udp_send(struct udp_pcb *pcb, struct pbuf *p) in udp_send() argument
473 LWIP_ERROR("udp_send: invalid pcb", pcb != NULL, return ERR_ARG); in udp_send()
476 if (IP_IS_ANY_TYPE_VAL(pcb->remote_ip)) { in udp_send()
481 return udp_sendto(pcb, p, &pcb->remote_ip, pcb->remote_port); in udp_send()
489 udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, in udp_send_chksum() argument
492 LWIP_ERROR("udp_send_chksum: invalid pcb", pcb != NULL, return ERR_ARG); in udp_send_chksum()
495 if (IP_IS_ANY_TYPE_VAL(pcb->remote_ip)) { in udp_send_chksum()
500 return udp_sendto_chksum(pcb, p, &pcb->remote_ip, pcb->remote_port, in udp_send_chksum()
524 udp_sendto(struct udp_pcb *pcb, struct pbuf *p, in udp_sendto() argument
528 return udp_sendto_chksum(pcb, p, dst_ip, dst_port, 0, 0); in udp_sendto()
534 udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, in udp_sendto_chksum() argument
540 LWIP_ERROR("udp_sendto: invalid pcb", pcb != NULL, return ERR_ARG); in udp_sendto_chksum()
544 if (!IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) { in udp_sendto_chksum()
550 if (pcb->netif_idx != NETIF_NO_INDEX) { in udp_sendto_chksum()
551 netif = netif_get_by_index(pcb->netif_idx); in udp_sendto_chksum()
562 if (pcb->mcast_ifindex != NETIF_NO_INDEX) { in udp_sendto_chksum()
563 netif = netif_get_by_index(pcb->mcast_ifindex); in udp_sendto_chksum()
576 if (!ip4_addr_isany_val(pcb->mcast_ip4) && in udp_sendto_chksum()
577 !ip4_addr_cmp(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) { in udp_sendto_chksum()
578 netif = ip4_route_src(ip_2_ip4(&pcb->local_ip), &pcb->mcast_ip4); in udp_sendto_chksum()
588 netif = ip_route(&pcb->local_ip, dst_ip); in udp_sendto_chksum()
601 return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum); in udp_sendto_chksum()
603 return udp_sendto_if(pcb, p, dst_ip, dst_port, netif); in udp_sendto_chksum()
628 udp_sendto_if(struct udp_pcb *pcb, struct pbuf *p, in udp_sendto_if() argument
632 return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, 0, 0); in udp_sendto_if()
637 udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, in udp_sendto_if_chksum() argument
644 LWIP_ERROR("udp_sendto_if: invalid pcb", pcb != NULL, return ERR_ARG); in udp_sendto_if_chksum()
649 if (!IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) { in udp_sendto_if_chksum()
656 if (ip6_addr_isany(ip_2_ip6(&pcb->local_ip)) || in udp_sendto_if_chksum()
657 ip6_addr_ismulticast(ip_2_ip6(&pcb->local_ip))) { in udp_sendto_if_chksum()
665 if (netif_get_ip6_addr_match(netif, ip_2_ip6(&pcb->local_ip)) < 0) { in udp_sendto_if_chksum()
669 src_ip = &pcb->local_ip; in udp_sendto_if_chksum()
677 if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) || in udp_sendto_if_chksum()
678 ip4_addr_ismulticast(ip_2_ip4(&pcb->local_ip))) { in udp_sendto_if_chksum()
685 if (!ip4_addr_cmp(ip_2_ip4(&(pcb->local_ip)), netif_ip4_addr(netif))) { in udp_sendto_if_chksum()
690 src_ip = &pcb->local_ip; in udp_sendto_if_chksum()
694 return udp_sendto_if_src_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum, src_ip); in udp_sendto_if_chksum()
696 return udp_sendto_if_src(pcb, p, dst_ip, dst_port, netif, src_ip); in udp_sendto_if_chksum()
703 udp_sendto_if_src(struct udp_pcb *pcb, struct pbuf *p, in udp_sendto_if_src() argument
707 return udp_sendto_if_src_chksum(pcb, p, dst_ip, dst_port, netif, 0, 0, src_ip); in udp_sendto_if_src()
712 udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, in udp_sendto_if_src_chksum() argument
725 LWIP_ERROR("udp_sendto_if_src: invalid pcb", pcb != NULL, return ERR_ARG); in udp_sendto_if_src_chksum()
731 if (!IP_ADDR_PCB_VERSION_MATCH(pcb, src_ip) || in udp_sendto_if_src_chksum()
732 !IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) { in udp_sendto_if_src_chksum()
738 if (!ip_get_option(pcb, SOF_BROADCAST) && in udp_sendto_if_src_chksum()
744 ("udp_sendto_if: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb)); in udp_sendto_if_src_chksum()
750 if (pcb->local_port == 0) { in udp_sendto_if_src_chksum()
752 err = udp_bind(pcb, &pcb->local_ip, pcb->local_port); in udp_sendto_if_src_chksum()
789 udphdr->src = lwip_htons(pcb->local_port); in udp_sendto_if_src_chksum()
796 if (((pcb->flags & UDP_FLAGS_MULTICAST_LOOP) != 0) && ip_addr_ismulticast(dst_ip)) { in udp_sendto_if_src_chksum()
805 if (pcb->flags & UDP_FLAGS_UDPLITE) { in udp_sendto_if_src_chksum()
809 chklen_hdr = chklen = pcb->chksum_len_tx; in udp_sendto_if_src_chksum()
859 if (IP_IS_V6(dst_ip) || (pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) { in udp_sendto_if_src_chksum()
888 ttl = (ip_addr_ismulticast(dst_ip) ? udp_get_multicast_ttl(pcb) : pcb->ttl); in udp_sendto_if_src_chksum()
890 ttl = pcb->ttl; in udp_sendto_if_src_chksum()
896 NETIF_SET_HINTS(netif, &(pcb->netif_hints)); in udp_sendto_if_src_chksum()
897 err = ip_output_if_src(q, src_ip, dst_ip, ttl, pcb->tos, ip_proto, netif); in udp_sendto_if_src_chksum()
936 udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) in udp_bind() argument
955 LWIP_ERROR("udp_bind: invalid pcb", pcb != NULL, return ERR_ARG); in udp_bind()
965 if (pcb == ipcb) { in udp_bind()
993 if (pcb != ipcb) { in udp_bind()
998 if (!ip_get_option(pcb, SOF_REUSEADDR) || in udp_bind()
1017 ip_addr_set_ipaddr(&pcb->local_ip, ipaddr); in udp_bind()
1019 pcb->local_port = port; in udp_bind()
1020 mib2_udp_bind(pcb); in udp_bind()
1024 pcb->next = udp_pcbs; in udp_bind()
1025 udp_pcbs = pcb; in udp_bind()
1028 ip_addr_debug_print_val(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, pcb->local_ip); in udp_bind()
1029 LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, (", port %"U16_F")\n", pcb->local_port)); in udp_bind()
1046 udp_bind_netif(struct udp_pcb *pcb, const struct netif *netif) in udp_bind_netif() argument
1051 pcb->netif_idx = netif_get_index(netif); in udp_bind_netif()
1053 pcb->netif_idx = NETIF_NO_INDEX; in udp_bind_netif()
1075 udp_connect(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port) in udp_connect() argument
1081 LWIP_ERROR("udp_connect: invalid pcb", pcb != NULL, return ERR_ARG); in udp_connect()
1084 if (pcb->local_port == 0) { in udp_connect()
1085 err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port); in udp_connect()
1091 ip_addr_set_ipaddr(&pcb->remote_ip, ipaddr); in udp_connect()
1095 if (IP_IS_V6(&pcb->remote_ip) && in udp_connect()
1096 ip6_addr_lacks_zone(ip_2_ip6(&pcb->remote_ip), IP6_UNKNOWN)) { in udp_connect()
1097 ip6_addr_select_zone(ip_2_ip6(&pcb->remote_ip), ip_2_ip6(&pcb->local_ip)); in udp_connect()
1101 pcb->remote_port = port; in udp_connect()
1102 pcb->flags |= UDP_FLAGS_CONNECTED; in udp_connect()
1106 pcb->remote_ip); in udp_connect()
1107 …LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, (", port %"U16_F")\n", pcb->remote_port)); in udp_connect()
1111 if (pcb == ipcb) { in udp_connect()
1117 pcb->next = udp_pcbs; in udp_connect()
1118 udp_pcbs = pcb; in udp_connect()
1130 udp_disconnect(struct udp_pcb *pcb) in udp_disconnect() argument
1134 LWIP_ERROR("udp_disconnect: invalid pcb", pcb != NULL, return); in udp_disconnect()
1138 if (IP_IS_ANY_TYPE_VAL(pcb->local_ip)) { in udp_disconnect()
1139 ip_addr_copy(pcb->remote_ip, *IP_ANY_TYPE); in udp_disconnect()
1142 ip_addr_set_any(IP_IS_V6_VAL(pcb->remote_ip), &pcb->remote_ip); in udp_disconnect()
1146 pcb->remote_port = 0; in udp_disconnect()
1147 pcb->netif_idx = NETIF_NO_INDEX; in udp_disconnect()
1149 udp_clear_flags(pcb, UDP_FLAGS_CONNECTED); in udp_disconnect()
1162 udp_recv(struct udp_pcb *pcb, udp_recv_fn recv, void *recv_arg) in udp_recv() argument
1166 LWIP_ERROR("udp_recv: invalid pcb", pcb != NULL, return); in udp_recv()
1169 pcb->recv = recv; in udp_recv()
1170 pcb->recv_arg = recv_arg; in udp_recv()
1183 udp_remove(struct udp_pcb *pcb) in udp_remove() argument
1189 LWIP_ERROR("udp_remove: invalid pcb", pcb != NULL, return); in udp_remove()
1191 mib2_udp_unbind(pcb); in udp_remove()
1193 if (udp_pcbs == pcb) { in udp_remove()
1200 if (pcb2->next != NULL && pcb2->next == pcb) { in udp_remove()
1202 pcb2->next = pcb->next; in udp_remove()
1207 memp_free(MEMP_UDP_PCB, pcb); in udp_remove()
1224 struct udp_pcb *pcb; in udp_new() local
1228 pcb = (struct udp_pcb *)memp_malloc(MEMP_UDP_PCB); in udp_new()
1230 if (pcb != NULL) { in udp_new()
1235 memset(pcb, 0, sizeof(struct udp_pcb)); in udp_new()
1236 pcb->ttl = UDP_TTL; in udp_new()
1238 udp_set_multicast_ttl(pcb, UDP_TTL); in udp_new()
1241 return pcb; in udp_new()
1261 struct udp_pcb *pcb; in udp_new_ip_type() local
1265 pcb = udp_new(); in udp_new_ip_type()
1267 if (pcb != NULL) { in udp_new_ip_type()
1268 IP_SET_TYPE_VAL(pcb->local_ip, type); in udp_new_ip_type()
1269 IP_SET_TYPE_VAL(pcb->remote_ip, type); in udp_new_ip_type()
1274 return pcb; in udp_new_ip_type()