int Start_Interface(tInterface *Iface);
void Send_DHCPDISCOVER(tInterface *Iface);
void Send_DHCPREQUEST(tInterface *Iface, void *OfferBuffer, int TypeOffset);
int Start_Interface(tInterface *Iface);
void Send_DHCPDISCOVER(tInterface *Iface);
void Send_DHCPREQUEST(tInterface *Iface, void *OfferBuffer, int TypeOffset);
void Update_State(tInterface *Iface, int newState);
void SetAddress(tInterface *Iface, void *Addr, void *Mask, void *Router);
void Update_State(tInterface *Iface, int newState);
void SetAddress(tInterface *Iface, void *Addr, void *Mask, void *Router);
- Iface->Num = _SysIOCtl(fd, 4, (void*)Iface->Adapter); // Create interface
+ struct {
+ const char *Device;
+ const char *Name;
+ int Type;
+ } ifinfo;
+ ifinfo.Device = Iface->Adapter;
+ ifinfo.Name = "";
+ ifinfo.Type = 4;
+ Iface->Num = _SysIOCtl(fd, 4, &ifinfo); // Create interface
_SysIOCtl(fd, 6, addr); // Set address to 0.0.0.0
tmp = 0; _SysIOCtl(fd, 7, &tmp); // Set subnet mask to 0
// Open UDP Client
snprintf(path, sizeof(path), "/Devices/ip/%i/udp", Iface->Num);
_SysIOCtl(fd, 6, addr); // Set address to 0.0.0.0
tmp = 0; _SysIOCtl(fd, 7, &tmp); // Set subnet mask to 0
// Open UDP Client
snprintf(path, sizeof(path), "/Devices/ip/%i/udp", Iface->Num);
if( fd == -1 ) {
fprintf(stderr, "ERROR: Unable to open '%s'\n", path);
return -1;
}
tmp = 68; _SysIOCtl(fd, 4, &tmp); // Local port
tmp = 67; _SysIOCtl(fd, 5, &tmp); // Remote port
if( fd == -1 ) {
fprintf(stderr, "ERROR: Unable to open '%s'\n", path);
return -1;
}
tmp = 68; _SysIOCtl(fd, 4, &tmp); // Local port
tmp = 67; _SysIOCtl(fd, 5, &tmp); // Remote port
- tmp = 0; _SysIOCtl(fd, 7, &tmp); // Remote addr mask bits - we don't care where the reply comes from
+ tmp = 0; _SysIOCtl(fd, 7, &tmp); // Remote addr mask bits - we don't care where the reply comes from
addr[0] = addr[1] = addr[2] = addr[3] = 255; // 255.255.255.255
_SysIOCtl(fd, 8, addr); // Remote address
addr[0] = addr[1] = addr[2] = addr[3] = 255; // 255.255.255.255
_SysIOCtl(fd, 8, addr); // Remote address
- _SysWrite(Iface->SocketFD, data, sizeof(data));
+ i = _SysWrite(Iface->SocketFD, data, sizeof(data));
+ if( i != sizeof(data) ) {
+ _SysDebug("_SysWrite failed (%i != %i)", i, sizeof(data));
+ }
_SysIOCtl(Iface->IfaceFD, 6, Addr);
_SysIOCtl(Iface->IfaceFD, 7, &mask_bits);
_SysIOCtl(Iface->IfaceFD, 6, Addr);
_SysIOCtl(Iface->IfaceFD, 7, &mask_bits);
{
uint8_t *addr = Router;
_SysDebug("Router %i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]);
{
uint8_t *addr = Router;
_SysDebug("Router %i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]);