File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / hping2 / binding.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 22:11:37 2012 UTC (12 years, 10 months ago) by misho
Branches: hping2, MAIN
CVS tags: v2_0_0rc3p7, v2_0_0rc3p5, v2_0_0rc3p4, v2_0_0rc3p0, v2_0_0rc3, HEAD
hping2

/* 
 * $smu-mark$ 
 * $name: binding.c$ 
 * $author: Salvatore Sanfilippo <antirez@invece.org>$ 
 * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$ 
 * $license: This software is under GPL version 2 of license$ 
 * $date: Fri Nov  5 11:55:46 MET 1999$ 
 * $rev: 11$ 
 */ 

#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <errno.h>

#include "hping2.h"
#include "globals.h"

void inc_destparm(int sid)
{
	static long sec = 0;
	static long usec = 0;
	int *p;
	int errno_save = errno;

	switch (ctrlzbind) {
	case BIND_DPORT:
		p = &dst_port;
		break;
	case BIND_TTL:
		p = &src_ttl;
		break;
	default:
		printf("error binding ctrl+z\n");
		/* errno = errno_save; */
		return;
	}

	if ( (time(NULL) == sec) && ((get_usec() - usec) < 200000) ) {
		if (*p > 0)
			(*p)-=2;
		if (*p < 0)
			*p=0;
	} else
		(*p)++;
	
	printf("\b\b\b\b\b\b\b\b\b");
	printf("%d: ", *p);
	fflush(stdout);

	sec = time(NULL);
	usec = get_usec();
	signal(SIGTSTP, inc_destparm);
	errno = errno_save;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>