diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-06 18:36:50 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-06 18:36:50 +0000 |
commit | 3538b9a8822421b7c8596a33a917dcf2f99c92b7 (patch) | |
tree | 768c23fe79bb81583de7376a4d744632d888d303 /networking/udhcp/packet.c | |
parent | 5d725462d44268f9a86030daaa6f6396d32f796c (diff) | |
download | busybox-w32-3538b9a8822421b7c8596a33a917dcf2f99c92b7.tar.gz busybox-w32-3538b9a8822421b7c8596a33a917dcf2f99c92b7.tar.bz2 busybox-w32-3538b9a8822421b7c8596a33a917dcf2f99c92b7.zip |
Implement optional syslog logging using ordinary
bb_xx_msg calls, and convert networking/* to it.
The rest of bbox will be converted gradually.
Diffstat (limited to 'networking/udhcp/packet.c')
-rw-r--r-- | networking/udhcp/packet.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 67a452dbc..30675eaab 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c | |||
@@ -58,21 +58,21 @@ int udhcp_get_packet(struct dhcpMessage *packet, int fd) | |||
58 | memset(packet, 0, sizeof(struct dhcpMessage)); | 58 | memset(packet, 0, sizeof(struct dhcpMessage)); |
59 | bytes = read(fd, packet, sizeof(struct dhcpMessage)); | 59 | bytes = read(fd, packet, sizeof(struct dhcpMessage)); |
60 | if (bytes < 0) { | 60 | if (bytes < 0) { |
61 | DEBUG(LOG_INFO, "couldn't read on listening socket, ignoring"); | 61 | DEBUG("couldn't read on listening socket, ignoring"); |
62 | return -1; | 62 | return -1; |
63 | } | 63 | } |
64 | 64 | ||
65 | if (ntohl(packet->cookie) != DHCP_MAGIC) { | 65 | if (ntohl(packet->cookie) != DHCP_MAGIC) { |
66 | LOG(LOG_ERR, "received bogus message, ignoring"); | 66 | bb_error_msg("Received bogus message, ignoring"); |
67 | return -2; | 67 | return -2; |
68 | } | 68 | } |
69 | DEBUG(LOG_INFO, "Received a packet"); | 69 | DEBUG("Received a packet"); |
70 | 70 | ||
71 | if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) { | 71 | if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) { |
72 | for (i = 0; broken_vendors[i][0]; i++) { | 72 | for (i = 0; broken_vendors[i][0]; i++) { |
73 | if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) && | 73 | if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) && |
74 | !strncmp((char*)vendor, broken_vendors[i], vendor[OPT_LEN - 2])) { | 74 | !strncmp((char*)vendor, broken_vendors[i], vendor[OPT_LEN - 2])) { |
75 | DEBUG(LOG_INFO, "broken client (%s), forcing broadcast", | 75 | DEBUG("broken client (%s), forcing broadcast", |
76 | broken_vendors[i]); | 76 | broken_vendors[i]); |
77 | packet->flags |= htons(BROADCAST_FLAG); | 77 | packet->flags |= htons(BROADCAST_FLAG); |
78 | } | 78 | } |
@@ -123,7 +123,7 @@ int udhcp_raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source | |||
123 | struct udp_dhcp_packet packet; | 123 | struct udp_dhcp_packet packet; |
124 | 124 | ||
125 | if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { | 125 | if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { |
126 | DEBUG(LOG_ERR, "socket call failed: %m"); | 126 | bb_perror_msg("socket"); |
127 | return -1; | 127 | return -1; |
128 | } | 128 | } |
129 | 129 | ||
@@ -136,7 +136,7 @@ int udhcp_raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source | |||
136 | dest.sll_halen = 6; | 136 | dest.sll_halen = 6; |
137 | memcpy(dest.sll_addr, dest_arp, 6); | 137 | memcpy(dest.sll_addr, dest_arp, 6); |
138 | if (bind(fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_ll)) < 0) { | 138 | if (bind(fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_ll)) < 0) { |
139 | DEBUG(LOG_ERR, "bind call failed: %m"); | 139 | bb_perror_msg("bind"); |
140 | close(fd); | 140 | close(fd); |
141 | return -1; | 141 | return -1; |
142 | } | 142 | } |
@@ -159,7 +159,7 @@ int udhcp_raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source | |||
159 | 159 | ||
160 | result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest)); | 160 | result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest)); |
161 | if (result <= 0) { | 161 | if (result <= 0) { |
162 | DEBUG(LOG_ERR, "write on socket failed: %m"); | 162 | bb_perror_msg("sendto"); |
163 | } | 163 | } |
164 | close(fd); | 164 | close(fd); |
165 | return result; | 165 | return result; |