• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/udhcpd/

Lines Matching defs:packet

8 #include <netpacket/packet.h>

17 #include "packet.h"
23 void init_header(struct dhcpMessage *packet, char type)
25 memset(packet, 0, sizeof(struct dhcpMessage));
32 packet->op = BOOTREQUEST;
37 packet->op = BOOTREPLY;
39 packet->htype = ETH_10MB;
40 packet->hlen = ETH_10MB_LEN;
41 packet->cookie = htonl(DHCP_MAGIC);
42 packet->options[0] = DHCP_END;
43 add_simple_option(packet->options, DHCP_MESSAGE_TYPE, type);
47 /* read a packet from socket fd, return -1 on read error, -2 on packet error */
48 int get_packet(struct dhcpMessage *packet, int fd)
58 memset(packet, 0, sizeof(struct dhcpMessage));
59 bytes = read(fd, packet, sizeof(struct dhcpMessage));
65 if (ntohl(packet->cookie) != DHCP_MAGIC) {
69 DEBUG(LOG_INFO, "Received a packet");
71 if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) {
77 packet->flags |= htons(BROADCAST_FLAG);
117 /* Constuct a ip/udp header for a packet, and specify the source and dest hardware address */
124 struct udp_dhcp_packet packet;
132 memset(&packet, 0, sizeof(packet));
145 packet.ip.protocol = IPPROTO_UDP;
146 packet.ip.saddr = source_ip;
147 packet.ip.daddr = dest_ip;
148 packet.udp.source = htons(source_port);
149 packet.udp.dest = htons(dest_port);
150 packet.udp.len = htons(sizeof(packet.udp) + sizeof(struct dhcpMessage)); /* cheat on the psuedo-header */
151 packet.ip.tot_len = packet.udp.len;
152 memcpy(&(packet.data), payload, sizeof(struct dhcpMessage));
153 packet.udp.check = checksum(&packet, sizeof(struct udp_dhcp_packet));
155 packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet));
156 packet.ip.ihl = sizeof(packet.ip) >> 2;
157 packet.ip.version = IPVERSION;
158 packet.ip.ttl = IPDEFTTL;
159 packet.ip.check = checksum(&(packet.ip), sizeof(packet.ip));
161 result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest));
170 /* Let the kernel do all the work for packet generation */