Lines Matching refs:packet
16 void FAST_FUNC udhcp_init_header(struct dhcp_packet *packet, char type) in udhcp_init_header() argument
18 memset(packet, 0, sizeof(*packet)); in udhcp_init_header()
19 packet->op = BOOTREQUEST; /* if client to a server */ in udhcp_init_header()
24 packet->op = BOOTREPLY; /* if server to client */ in udhcp_init_header()
26 packet->htype = 1; /* ethernet */ in udhcp_init_header()
27 packet->hlen = 6; in udhcp_init_header()
28 packet->cookie = htonl(DHCP_MAGIC); in udhcp_init_header()
30 packet->options[0] = DHCP_END; in udhcp_init_header()
31 udhcp_add_simple_option(packet, DHCP_MESSAGE_TYPE, type); in udhcp_init_header()
36 void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet) in udhcp_dump_packet() argument
38 char buf[sizeof(packet->chaddr)*2 + 1]; in udhcp_dump_packet()
61 , packet->hlen in udhcp_dump_packet()
63 , packet->xid in udhcp_dump_packet()
66 , packet->ciaddr in udhcp_dump_packet()
67 , packet->yiaddr in udhcp_dump_packet()
68 , packet->siaddr_nip in udhcp_dump_packet()
69 , packet->gateway_nip in udhcp_dump_packet()
75 *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; in udhcp_dump_packet()
81 int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd) in udhcp_recv_kernel_packet() argument
85 memset(packet, 0, sizeof(*packet)); in udhcp_recv_kernel_packet()
86 bytes = safe_read(fd, packet, sizeof(*packet)); in udhcp_recv_kernel_packet()
93 || packet->cookie != htonl(DHCP_MAGIC) in udhcp_recv_kernel_packet()
100 udhcp_dump_packet(packet); in udhcp_recv_kernel_packet()
112 struct ip_udp_dhcp_packet packet; in udhcp_send_raw_packet() local
125 memset(&packet, 0, offsetof(struct ip_udp_dhcp_packet, data)); in udhcp_send_raw_packet()
126 packet.data = *dhcp_pkt; /* struct copy */ in udhcp_send_raw_packet()
155 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(packet.data.options); in udhcp_send_raw_packet()
159 packet.ip.protocol = IPPROTO_UDP; in udhcp_send_raw_packet()
160 packet.ip.saddr = source_nip; in udhcp_send_raw_packet()
161 packet.ip.daddr = dest_nip; in udhcp_send_raw_packet()
162 packet.udp.source = htons(source_port); in udhcp_send_raw_packet()
163 packet.udp.dest = htons(dest_port); in udhcp_send_raw_packet()
165 packet.udp.len = htons(UDP_DHCP_SIZE - padding); in udhcp_send_raw_packet()
167 packet.ip.tot_len = packet.udp.len; in udhcp_send_raw_packet()
168 packet.udp.check = inet_cksum(&packet, in udhcp_send_raw_packet()
171 packet.ip.tot_len = htons(IP_UDP_DHCP_SIZE - padding); in udhcp_send_raw_packet()
172 packet.ip.ihl = sizeof(packet.ip) >> 2; in udhcp_send_raw_packet()
173 packet.ip.version = IPVERSION; in udhcp_send_raw_packet()
174 packet.ip.ttl = IPDEFTTL; in udhcp_send_raw_packet()
175 packet.ip.check = inet_cksum(&packet.ip, sizeof(packet.ip)); in udhcp_send_raw_packet()
178 result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0, in udhcp_send_raw_packet()