aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/d6_packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/d6_packet.c')
-rw-r--r--networking/udhcp/d6_packet.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c
index 167a813e3..172f8e1ab 100644
--- a/networking/udhcp/d6_packet.c
+++ b/networking/udhcp/d6_packet.c
@@ -6,6 +6,7 @@
6 */ 6 */
7#include "common.h" 7#include "common.h"
8#include "d6_common.h" 8#include "d6_common.h"
9#include "dhcpc.h"
9#include "dhcpd.h" 10#include "dhcpd.h"
10#include <netinet/in.h> 11#include <netinet/in.h>
11#include <netinet/if_ether.h> 12#include <netinet/if_ether.h>
@@ -50,11 +51,10 @@ int FAST_FUNC d6_recv_kernel_packet(struct in6_addr *peer_ipv6
50} 51}
51 52
52/* Construct a ipv6+udp header for a packet, send packet */ 53/* Construct a ipv6+udp header for a packet, send packet */
53int FAST_FUNC d6_send_raw_packet( 54int FAST_FUNC d6_send_raw_packet_from_client_data_ifindex(
54 struct d6_packet *d6_pkt, unsigned d6_pkt_size, 55 struct d6_packet *d6_pkt, unsigned d6_pkt_size,
55 struct in6_addr *src_ipv6, int source_port, 56 struct in6_addr *src_ipv6, int source_port,
56 struct in6_addr *dst_ipv6, int dest_port, const uint8_t *dest_arp, 57 struct in6_addr *dst_ipv6, int dest_port, const uint8_t *dest_arp)
57 int ifindex)
58{ 58{
59 struct sockaddr_ll dest_sll; 59 struct sockaddr_ll dest_sll;
60 struct ip6_udp_d6_packet packet; 60 struct ip6_udp_d6_packet packet;
@@ -74,7 +74,7 @@ int FAST_FUNC d6_send_raw_packet(
74 74
75 dest_sll.sll_family = AF_PACKET; 75 dest_sll.sll_family = AF_PACKET;
76 dest_sll.sll_protocol = htons(ETH_P_IPV6); 76 dest_sll.sll_protocol = htons(ETH_P_IPV6);
77 dest_sll.sll_ifindex = ifindex; 77 dest_sll.sll_ifindex = client_data.ifindex;
78 /*dest_sll.sll_hatype = ARPHRD_???;*/ 78 /*dest_sll.sll_hatype = ARPHRD_???;*/
79 /*dest_sll.sll_pkttype = PACKET_???;*/ 79 /*dest_sll.sll_pkttype = PACKET_???;*/
80 dest_sll.sll_halen = 6; 80 dest_sll.sll_halen = 6;
@@ -103,8 +103,8 @@ int FAST_FUNC d6_send_raw_packet(
103 */ 103 */
104 packet.ip6.ip6_hlim = IPPROTO_UDP; 104 packet.ip6.ip6_hlim = IPPROTO_UDP;
105 packet.udp.check = inet_cksum( 105 packet.udp.check = inet_cksum(
106 (uint8_t *)&packet + 4, 106 (uint8_t *)&packet + 4,
107 offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size 107 offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size
108 ); 108 );
109 /* fix 'hop limit' and 'next header' after UDP checksumming */ 109 /* fix 'hop limit' and 'next header' after UDP checksumming */
110 packet.ip6.ip6_hlim = 1; /* observed Windows machines to use hlim=1 */ 110 packet.ip6.ip6_hlim = 1; /* observed Windows machines to use hlim=1 */
@@ -126,11 +126,10 @@ int FAST_FUNC d6_send_raw_packet(
126} 126}
127 127
128/* Let the kernel do all the work for packet generation */ 128/* Let the kernel do all the work for packet generation */
129int FAST_FUNC d6_send_kernel_packet( 129int FAST_FUNC d6_send_kernel_packet_from_client_data_ifindex(
130 struct d6_packet *d6_pkt, unsigned d6_pkt_size, 130 struct d6_packet *d6_pkt, unsigned d6_pkt_size,
131 struct in6_addr *src_ipv6, int source_port, 131 struct in6_addr *src_ipv6, int source_port,
132 struct in6_addr *dst_ipv6, int dest_port, 132 struct in6_addr *dst_ipv6, int dest_port)
133 int ifindex)
134{ 133{
135 struct sockaddr_in6 sa; 134 struct sockaddr_in6 sa;
136 int fd; 135 int fd;
@@ -157,7 +156,7 @@ int FAST_FUNC d6_send_kernel_packet(
157 sa.sin6_family = AF_INET6; 156 sa.sin6_family = AF_INET6;
158 sa.sin6_port = htons(dest_port); 157 sa.sin6_port = htons(dest_port);
159 sa.sin6_addr = *dst_ipv6; /* struct copy */ 158 sa.sin6_addr = *dst_ipv6; /* struct copy */
160 sa.sin6_scope_id = ifindex; 159 sa.sin6_scope_id = client_data.ifindex;
161 if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) { 160 if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
162 msg = "connect"; 161 msg = "connect";
163 goto ret_close; 162 goto ret_close;