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

📄 rapi_fmt.c

📁 radius协议源码÷The Radius Stack will connect to a Radius Server. This stack implementation is built upo
💻 C
📖 第 1 页 / 共 2 页
字号:
			qos_name[ctxp->spec_type],			fspec_fmtf(ctxp->xtspec_r, b1),			fspec_fmtf(ctxp->xtspec_b, b2),			fspec_fmtf(ctxp->xtspec_p, b3),			fspec_fmtf((float32_t)ctxp->xtspec_m, b4),			fspec_fmtf((float32_t)ctxp->xtspec_M, b5));        return(out);}/* *	Format body of "Integrated Services format" tspec */char *rapi_fmt_tspecbody3(IS_tspbody_t *tbp)	{	IS_serv_hdr_t	*shp = (IS_serv_hdr_t *) &tbp->tspec_u;	int		 vers;	vers = Intserv_Version(tbp->st_mh.ismh_version);	if (vers != INTSERV_VERSION0) {		sprintf(out, "IS Tspec version? %d\n", vers);		return(out);	}	if (shp->issh_len32b != tbp->st_mh.ismh_len32b - 1) {		sprintf(out, ">1 serv hdr: unsupported.\n");		return(out);	}	switch (shp->issh_service) {	    case GENERAL_INFO:		{		gen_Tspec_t *gp =&tbp->tspec_u.gen_stspec;		if (tbp->st_mh.ismh_len32b != wordsof(sizeof(gen_Tspec_t))) {			sprintf(out1, "!Tspec: mh_len? %d ",						tbp->st_mh.ismh_len32b);			break;		}		if (gp->gtspec_parmno != IS_WKP_TB_TSPEC) {			sprintf(out1, "!Tspec: parm#? %d ", gp->gtspec_parmno);			break;		}		/* Don't print if invalid */		if (gp->gtspec_flags & ISPH_FLG_INV) {			strcpy(out1, "INV");			break;		}		strcpy(out1, rapi_fmt_gen_Tspecbody3(&gp->gen_Tspec_parms));		}		break;	    case CONTROLLED_LOAD_SERV:	    case GUARANTEED_SERV:		sprintf(out1, "T=[Wrong/obsolete Tspec service id %d]",			shp->issh_service);		break;	}	sprintf(out, "%s", out1);	return(out);}char *rapi_fmt_adspecbody2(qos_adspecx_t *adsp)	{	sprintf(out, "{%.4s%d hop %.5sBW %.5sus %dB}",		/* 34 */		(adsp->xaspec_flags & XASPEC_FLG_BRK)?"br! ":"",		adsp->xaspec_hopcnt,		fspec_fmtf(adsp->xaspec_path_bw, b1),		fspec_fmtf((float32_t)adsp->xaspec_min_latency, b2),		adsp->xaspec_composed_MTU);	if (!(adsp->xGaspec_flags & XASPEC_FLG_IGN)) {		strcat(out, " ,G={");		if (adsp->xGaspec_flags & XASPEC_FLG_BRK)			strcat(out, "br!");		if (adsp->xGaspec_flags & XASPEC_FLG_PARM) {			sprintf(out1, " %d %d %d %d",				adsp->xGaspec_Ctot, adsp->xGaspec_Dtot,				adsp->xGaspec_Csum, adsp->xGaspec_Dsum);			strcat(out, out1);		}		if (adsp->xGaspec_override) {			sprintf(out1, " %d hop %.5sBW %.5sus %dB",				adsp->xGaspec_hopcnt,				fspec_fmtf(adsp->xGaspec_path_bw, b1),				fspec_fmtf(				    (float32_t)adsp->xGaspec_min_latency, b2),				adsp->xGaspec_composed_MTU);			strcat(out, out1);		}		strcat(out, "}");	}	if (!(adsp->xClaspec_flags & XASPEC_FLG_IGN)) {		strcat(out, " ,CL={");		if (adsp->xClaspec_flags & XASPEC_FLG_BRK)			strcat(out, "br!");		if (adsp->xClaspec_override) {			sprintf(out1, " %d hop %.5sBW %.5sus %dB",				adsp->xClaspec_hopcnt,				fspec_fmtf(adsp->xClaspec_path_bw, b1),				fspec_fmtf(				    (float32_t)adsp->xClaspec_min_latency, b2),				adsp->xClaspec_composed_MTU);			strcat(out, out1);		}		strcat(out, "}");	}	return(out);}char *rapi_fmt_adspecbody3(IS_adsbody_t *ISap)	{	IS_main_hdr_t	*mhp = (IS_main_hdr_t *)ISap;	IS_serv_hdr_t	*shp = (IS_serv_hdr_t *)(mhp+1); /* Ptr to fragment */	IS_serv_hdr_t	*lastshp; 	IS_parm_hdr_t	*php, *lastphp;	char		 out2[80], *brk_str, *end_str;	if (mhp->ismh_version != INTSERV_VERSION0) {		sprintf(out, "IS Adspec version? %d\n", mhp->ismh_version);		return(out);	}	strcpy(out, "Adspec(");	lastshp  = (IS_serv_hdr_t *) Next_Main_Hdr(mhp);	/* TEMPORARY...!	 */	if (shp->issh_len32b & ISSH_BREAK_BIT) {		strcat(out, "rsvp-use-00!)\n");		return(out);	}	while (shp < lastshp) {	    lastphp = (IS_parm_hdr_t *)Next_Serv_Hdr(shp);	    brk_str = (shp->issh_flags & ISSH_BREAK_BIT) ? "br!" : "";	    end_str = "";	    switch(shp->issh_service) {		case GENERAL_INFO:			strcat(out, brk_str);			php = (IS_parm_hdr_t *)(shp+1);			break;		case GUARANTEED_SERV:			{			Gads_parms_t *gap = (Gads_parms_t *) shp;			if (gap->Gads_serv_hdr.issh_len32b == 0) {				sprintf(out2, ", G={%s", brk_str);				php = (IS_parm_hdr_t *)(shp+1);			}			else {				sprintf(out2, ", G={%s%d %d %d %d",					brk_str,					gap->Gads_Ctot, gap->Gads_Dtot,					gap->Gads_Csum, gap->Gads_Dsum);				php = (IS_parm_hdr_t *)(gap+1);			}			strcat(out, out2);			end_str = "}";			break;			}		case CONTROLLED_LOAD_SERV:			sprintf(out2, ", CL={%s", brk_str);			strcat(out, out2);			end_str = "}";			php = (IS_parm_hdr_t *)(shp+1);			break;		default:			sprintf(out2, "??Serv#=%d)\n", shp->issh_service);		        strcat(out, out2);			return(out);	    }	    while(php < lastphp) {		switch (php->isph_parm_num) {		    case IS_WKP_HOP_CNT:			sprintf(out2, " %d hop", *(u_int32_t *)(php+1));			break;		    case IS_WKP_MIN_LATENCY:			sprintf(out2, " %sus",				fspec_fmtf((float32_t)						*(u_int32_t *)(php+1), b2));			break;		    case IS_WKP_PATH_BW:			sprintf(out2, " %sBW",				fspec_fmtf(*(float32_t *)(php+1), b1));			break;		    case IS_WKP_COMPOSED_MTU:			sprintf(out2, " %dB", *(u_int32_t *)(php+1));			break;		    default:			strcpy(out2, "?parm");			break;		}		strcat(out, out2);		php = Next_Parm_Hdr(php);	    }	    strcat(out, end_str);	    shp = (IS_serv_hdr_t *)php;	}	strcat(out, ")\n");	return(out);}	/* *	Format generic Tspec */char *rapi_fmt_gen_Tspecbody3(TB_Tsp_parms_t *gp)	{	sprintf(out1, "T=[%s(%s) %sB/s %s %s]",			fspec_fmtf(gp->TB_Tspec_r, b1),			fspec_fmtf(gp->TB_Tspec_b, b2),			fspec_fmtf(gp->TB_Tspec_p, b3),			fspec_fmtf((float32_t)gp->TB_Tspec_m, b4),			fspec_fmtf((float32_t)gp->TB_Tspec_M, b5));	return(out1);}/* *  Format RAPI filter spec into buffer */voidrapi_fmt_filtspec(rapi_filter_t *afp, char *buff, int len)	{	struct sockaddr_in	*sadp;#ifdef	USE_IPV6	struct sockaddr_in6	*sadp6;#endif	/* USE_IPV6 */	if (len < 32)		return;	if (!afp || afp->form == RAPI_EMPTY_OTYPE) {		strcpy(buff, "( )");		return;	}	switch (afp->form) {	   case RAPI_FILTERFORM_BASE:		sadp = &afp->rapi_filt4;		if (sadp->sin_family != AF_INET) {			sprintf(buff, "Filtspec: Addr family %d?", 							sadp->sin_family);			return;		}		if (IN_ARE_ADDR_EQUAL(&sadp->sin_addr,&inaddr_any))			strcpy(buff,"(*)");		else			sprintf(buff, "%.24s/%hu",net_inaddr_host((char *)				&sadp->sin_addr,AF_INET),				ntoh16(sadp->sin_port));		break;	   case RAPI_FILTERFORM_GPI:		if (IN_ARE_ADDR_EQUAL(&afp->rapi_filtgpi4_addr,&inaddr_any))			strcpy(buff,"(*)");		else			sprintf(buff, "%.16s<g>%d",net_inaddr_host((char *)				&afp->rapi_filtgpi4_addr,AF_INET),				afp->rapi_filtgpi4_gpi);		break;				#ifdef	USE_IPV6	   case RAPI_FILTERFORM_BASE6:		sadp6 = &afp->rapi_filt6;		if (sadp6->sin6_family != AF_INET6) {			sprintf(buff, "Filtspec: Addr family %d?", 							sadp6->sin6_family);			return;		}		if (IN6_ARE_ADDR_EQUAL(&sadp6->sin6_addr,&in6addr_any))			strcpy(buff,"(*)");		else			sprintf(buff, "%.24s/%hu",net_inaddr_host((char *)				&sadp6->sin6_addr,AF_INET6),				ntoh16(sadp6->sin6_port));		break;	   case RAPI_FILTERFORM_GPI6:		if (IN6_ARE_ADDR_EQUAL(&afp->rapi_filtgpi6_addr,&in6addr_any))			strcpy(buff,"(*)");		else			sprintf(buff, "%.16s<g>%d",net_inaddr_host((char *)				&afp->rapi_filtgpi6_addr,AF_INET6),				afp->rapi_filtgpi6_gpi);		break;				#endif	/* USE_IPV6 */	   default:		strcpy(buff, "?Filt type");		return;	}}/*  *  Values in flowspecs actually contain limited precision. *  Reflect this by printing 3 significant digits, and float them using *  K or M suffix when appropriate. */char *fspec_fmtf(float32_t x, char *buff)	{	static char *fspec_units[] = {"",  "K",  "M", "G", "T"};	int i = 0; 	if (x >= 1.0e15)		sprintf(buff, "Inf");	else {		while (x >= 1000) {			i++;			x /= 1000;		}		sprintf(buff, "%.3g%s", x, fspec_units[i]);	}	return (buff);}

⌨️ 快捷键说明

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