Lines Matching defs:packet
33 #include "packet.h"
175 /* send a packet to giaddr using the kernel ip stack */
178 DEBUG(LOG_INFO, "Forwarding packet to relay");
185 /* send a packet to a specific arp address and ip address by creating our own ip packet */
192 DEBUG(LOG_INFO, "broadcasting packet to client (NAK)");
196 DEBUG(LOG_INFO, "unicasting packet to client ciaddr");
200 DEBUG(LOG_INFO, "broadcasting packet to client (requested)");
204 DEBUG(LOG_INFO, "unicasting packet to client yiaddr");
213 /* send a dhcp packet, if force broadcast is set, the packet will be broadcast to the client */
225 static void init_packet(struct dhcpMessage *packet, struct dhcpMessage *oldpacket, char type)
227 init_header(packet, type);
228 packet->xid = oldpacket->xid;
229 memcpy(packet->chaddr, oldpacket->chaddr, 16);
230 packet->flags = oldpacket->flags;
231 packet->giaddr = oldpacket->giaddr;
232 packet->ciaddr = oldpacket->ciaddr;
233 add_simple_option(packet->options, DHCP_SERVER_ID, server_config.server);
238 static void add_bootp_options(struct dhcpMessage *packet)
240 packet->siaddr = server_config.siaddr;
242 strncpy(packet->sname, server_config.sname, sizeof(packet->sname) - 1);
244 strncpy(packet->file, server_config.boot_file, sizeof(packet->file) - 1);
251 struct dhcpMessage packet;
262 init_packet(&packet, oldpacket, DHCPOFFER);
273 packet.yiaddr = lease->yiaddr;
277 packet.yiaddr = htonl(reserved_ip);
302 packet.yiaddr = req_align;
306 packet.yiaddr = find_address2(0, mac);
309 if (!packet.yiaddr) packet.yiaddr = find_address2(1, mac);
312 if(!packet.yiaddr) {
317 if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time)) {
352 add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align));
357 add_option_string(packet.options, curr->data);
361 add_bootp_options(&packet);
363 addr.s_addr = packet.yiaddr;
365 return send_packet(&packet, 0);
371 struct dhcpMessage packet;
373 init_packet(&packet, oldpacket, DHCPNAK);
376 return send_packet(&packet, 1);
382 struct dhcpMessage packet;
395 init_packet(&packet, oldpacket, DHCPACK);
396 packet.yiaddr = yiaddr;
409 if (is_guest_network(packet.chaddr)) {
421 if (is_arlo_network(packet.chaddr)) {
422 arlo_addr.s_addr=packet.yiaddr;
426 (unsigned char)packet.chaddr[0],
427 (unsigned char)packet.chaddr[1],
428 (unsigned char)packet.chaddr[2],
429 (unsigned char)packet.chaddr[3],
430 (unsigned char)packet.chaddr[4],
431 (unsigned char)packet.chaddr[5]);
452 memcpy(arlo_mac, packet.chaddr,6);
467 add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align));
472 add_option_string(packet.options, curr->data);
476 add_bootp_options(&packet);
478 addr.s_addr = packet.yiaddr;
481 if (send_packet(&packet, 0) < 0)
484 add_lease(packet.chaddr, packet.yiaddr, lease_time_align);
486 client_mac = (unsigned char *)packet.chaddr;
487 client_ip = (unsigned char *)&packet.yiaddr;
504 struct dhcpMessage packet;
507 init_packet(&packet, oldpacket, DHCPACK);
512 add_option_string(packet.options, curr->data);
516 add_bootp_options(&packet);
518 return send_packet(&packet, 0);