- if (addr) {
- if (rp->rcb_flags & RAW_FADDR)
- return (EISCONN);
- raw_connaddr(rp, (struct sockaddr *)addr);
- } else if ((rp->rcb_flags & RAW_FADDR) == 0)
- return (ENOTCONN);
+ if (nam) {
+ if (rp->rcb_flags & RAW_FADDR) {
+ error = EISCONN;
+ break;
+ }
+ raw_connaddr(rp, nam);
+ } else if ((rp->rcb_flags & RAW_FADDR) == 0) {
+ error = ENOTCONN;
+ break;
+ }
+ /*
+ * Check for routing. If new foreign address, or
+ * no route presently in use, try to allocate new
+ * route. On failure, just hand packet to output
+ * routine anyway in case it can handle it.
+ */
+ if ((rp->rcb_flags & RAW_DONTROUTE) == 0)
+ if (!equal(rp->rcb_faddr, rp->rcb_route.ro_dst) ||
+ rp->rcb_route.ro_rt == 0) {
+ if (rp->rcb_route.ro_rt)
+ rtfree(rp->rcb_route.ro_rt);
+ rp->rcb_route.ro_dst = rp->rcb_faddr;
+ rtalloc(&rp->rcb_route);
+ }