+in_setsockaddr(inp, nam)
+ register struct inpcb *inp;
+ struct mbuf *nam;
+{
+ register struct sockaddr_in *sin;
+
+ nam->m_len = sizeof (*sin);
+ sin = mtod(nam, struct sockaddr_in *);
+ bzero((caddr_t)sin, sizeof (*sin));
+ sin->sin_family = AF_INET;
+ sin->sin_port = inp->inp_lport;
+ sin->sin_addr = inp->inp_laddr;
+}
+
+in_setpeeraddr(inp, nam)
+ struct inpcb *inp;
+ struct mbuf *nam;
+{
+ register struct sockaddr_in *sin;
+
+ nam->m_len = sizeof (*sin);
+ sin = mtod(nam, struct sockaddr_in *);
+ bzero((caddr_t)sin, sizeof (*sin));
+ sin->sin_family = AF_INET;
+ sin->sin_port = inp->inp_fport;
+ sin->sin_addr = inp->inp_faddr;
+}
+
+/*
+ * Pass some notification to all connections of a protocol
+ * associated with address dst. Call the protocol specific
+ * routine (if any) to handle each connection.
+ */
+in_pcbnotify(head, dst, errno, notify)
+ struct inpcb *head;
+ register struct in_addr *dst;
+ int errno, (*notify)();
+{
+ register struct inpcb *inp, *oinp;
+ int s = splimp();
+
+ for (inp = head->inp_next; inp != head;) {
+ if (inp->inp_faddr.s_addr != dst->s_addr ||
+ inp->inp_socket == 0) {
+ inp = inp->inp_next;
+ continue;
+ }
+ if (errno)
+ inp->inp_socket->so_error = errno;
+ oinp = inp;
+ inp = inp->inp_next;
+ if (notify)
+ (*notify)(oinp);
+ }
+ splx(s);
+}
+
+/*
+ * Check for alternatives when higher level complains
+ * about service problems. For now, invalidate cached
+ * routing information. If the route was created dynamically
+ * (by a redirect), time to try a default gateway again.
+ */
+in_losing(inp)
+ struct inpcb *inp;
+{
+ register struct rtentry *rt;
+
+ if ((rt = inp->inp_route.ro_rt)) {
+ if (rt->rt_flags & RTF_DYNAMIC)
+ (void) rtrequest((int)SIOCDELRT, rt);
+ rtfree(rt);
+ inp->inp_route.ro_rt = 0;
+ /*
+ * A new route can be allocated
+ * the next time output is attempted.
+ */
+ }
+}
+
+/*
+ * After a routing change, flush old routing
+ * and allocate a (hopefully) better one.
+ */
+in_rtchange(inp)
+ register struct inpcb *inp;
+{
+ if (inp->inp_route.ro_rt) {
+ rtfree(inp->inp_route.ro_rt);
+ inp->inp_route.ro_rt = 0;
+ /*
+ * A new route can be allocated the next time
+ * output is attempted.
+ */
+ }
+}
+