Beispiel #1
0
static int preprocess()
{
	const char* flag = arg_getflag();
	while (flag != NULL)
	{
		if (matches(flag, "--file"))
		{
			g_filename = arg_getflagarg();
			if (g_filename == NULL)
			{
				puts("** Usage: --file filename");
				puts(HELP_MSG);
				return 1;
			}
		}
		else if (matches(flag, "--os"))
		{
			const char* os = arg_getflagarg();
			if (os == NULL || !os_set(os))
			{
				puts("** Usage: --os osname");
				puts(HELP_MSG);
				return 1;
			}
		}
		else if (matches(flag, "--version"))
		{
			printf("premake (Premake Build Script Generator) %s\n", VERSION);
		}

		flag = arg_getflag();
	}

	return 1;
}
Beispiel #2
0
// ------------------------------------------------
// Function:        dhcp_send()
// ------------------------------------------------
// Input:           Message type
//                  TRUE to broadcast answer
// Output:          TRUE if succesful
// ------------------------------------------------
// Description:     Send a DHCP message
// ------------------------------------------------
BOOL dhcp_send(BYTE type, BOOL broadcast)
{
    PPBUF buf;

    buf = udp_new(SOCKET_DHCP);
    if(buf == NULL) return FALSE;

    DHCP(buf->data)->op = 1;                            // BOOTREQUEST
    DHCP(buf->data)->htype = 1;                         // ETH 10MBPS
    DHCP(buf->data)->hlen = 6;                          // 6 bytes ETH MAC
    DHCP(buf->data)->hops = 0;
    DHCP(buf->data)->xid = xid.d;
    DHCP(buf->data)->secs = 0;

    if(broadcast) {
        DHCP(buf->data)->flags = HTONS(0x8000);         // server must broadcast answer
        DHCP(buf->data)->ci.d = 0;
    } else {
        DHCP(buf->data)->flags = 0;                     // server must send unicast answer
        DHCP(buf->data)->ci.d = ip_local[INTERFACE_ETH].d;
    }

    DHCP(buf->data)->yi.d = 0;
    DHCP(buf->data)->gi.d = 0;
    DHCP(buf->data)->si.d = ip_dhcp.d;

    os_set((BYTE *)(&DHCP(buf->data)->chaddr), 0, 16+64+128);
    os_copy((BYTE *)&mac_local,
            (BYTE *)(&DHCP(buf->data)->chaddr),
            sizeof(MACADDR));

    // --------------
    // insert options
    // --------------
    skip(buf, BOOTP_HDR_SIZE);
    buf->size = BOOTP_HDR_SIZE;
    write_uint32(buf, 0x63825363);                      // magic cookie

    write_byte(buf, DHCP_OPT_TYPE);                     // DHCP message type
    write_byte(buf, 1);
    write_byte(buf, type);

    write_byte(buf, DHCP_OPT_ID);                       // DHCP source ID
    write_byte(buf, 7);
    write_byte(buf, 1);
    write_buf(buf, (BYTE *)&mac_local, sizeof(MACADDR));

    write_byte(buf, DHCP_OPT_IP);                       // Request IP address
    write_byte(buf, 4);
    write_ip(buf, ip_tmp);

#ifdef _DNS
    write_byte(buf, DHCP_OPT_REQ);                      // Request options
    write_byte(buf, 3);
    write_byte(buf, DHCP_OPT_MASK);
    write_byte(buf, DHCP_OPT_ROUTER);
    write_byte(buf, DHCP_OPT_DNS);
#else
    write_byte(buf, DHCP_OPT_REQ);                      // Request options
    write_byte(buf, 2);
    write_byte(buf, DHCP_OPT_MASK);
    write_byte(buf, DHCP_OPT_ROUTER);
#endif

    write_byte(buf, DHCP_OPT_END);                      // done with options

    udp_send(buf);
    release_buffer(buf);
    return TRUE;
}