Ejemplo n.º 1
0
/*
 *	Handle a BOOTP received packet.
 */
static void bootp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
			  unsigned src, unsigned len)
{
	struct bootp_hdr *bp;

	debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
	      src, dest, len, sizeof(struct bootp_hdr));

	bp = (struct bootp_hdr *)pkt;

	/* Filter out pkts we don't want */
	if (check_reply_packet(pkt, dest, src, len))
		return;

	/*
	 *	Got a good BOOTP reply.	 Copy the data into our variables.
	 */
#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
	status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
#endif

	store_net_params(bp);		/* Store net parameters from reply */

	/* Retrieve extended information (we must parse the vendor area) */
	if (net_read_u32((u32 *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
		bootp_process_vendor((uchar *)&bp->bp_vend[4], len);

	net_set_timeout_handler(0, (thand_f *)0);
	bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, "bootp_stop");

	debug("Got good BOOTP\n");

	net_auto_load();
}
Ejemplo n.º 2
0
void *receiver(void *arg)
{
	int pipeFd = 0;
	const unsigned char *p_packet = 0;
	struct pcap_pkthdr *p_pkthdr = 0;

	receiver_grub_args *grub = (receiver_grub_args*)arg;
	pcap_t *p_descr = grub->p_descr;
	NodeStatus *p_node_status = grub->p_node_status;
	unsigned char *source_ip = 0;	
	source_ip = grub->source_ip;

/*	if ((pipeFd = open(".read_sense", O_RDWR)) < 0) {
		perror("fail to call open()");
		exit(1);
	}
*/
	while(1){
		if (pcap_next_ex(p_descr, &p_pkthdr, &p_packet) != 1) {
			continue;
		}

		/*if ((pipeFd = open(".read_sense", O_RDWR)) < 0) {
			perror("fail to call open()");
			exit(1);
		}*/



		if(traffic_flag == 1) {
			confirmNodeTraffic(p_packet, p_pkthdr, source_ip, pipeFd);
		}
		
		check_reply_packet(p_packet, p_pkthdr, source_ip, p_node_status, pipeFd);

		//close(pipeFd);
	}
	close(pipeFd);

	return 0;
}