mirror of
https://github.com/reactos/reactos.git
synced 2024-10-31 20:02:55 +00:00
4f0b8d3db0
svn path=/branches/ntvdm/; revision=59241
40 lines
1.2 KiB
C
40 lines
1.2 KiB
C
#include <rosdhcp.h>
|
|
|
|
SOCKET ServerSocket;
|
|
|
|
void SocketInit() {
|
|
ServerSocket = socket( AF_INET, SOCK_DGRAM, 0 );
|
|
}
|
|
|
|
ssize_t send_packet( struct interface_info *ip,
|
|
struct dhcp_packet *p,
|
|
size_t size,
|
|
struct in_addr addr,
|
|
struct sockaddr_in *broadcast,
|
|
struct hardware *hardware ) {
|
|
int result =
|
|
sendto( ip->wfdesc, (char *)p, size, 0,
|
|
(struct sockaddr *)broadcast, sizeof(*broadcast) );
|
|
|
|
if (result < 0) {
|
|
note ("send_packet: %x", result);
|
|
if (result == WSAENETUNREACH)
|
|
note ("send_packet: please consult README file%s",
|
|
" regarding broadcast address.");
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
ssize_t receive_packet(struct interface_info *ip,
|
|
unsigned char *packet_data,
|
|
size_t packet_len,
|
|
struct sockaddr_in *dest,
|
|
struct hardware *hardware ) {
|
|
int recv_addr_size = sizeof(*dest);
|
|
int result =
|
|
recvfrom (ip -> rfdesc, (char *)packet_data, packet_len, 0,
|
|
(struct sockaddr *)dest, &recv_addr_size );
|
|
return result;
|
|
}
|