/* * Send request on all interfaces for information from other routers * at startup time. */ void send_request(void) { struct interface *ifp; struct msghdr *mh; struct rip6 *pkt; struct route_entry *rp; struct sockaddr_in6 sdst; int n; if (snd_data == NULL) return; pkt = (struct rip6 *)snd_data; bzero((void *)pkt, sizeof(struct rip6)); pkt->rip6_cmd = RIP6_REQUEST; pkt->rip6_ver = RIP6_VERSION; rp = pkt->rip6_rte; rp->rip6_metric = HOPCOUNT_INFINITY; mh = &smsgh; /* used in send_request/send_update */ (void)inet_pton(AF_INET6, ALL_RIP6_ROUTER, (void *)&sdst.sin6_addr); mh->msg_name = (char *)&(sdst); sdst.sin6_len = mh->msg_namelen = sizeof(struct sockaddr_in6); mh->msg_iov = &siov; mh->msg_iovlen = 1; siov.iov_base = snd_data; siov.iov_len = sizeof(struct rip6); sdst.sin6_family = AF_INET6; sdst.sin6_port = htons(RIP6_PORT); sdst.sin6_flowinfo = 0; for (ifp = ifnet; ifp; ifp = ifp->if_next) { if ((ifp->if_flag & IFF_UP) == 0 || (ifp->if_flag & IFF_LOOPBACK) || (ifp->if_flag & IFF_RUNNING) == 0) continue; if (ifp->if_config->int_inpass == CTL_NOLISTEN && ifp->if_config->int_ctlin == NULL) continue; mh->msg_control = (char *)&(ifp->if_cinfo); mh->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)); if (rt6_trace) trace_packet("Tx", ifp, mh, 1, 0); if ((n = sendmsg(rip6_sock, mh, 0)) < 0) syslog(LOG_ERR, "send_request: send_request: UDP socket: %m"); } return; }
void Raytracer::trace_packet_worker(tsqueue<PacketRegion> *packet_queue, unsigned char *buffer) { while (true) { bool empty; PacketRegion packet = packet_queue->Pop(empty); if (empty) { break; } trace_packet(packet, 1.0, buffer); } }
/* * Writes the message on to UDP socket to appropriate destinations. */ void send_message(struct msghdr *mh, struct interface *ifp, unsigned int force) { int n, nentries, flag; struct control *ctlp; flag = 0; nentries = (mh->msg_iov->iov_len - sizeof(struct rip6)) / sizeof(struct route_entry) + 1; if (mh->msg_name != NULL) { /* should respond by unicast */ struct in6_pktinfo *pf; /* query(all), query(n), startup-query(all) */ /* send back to the sender of request directly */ /* Its src addr is response's dst addr */ /* mh->msg_name = mh->msg_name; */ pf = (struct in6_pktinfo *)CMSG_DATA(CMSG_FIRSTHDR(mh)); if (IN6_IS_ADDR_MULTICAST(&pf->ipi6_addr)) { if (ifp->if_lladdr) pf->ipi6_addr = ifp->if_lladdr->pl_pref.prf_addr; else return; /* cannot send without linklocal */ } if (rt6_trace) trace_packet("Tx", ifp, mh, nentries, 0); if ((n = sendmsg(rip6_sock, mh, 0)) != mh->msg_iov->iov_len) syslog(LOG_ERR, "send_message: UDP socket: %m"); return; } if (!(ifp->if_flag & IFF_RUNNING)) return; /* doesn't have any linklocal */ mh->msg_control = (void *)&(ifp->if_cinfo); mh->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)); /* SPECIAL CASE */ /* AGGREGATE overrides NOOUT */ if (force) { struct sockaddr_in6 tmp6; bzero((void *)&tmp6, sizeof(tmp6)); tmp6.sin6_port = htons(RIP6_PORT); tmp6.sin6_len = sizeof(tmp6); tmp6.sin6_family = AF_INET6; tmp6.sin6_flowinfo = 0; (void)inet_pton(AF_INET6, ALL_RIP6_ROUTER, &tmp6.sin6_addr); mh->msg_name = (char *)&tmp6; mh->msg_namelen = sizeof(tmp6); if (rt6_trace) trace_packet("Tx", ifp, mh, (nentries + 1), 0); if ((n = sendmsg(rip6_sock, mh, MSG_DONTROUTE)) != mh->msg_iov->iov_len) syslog(LOG_ERR, "send_message: UDP socket: %m"); ifp->if_updates++; return; } /* * Loop through all the destinations listed in out list with * CTL_SEND of this interface and send a copy to them each. * Note: there should be a CTL_SEND to FF02::9 entry in * default. */ for (ctlp = ifp->if_config->int_ctlout; ctlp; ctlp = ctlp->ctl_next) { if (ctlp->ctl_pass == CTL_NOSEND) continue; mh->msg_name = (char *)&(ctlp->ctl_addr); mh->msg_namelen = sizeof(struct sockaddr_in6); if (rt6_trace) trace_packet("Tx", ifp, mh, (nentries + 1), 0); n = sendmsg(rip6_sock, mh, MSG_DONTROUTE); if (n != mh->msg_iov->iov_len) syslog(LOG_ERR, "send_message: UDP socket: %m"); ifp->if_updates++; } return; }