示例#1
0
文件: responses.c 项目: shoal/sIP
void ip_response()
{
    uint8_t buff[] = {
        0x02, 0, 0, 0, 0, 0,		//hw
        0x02, 1, 1, 1, 1, 1,
        0x08, 0x00,			//ip

        0x45, 0, 			//header ver/len/frag
        0, 36,				//len
        0, 0, 0, 0,
        200, 				//ttl
        0x11,				//udp
        0x6f, 0x75,				//checksum - 0x0000 = ignore
        192, 168, 1, 2,
        192, 168, 1, 1,

        0xfd, 0xe8, 0xfd, 0xe8,		//src/dest port
        0, 16,				//len
        0xcf, 0x43,				//checksum - 0 = ignore
        'h', 'e', 'l', 'l', 'o', '-', 'm', 'e'
    };

    // write to debug file
    write_pcap(buff, sizeof(buff));

    (cb_frame_complete)(buff, sizeof(buff));


}
示例#2
0
文件: responses.c 项目: shoal/sIP
void arp_response( )
{

    uint8_t buff[] = {
        0x02, 0, 0, 0, 0, 0,		//hw
        0x02, 1, 1, 1, 1, 1,
        0x08, 0x06,			//arp
        0x00, 0x01,			//ether
        0x08, 0x00,			//arp
        0x06,				//hw len
        0x04,				//ip len
        0x00, 0x02,			//response
        0x02, 1, 1, 1, 1, 1,		//whoami
        192, 168, 1, 2,		//whoami
        0x02, 0, 0, 0, 0, 0,		//youare
        192, 168, 1, 1
    };		//youare
    uint16_t buff_len = 42;


    // write to debug file
    write_pcap(buff, buff_len);

    // send data back
    (cb_frame_complete)(buff, buff_len);


}
示例#3
0
static void save_network(struct network *n)
{
	int i;

	write_pcap(_outfd, n->n_beacon, n->n_beaconlen);

        for (i = 0; i < 4; i++) {
                struct packet *p = &n->n_handshake->c_handshake[i];

                if (p->p_len)
                        packet_write_pcap(_outfd, p);
        }
}
示例#4
0
static void save_network(const struct network * n)
{
	REQUIRE(n != NULL);

	int i;

	_outfd = open_pcap(_outfilename);
	write_pcap(_outfd, n->n_beacon, n->n_beaconlen);

	for (i = 0; i < 4; i++)
	{
		struct packet * p = &n->n_handshake->c_handshake[i];

		ALLEGE(p != NULL); //-V547

		if (p->p_len) packet_write_pcap(_outfd, p);
	}
}
示例#5
0
/** Write to file & decide what response to give **/
RETURN_STATUS send_frame(const uint8_t *buffer, const uint16_t buffer_len)
{

	write_pcap(buffer, buffer_len-ETH_CRCLEN);

	if(buffer[12] == 0x08 && buffer[13] == 0x06)
	{
		// only respond to a request
		if(buffer[21] == 1)
			arp_response();
	}

	if(buffer[12] == 0x08 && buffer[13] == 0x00)
	{
		//IP - assume UDP as thats what I'm testing...
		ip_response();
	}

return SUCCESS;

}
示例#6
0
static inline void packet_write_pcap(int fd, const struct packet * p)
{
	write_pcap(fd, p->p_data, p->p_len);
}
示例#7
0
static void packet_write_pcap(int fd, struct packet *p)
{
        write_pcap(fd, p->p_data, p->p_len);
}