Deleted Added
full compact
rdisc.c (20339) rdisc.c (20606)
1/*
2 * Copyright (c) 1995
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

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

31 * SUCH DAMAGE.
32 */
33
34#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
35static char sccsid[] = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
36#elif defined(__NetBSD__)
37static char rcsid[] = "$NetBSD$";
38#endif
1/*
2 * Copyright (c) 1995
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

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

31 * SUCH DAMAGE.
32 */
33
34#if !defined(lint) && !defined(sgi) && !defined(__NetBSD__)
35static char sccsid[] = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
36#elif defined(__NetBSD__)
37static char rcsid[] = "$NetBSD$";
38#endif
39#ident "$Revision: 1.19 $"
39#ident "$Revision: 1.20 $"
40
41#include "defs.h"
42#include <netinet/in_systm.h>
43#include <netinet/ip.h>
44#include <netinet/ip_icmp.h>
45
46/* router advertisement ICMP packet */
47struct icmp_ad {

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

911
912
913/* read packets from the router discovery socket
914 */
915void
916read_d(void)
917{
918 static struct msg_limit bad_asize, bad_len;
40
41#include "defs.h"
42#include <netinet/in_systm.h>
43#include <netinet/ip.h>
44#include <netinet/ip_icmp.h>
45
46/* router advertisement ICMP packet */
47struct icmp_ad {

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

911
912
913/* read packets from the router discovery socket
914 */
915void
916read_d(void)
917{
918 static struct msg_limit bad_asize, bad_len;
919#ifdef USE_PASSIFNAME
920 static struct msg_limit bad_name;
921#endif
919 struct sockaddr_in from;
920 int n, fromlen, cc, hlen;
921 struct {
922 struct sockaddr_in from;
923 int n, fromlen, cc, hlen;
924 struct {
922#undef USE_PASSIFNAME /* it is too bad it does not work on raw sockets */
923#ifdef USE_PASSIFNAME
924 char ifname[IFNAMSIZ];
925#endif
926 union {
927 struct ip ip;
928 u_short s[512/2];
929 u_char b[512];
930 } pkt;

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

956 hlen = buf.pkt.ip.ip_hl << 2;
957 if (cc < hlen + ICMP_MINLEN)
958 continue;
959 p = (union ad_u *)&buf.pkt.b[hlen];
960 cc -= hlen;
961
962#ifdef USE_PASSIFNAME
963 ifp = ifwithname(buf.ifname, 0);
925#ifdef USE_PASSIFNAME
926 char ifname[IFNAMSIZ];
927#endif
928 union {
929 struct ip ip;
930 u_short s[512/2];
931 u_char b[512];
932 } pkt;

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

958 hlen = buf.pkt.ip.ip_hl << 2;
959 if (cc < hlen + ICMP_MINLEN)
960 continue;
961 p = (union ad_u *)&buf.pkt.b[hlen];
962 cc -= hlen;
963
964#ifdef USE_PASSIFNAME
965 ifp = ifwithname(buf.ifname, 0);
964 if (ifp == 0) {
965 /* maybe it is a new interface */
966 ifinit();
967 ifp = ifwithname(buf.ifname, 0);
968 if (ifp == 0) {
969 msglim(&bad_name, from.sin_addr.s_addr,
970 "impossible rdisc if_ name %.*s",
971 IFNAMSIZ, buf.ifname);
972 }
973 }
966 if (ifp == 0)
967 msglim(&bad_name, from.sin_addr.s_addr,
968 "impossible rdisc if_ name %.*s",
969 IFNAMSIZ, buf.ifname);
974#else
975 /* If we could tell the interface on which a packet from
976 * address 0 arrived, we could deal with such solicitations.
977 */
978 ifp = ((from.sin_addr.s_addr == 0)
979 ? 0 : iflookup(from.sin_addr.s_addr));
980#endif
970#else
971 /* If we could tell the interface on which a packet from
972 * address 0 arrived, we could deal with such solicitations.
973 */
974 ifp = ((from.sin_addr.s_addr == 0)
975 ? 0 : iflookup(from.sin_addr.s_addr));
976#endif
981 ifp = ck_icmp("Recv",
982 from.sin_addr.s_addr, ifp,
983 buf.pkt.ip.ip_dst.s_addr,
984 p, cc);
977 ifp = ck_icmp("Recv", from.sin_addr.s_addr, ifp,
978 buf.pkt.ip.ip_dst.s_addr, p, cc);
985 if (ifp == 0)
986 continue;
987 if (ifwithaddr(from.sin_addr.s_addr, 0, 0)) {
979 if (ifp == 0)
980 continue;
981 if (ifwithaddr(from.sin_addr.s_addr, 0, 0)) {
988 trace_pkt(" discard our own Router Discovery"
989 " message");
982 trace_pkt(" "
983 "discard our own Router Discovery message");
990 continue;
991 }
992
993 switch (p->icmp.icmp_type) {
994 case ICMP_ROUTERADVERT:
995 if (p->ad.icmp_ad_asize*4
996 < sizeof(p->ad.icmp_ad_info[0])) {
997 msglim(&bad_asize, from.sin_addr.s_addr,

--- 50 unchanged lines hidden ---
984 continue;
985 }
986
987 switch (p->icmp.icmp_type) {
988 case ICMP_ROUTERADVERT:
989 if (p->ad.icmp_ad_asize*4
990 < sizeof(p->ad.icmp_ad_info[0])) {
991 msglim(&bad_asize, from.sin_addr.s_addr,

--- 50 unchanged lines hidden ---