mld6.c (62915) | mld6.c (78064) |
---|---|
1/* $KAME: mld6.c,v 1.11 2001/05/13 15:45:07 suz Exp $ */ 2/* $FreeBSD: head/usr.sbin/mld6query/mld6.c 78064 2001-06-11 12:39:29Z ume $ */ 3 |
|
1/* 2 * Copyright (C) 1998 WIDE Project. 3 * 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 --- 61 unchanged lines hidden (view full) --- 70 struct icmp6_filter filt; 71 u_int hlim = 1; 72 fd_set fdset; 73 struct itimerval itimer; 74 u_int type; 75 int ch; 76 77 type = MLD6_LISTENER_QUERY; | 4/* 5 * Copyright (C) 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright --- 61 unchanged lines hidden (view full) --- 73 struct icmp6_filter filt; 74 u_int hlim = 1; 75 fd_set fdset; 76 struct itimerval itimer; 77 u_int type; 78 int ch; 79 80 type = MLD6_LISTENER_QUERY; |
78 while ((ch = getopt(argc, argv, "d")) != EOF) { | 81 while ((ch = getopt(argc, argv, "dr")) != -1) { |
79 switch (ch) { 80 case 'd': 81 type = MLD6_LISTENER_DONE; 82 break; 83 case 'r': 84 type = MLD6_LISTENER_REPORT; 85 break; 86 default: --- 6 unchanged lines hidden (view full) --- 93 argc -= optind; 94 95 if (argc != 1 && argc != 2) 96 usage(); 97 98 ifindex = (u_short)if_nametoindex(argv[0]); 99 if (ifindex == 0) 100 usage(); | 82 switch (ch) { 83 case 'd': 84 type = MLD6_LISTENER_DONE; 85 break; 86 case 'r': 87 type = MLD6_LISTENER_REPORT; 88 break; 89 default: --- 6 unchanged lines hidden (view full) --- 96 argc -= optind; 97 98 if (argc != 1 && argc != 2) 99 usage(); 100 101 ifindex = (u_short)if_nametoindex(argv[0]); 102 if (ifindex == 0) 103 usage(); |
101 if (argc == 3 && inet_pton(AF_INET6, argv[1], &maddr) != 1) | 104 if (argc == 2 && inet_pton(AF_INET6, argv[1], &maddr) != 1) |
102 usage(); 103 104 if ((s = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) 105 err(1, "socket"); 106 107 if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hlim, 108 sizeof(hlim)) == -1) 109 err(1, "setsockopt(IPV6_MULTICAST_HOPS)"); --- 73 unchanged lines hidden (view full) --- 183 inet6_option_space(hbhlen); 184 185 if ((cmsgbuf = malloc(cmsglen)) == NULL) 186 errx(1, "can't allocate enough memory for cmsg"); 187 cmsgp = (struct cmsghdr *)cmsgbuf; 188 m.msg_control = (caddr_t)cmsgbuf; 189 m.msg_controllen = cmsglen; 190 /* specify the outgoing interface */ | 105 usage(); 106 107 if ((s = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) 108 err(1, "socket"); 109 110 if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hlim, 111 sizeof(hlim)) == -1) 112 err(1, "setsockopt(IPV6_MULTICAST_HOPS)"); --- 73 unchanged lines hidden (view full) --- 186 inet6_option_space(hbhlen); 187 188 if ((cmsgbuf = malloc(cmsglen)) == NULL) 189 errx(1, "can't allocate enough memory for cmsg"); 190 cmsgp = (struct cmsghdr *)cmsgbuf; 191 m.msg_control = (caddr_t)cmsgbuf; 192 m.msg_controllen = cmsglen; 193 /* specify the outgoing interface */ |
191 cmsgp->cmsg_len = CMSG_SPACE(sizeof(struct in6_pktinfo)); | 194 cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); |
192 cmsgp->cmsg_level = IPPROTO_IPV6; 193 cmsgp->cmsg_type = IPV6_PKTINFO; 194 pi = (struct in6_pktinfo *)CMSG_DATA(cmsgp); 195 pi->ipi6_ifindex = index; 196 memset(&pi->ipi6_addr, 0, sizeof(pi->ipi6_addr)); 197 /* specifiy to insert router alert option in a hop-by-hop opt hdr. */ 198 cmsgp = CMSG_NXTHDR(&m, cmsgp); 199 if (inet6_option_init((void *)cmsgp, &cmsgp, IPV6_HOPOPTS)) --- 68 unchanged lines hidden --- | 195 cmsgp->cmsg_level = IPPROTO_IPV6; 196 cmsgp->cmsg_type = IPV6_PKTINFO; 197 pi = (struct in6_pktinfo *)CMSG_DATA(cmsgp); 198 pi->ipi6_ifindex = index; 199 memset(&pi->ipi6_addr, 0, sizeof(pi->ipi6_addr)); 200 /* specifiy to insert router alert option in a hop-by-hop opt hdr. */ 201 cmsgp = CMSG_NXTHDR(&m, cmsgp); 202 if (inet6_option_init((void *)cmsgp, &cmsgp, IPV6_HOPOPTS)) --- 68 unchanged lines hidden --- |