⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rsvp_debug.c

📁 radius协议源码÷The Radius Stack will connect to a Radius Server. This stack implementation is built upo
💻 C
📖 第 1 页 / 共 2 页
字号:
		log(LOG_DEBUG, 0, "\t\t%s", fmt_adspec(sdscp->rsvp_adspec));}voidprint_flwds(struct packet *pkt)	{	int		i;	style_t		style = Style(pkt);	FlowDesc	*flwdp = FlowDesc_of(pkt, 0);	switch (style) {	case STYLE_WF:		log(LOG_DEBUG, 0, "   WF   %s\n", 			fmt_flowspec(flwdp->rsvp_specp));		break;	case STYLE_FF:		for (i = 0; i < pkt->rsvp_nflwd; i++) {			flwdp = FlowDesc_of(pkt, i);			log(LOG_DEBUG, 0, "    FF   %s    %s\n", 				fmt_filtspec(flwdp->rsvp_filtp),				fmt_flowspec(flwdp->rsvp_specp));		}		break;	case STYLE_SE:		log(LOG_DEBUG, 0, "    SE   %s   %s\n",				fmt_filtspec(flwdp->rsvp_filtp),				fmt_flowspec(flwdp->rsvp_specp));		for (i = 1; i < pkt->rsvp_nflwd; i++) {			flwdp = FlowDesc_of(pkt, i);			log(LOG_DEBUG, 0, "         %s\n",				fmt_filtspec(flwdp->rsvp_filtp));		}		break;	default:		log(LOG_DEBUG, 0, "   ??Style= %d\n", style);		break;  	}}char *rsvp_timestamp(void){	struct timeval tv;	struct tm	tmv;	static char	buff[16];	gettimeofday(&tv, NULL);	memcpy(&tmv, localtime((time_t *) &tv.tv_sec), sizeof(struct tm));	sprintf(buff, "%02d:%02d:%02d.%03d", tmv.tm_hour, tmv.tm_min,			tmv.tm_sec, (int) tv.tv_usec/1000);	return(buff);}/* log(): write to the log. * *	Write all messages of severity <= l_severity into log file; if *	not in daemon mode, write them onto console (stderr) as well. */voidlog(int severity, int syserr, const char *format, ...){	char *a_time = rsvp_timestamp();	va_list ap;	assert(severity == LOG_ALWAYS || severity >= LOG_ERR);	va_start(ap, format);	if (severity <= l_debug) {		if (severity < LOG_DEBUG)	   		fprintf(stderr, "%s  ", a_time);		vfprintf(stderr, format, ap);	}	if (severity < LOG_DEBUG)		fprintf(logfp, "%s  ", a_time);	vfprintf(logfp, format, ap);	if (syserr == 0) {		/* Do nothing for now */	} else if (syserr < sys_nerr) {		if (severity <= l_debug)			fprintf(stderr, ": %s\n", sys_errlist[syserr]);		fprintf(logfp, ": %s\n", sys_errlist[syserr]);	} else {		if (severity <= l_debug)			fprintf(stderr, ": errno %d\n", syserr);		fprintf(logfp, ": errno %d\n", syserr);	}	if (ftell(logfp) > MAX_LOG_SIZE)		reset_log(0);}static char    *Log_Event_Types[] =                 {"Rcv UDP", "Rcv Raw", "Rcv API",		 "Snd UDP", "Snd Raw", "Snd U+R",		 "API Reg", "API Rsv", "API Cls",		 "API Upc",  "APIdbug", "APIstat",		 "AddFlow", "ModFlow", "DelFlow", "AddFilt", "DelFilt",		 "Ignore",  "Gen Err"		};/* log_event(): write event entry to log and to stderr if logging *	severity (l_debug) is LOG_DEBUG. */voidlog_event(int evtype, char *type, SESSION *destp, const char *format, ...)	{	va_list	ap;	char	*a_time = rsvp_timestamp();	char	*sess;	if (l_debug < LOG_DEBUG)  /* (Extra test: call has already tested */		return;	  	  /* l_debug >= LOG_DEBUG, in IsDebug macro.*/	va_start(ap, format);	if (!destp)		return;	if (Log_Event_Cause == NULL) Log_Event_Cause = " ";	sess = session_print(destp);	fprintf(stderr, "%12s|%s %-8.8s %-9.9s %s    ", 		a_time, Log_Event_Cause, Log_Event_Types[evtype], type, sess);	vfprintf(stderr, format, ap);	fprintf(logfp,  "%12s|%s %-8.8s %-9.9s %-24s ", 		a_time, Log_Event_Cause, Log_Event_Types[evtype], type, sess); 	vfprintf(logfp, format, ap);	Log_Event_Cause = NULL;	if (ftell(logfp) > MAX_LOG_SIZE)		reset_log(0);		}/* Print out statistics */#define MAX_RSVP_STAT (sizeof(RSVPstat)/sizeof(u_int32_t))voiddump_rsvp_stats() {	int i, j;	union {		RSVPstat	str;		u_int32_t	vec[MAX_RSVP_STAT];	} sum_stat;		memset(sum_stat.vec, 0, sizeof(sum_stat));	for (i=0; i<if_num; i++)		for (j=0; j<MAX_RSVP_STAT; j++)			sum_stat.vec[j] +=				 ((u_int32_t *)&if_vec[i].if_stats)[j];	printf("\nRSVP STATS -- Summary of Interfaces\n\n");	printf("      Type\t\t   Received\t     Sent\n");	for (i=0; i<RSVP_MAX_MSGTYPE+1; i++)		if (*r_type[i] != '\0')		    printf("%3d %12s\t%8d\t%8d\n", i, r_type[i],			sum_stat.str.rsvpstat_msgs_in[i], 			sum_stat.str.rsvpstat_msgs_out[i]);	printf("\n");	for (i= 2*RSVP_MAX_MSGTYPE+2, j=0; i < MAX_RSVP_STAT; i++, j++)		if (sum_stat.vec[i])			printf("%6d   %s\n", sum_stat.vec[i], RSVPstat_msg[j]);}/* *  Print out hex dump of specified range of storage. */voidhexf(FILE *fp, char *p, int len) {	char	*cp = p;	int	hcnt = 0;    	while (len > 0) {		if (hcnt == 0)			fprintf(fp, "x%2.2lx: ", (unsigned long)(cp-p));		if ((hcnt%4) == 0)			fprintf(fp, " ");		fprintf(fp, "%2.2x", (0xff&*cp++)) ;		len--;		hcnt++;		if (hcnt >= 16 || len == 0) {			fprintf(fp, "\n");			hcnt = 0;		}	}}/* String copy routine that truncates if necessary to n-1 characters,  *   but always null-terminates. */char *strtcpy(s1, s2, n)char *s1, *s2;int n;    {    strncpy(s1, s2, n);    *(s1+n-1) = '\0';    return(s1);}/* * Convert an IP address in u_long (network) format into a printable string. * Taken from mrouted code. */char *inet_fmt(addr, s)    u_int32_t addr;    char *s;{    register u_char *a;    a = (u_char *)&addr;    sprintf(s, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);    return (s);}/* *	Format bitmask into string s */char *bm_expand(bm,s)bitmap *bm;char *s;{    int i,first=1;	char t[4];        memset(s,0,sizeof(*s));    sprintf(s,"<");    for (i=0; i<(NBBY * sizeof(*bm)); i++) {	if (bmp_tst(bm,i)) {	    if (first) {			sprintf(t,"%d",i);			strcat(s,t);			first = 0;		}		else {			sprintf(t,",%d",i);			strcat(s,t);		}			}    }    strcat(s,">");    return s;}/* * test if two bitmaps are equal  */int bmp_equ(bitmap *x, bitmap *y){	int i;	for (i = 0; i < BMP_SIZE; i++) {		if (x->bmp[i] != y->bmp[i])			return 0;	}	return 1;}/* * test if this bitmap is zero */int bmp_zero(bitmap *x){	int i;	for (i = 0; i < BMP_SIZE; i++) {		if (x->bmp[i] != 0)			return 0;	}	return 1;}/* * reset this bitmap to all zero */voidbmp_rst(bitmap *x){	int i;	for (i = 0; i < BMP_SIZE; i++) {		x->bmp[i] = 0;	}	return;}/* * set specific bit in this bitmap */voidbmp_set(bitmap *x, int n){	int i = (n)/NBBY;	int j = (n)%NBBY;	x->bmp[i] |= (1 << j);	return;}/* * clear specific bit in this bitmap */voidbmp_clr(bitmap *x, int n){	int i = (n)/NBBY;	int j = (n)%NBBY;	x->bmp[i] &= ~(1 << j);	return;}/* * test if specific bit in this bitmap is set */intbmp_tst(bitmap *x, int n){	int i = (n)/NBBY;	int j = (n)%NBBY;	return ((x->bmp[i]) & (1 << j));}/* * shift this bitmap left to some number of bits * (to be used for RSRR) */bitmap *bmp_shift(bitmap *x, bitmap *y, int n){	u_long i;	bmp_rst(y);	for (i = 0; i < BMP_SIZE*NBBY; i++) {		if (bmp_tst(x, i)) {			if ((i+n) < (BMP_SIZE*NBBY))				bmp_set(y,i+n);		}	}	return y;}/* * create a bitmap from a unsigned long integer * (to be used by RSRR) */bitmap *bmp_create(u_long x, bitmap *y){	u_long i;	bmp_rst(y);	for (i = 0; i < sizeof(u_long)*NBBY; i++) {		if (BIT_TST(x, i)) {			bmp_set(y,i);		}	}	return y;}/* * convert from a larger rsrr_bmp to smaller bitmap * (usually rsrr_bmp has 256 bits, and bitmap has only 64 bits) */bitmap *bmp_convert(rsrr_bmp *x, bitmap *y) {	int i;	bmp_rst(y);	for (i=0; i<(RSRR_MAX_VIFS_V2/NBBY); i++) {		if (i < BMP_SIZE) {			y->bmp[i] = x->bm[i];		} else {			if (x->bm[i] !=0) {				log(LOG_DEBUG,0,"Please increase the BMP_SIZE");				break;			}		}	}	return y;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -