Deleted Added
full compact
in_pcb.c (1542) in_pcb.c (1549)
1/*
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 148 unchanged lines hidden (view full) ---

157 * then pick one.
158 */
159int
160in_pcbconnect(inp, nam)
161 register struct inpcb *inp;
162 struct mbuf *nam;
163{
164 struct in_ifaddr *ia;
1/*
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 148 unchanged lines hidden (view full) ---

157 * then pick one.
158 */
159int
160in_pcbconnect(inp, nam)
161 register struct inpcb *inp;
162 struct mbuf *nam;
163{
164 struct in_ifaddr *ia;
165 struct sockaddr_in *ifaddr;
165 struct sockaddr_in *ifaddr = 0;
166 register struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
167
168 if (nam->m_len != sizeof (*sin))
169 return (EINVAL);
170 if (sin->sin_family != AF_INET)
171 return (EAFNOSUPPORT);
172 if (sin->sin_port == 0)
173 return (EADDRNOTAVAIL);

--- 95 unchanged lines hidden (view full) ---

269 (void)in_pcbbind(inp, (struct mbuf *)0);
270 inp->inp_laddr = ifaddr->sin_addr;
271 }
272 inp->inp_faddr = sin->sin_addr;
273 inp->inp_fport = sin->sin_port;
274 return (0);
275}
276
166 register struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
167
168 if (nam->m_len != sizeof (*sin))
169 return (EINVAL);
170 if (sin->sin_family != AF_INET)
171 return (EAFNOSUPPORT);
172 if (sin->sin_port == 0)
173 return (EADDRNOTAVAIL);

--- 95 unchanged lines hidden (view full) ---

269 (void)in_pcbbind(inp, (struct mbuf *)0);
270 inp->inp_laddr = ifaddr->sin_addr;
271 }
272 inp->inp_faddr = sin->sin_addr;
273 inp->inp_fport = sin->sin_port;
274 return (0);
275}
276
277int
277void
278in_pcbdisconnect(inp)
279 struct inpcb *inp;
280{
281
282 inp->inp_faddr.s_addr = INADDR_ANY;
283 inp->inp_fport = 0;
284 if (inp->inp_socket->so_state & SS_NOFDREF)
285 in_pcbdetach(inp);
286}
287
278in_pcbdisconnect(inp)
279 struct inpcb *inp;
280{
281
282 inp->inp_faddr.s_addr = INADDR_ANY;
283 inp->inp_fport = 0;
284 if (inp->inp_socket->so_state & SS_NOFDREF)
285 in_pcbdetach(inp);
286}
287
288int
288void
289in_pcbdetach(inp)
290 struct inpcb *inp;
291{
292 struct socket *so = inp->inp_socket;
293
294 so->so_pcb = 0;
295 sofree(so);
296 if (inp->inp_options)
297 (void)m_free(inp->inp_options);
298 if (inp->inp_route.ro_rt)
299 rtfree(inp->inp_route.ro_rt);
300 ip_freemoptions(inp->inp_moptions);
301 remque(inp);
302 FREE(inp, M_PCB);
303}
304
289in_pcbdetach(inp)
290 struct inpcb *inp;
291{
292 struct socket *so = inp->inp_socket;
293
294 so->so_pcb = 0;
295 sofree(so);
296 if (inp->inp_options)
297 (void)m_free(inp->inp_options);
298 if (inp->inp_route.ro_rt)
299 rtfree(inp->inp_route.ro_rt);
300 ip_freemoptions(inp->inp_moptions);
301 remque(inp);
302 FREE(inp, M_PCB);
303}
304
305int
305void
306in_setsockaddr(inp, nam)
307 register struct inpcb *inp;
308 struct mbuf *nam;
309{
310 register struct sockaddr_in *sin;
311
312 nam->m_len = sizeof (*sin);
313 sin = mtod(nam, struct sockaddr_in *);
314 bzero((caddr_t)sin, sizeof (*sin));
315 sin->sin_family = AF_INET;
316 sin->sin_len = sizeof(*sin);
317 sin->sin_port = inp->inp_lport;
318 sin->sin_addr = inp->inp_laddr;
319}
320
306in_setsockaddr(inp, nam)
307 register struct inpcb *inp;
308 struct mbuf *nam;
309{
310 register struct sockaddr_in *sin;
311
312 nam->m_len = sizeof (*sin);
313 sin = mtod(nam, struct sockaddr_in *);
314 bzero((caddr_t)sin, sizeof (*sin));
315 sin->sin_family = AF_INET;
316 sin->sin_len = sizeof(*sin);
317 sin->sin_port = inp->inp_lport;
318 sin->sin_addr = inp->inp_laddr;
319}
320
321int
321void
322in_setpeeraddr(inp, nam)
323 struct inpcb *inp;
324 struct mbuf *nam;
325{
326 register struct sockaddr_in *sin;
327
328 nam->m_len = sizeof (*sin);
329 sin = mtod(nam, struct sockaddr_in *);

--- 10 unchanged lines hidden (view full) ---

340 * may be specified to limit the search. The "usual action" will be
341 * taken, depending on the ctlinput cmd. The caller must filter any
342 * cmds that are uninteresting (e.g., no error in the map).
343 * Call the protocol specific routine (if any) to report
344 * any errors for each matching socket.
345 *
346 * Must be called at splnet.
347 */
322in_setpeeraddr(inp, nam)
323 struct inpcb *inp;
324 struct mbuf *nam;
325{
326 register struct sockaddr_in *sin;
327
328 nam->m_len = sizeof (*sin);
329 sin = mtod(nam, struct sockaddr_in *);

--- 10 unchanged lines hidden (view full) ---

340 * may be specified to limit the search. The "usual action" will be
341 * taken, depending on the ctlinput cmd. The caller must filter any
342 * cmds that are uninteresting (e.g., no error in the map).
343 * Call the protocol specific routine (if any) to report
344 * any errors for each matching socket.
345 *
346 * Must be called at splnet.
347 */
348int
348void
349in_pcbnotify(head, dst, fport_arg, laddr, lport_arg, cmd, notify)
350 struct inpcb *head;
351 struct sockaddr *dst;
352 u_int fport_arg, lport_arg;
353 struct in_addr laddr;
354 int cmd;
355 void (*notify) __P((struct inpcb *, int));
356{

--- 41 unchanged lines hidden (view full) ---

398}
399
400/*
401 * Check for alternatives when higher level complains
402 * about service problems. For now, invalidate cached
403 * routing information. If the route was created dynamically
404 * (by a redirect), time to try a default gateway again.
405 */
349in_pcbnotify(head, dst, fport_arg, laddr, lport_arg, cmd, notify)
350 struct inpcb *head;
351 struct sockaddr *dst;
352 u_int fport_arg, lport_arg;
353 struct in_addr laddr;
354 int cmd;
355 void (*notify) __P((struct inpcb *, int));
356{

--- 41 unchanged lines hidden (view full) ---

398}
399
400/*
401 * Check for alternatives when higher level complains
402 * about service problems. For now, invalidate cached
403 * routing information. If the route was created dynamically
404 * (by a redirect), time to try a default gateway again.
405 */
406int
406void
407in_losing(inp)
408 struct inpcb *inp;
409{
410 register struct rtentry *rt;
411 struct rt_addrinfo info;
412
413 if ((rt = inp->inp_route.ro_rt)) {
414 inp->inp_route.ro_rt = 0;

--- 83 unchanged lines hidden ---
407in_losing(inp)
408 struct inpcb *inp;
409{
410 register struct rtentry *rt;
411 struct rt_addrinfo info;
412
413 if ((rt = inp->inp_route.ro_rt)) {
414 inp->inp_route.ro_rt = 0;

--- 83 unchanged lines hidden ---