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

📄 printqos.c

📁 《Windows网络编程技术》附书源码源码. 运行环境:9x/Me/NT/2000/XP/ 源码语言:简体中文 第十二章
💻 C
📖 第 1 页 / 共 2 页
字号:
    char          szIPv6[128],
                  szIndent[MAX_INDENT];

    memset(szIndent, ' ', MAX_INDENT);
    szIndent[indent * 3] = 0;

    printf("%sStye = ", szIndent);
    switch (resv->Style)                // filter style
    {
        case RSVP_DEFAULT_STYLE:
            // Use the default for this socket type 
            printf("RSVP_DEFAULT_STYLE\n");
            break;
        case RSVP_WILDCARD_STYLE:
            printf("RSVP_WILDCARD_STYLE\n");
            break;
        case RSVP_FIXED_FILTER_STYLE:
            printf("RSVP_FIXED_FILTER_STYLE\n");
            break;
        case RSVP_SHARED_EXPLICIT_STYLE:
            printf("RSVP_SHARED_EXPLICIT_STYLE\n");
            break;
        default:
            printf("Unknown style %d\n", resv->Style);
            break;
    }
    printf("%sConfirmRequest = %s\n", szIndent, (resv->ConfirmRequest ? "yes":"no"));
    PrintPolicy(resv->PolicyElementList, resv->NumPolicyElement, indent+1);
    printf("%sNumFlowDesc = %lu\n", szIndent, resv->NumFlowDesc);
    //
    // Print out the flow descriptors (if any) associated with the filter
    //
    for(i=0; i < resv->NumFlowDesc ;i++)
    {
        PrintFlowspec(&resv->FlowDescList[i].FlowSpec, indent+1);
        printf("%s  NumFilters = %lu\n", szIndent, resv->FlowDescList[i].NumFilters);
        for(j=0; j < resv->FlowDescList[i].NumFilters ;j++)
        {
            printf("%s  FilterType = ", szIndent);
            switch (resv->FlowDescList[i].FilterList[j].Type)
            {
                case FILTERSPECV4:
                    addr.sin_addr.s_addr = resv->FlowDescList[i].FilterList[j].FilterSpecV4.Address.Addr;
                    printf("%s    FILTERSPECV4\n", szIndent);
                    printf("%s      Address = %s\n", szIndent, inet_ntoa(addr.sin_addr));
                    printf("%s      Port    = %d\n", szIndent,
                        ntohs(resv->FlowDescList[i].FilterList[j].FilterSpecV4.Port));
                    break;
                case FILTERSPECV6:
                    printf("%s    FILTERSPECV6\n", szIndent);
                    WSAAddressToString(
                        (LPSOCKADDR)&resv->FlowDescList[i].FilterList[j].FilterSpecV6.Address,
                        sizeof(IN_ADDR_IPV6),
                        NULL,
                        szIPv6,
                        &dwIPv6Len);
                    printf("%s      Address = %s\n", szIndent, szIPv6);
                    printf("%s      Port    = %hu\n", szIndent, 
                        resv->FlowDescList[i].FilterList[j].FilterSpecV6.Port);
                    break;
                case FILTERSPECV6_FLOW:
                    printf("%s    FILTERSPECV6_FLOW\n", szIndent);
                    WSAAddressToString(
                        (LPSOCKADDR)&resv->FlowDescList[i].FilterList[j].FilterSpecV6Flow.Address,
                        sizeof(IN_ADDR_IPV6),
                        NULL,
                        szIPv6,
                        &dwIPv6Len);
                    printf("%s      Address = %s\n", szIndent, szIPv6);
                    printf("%s      FlowLabel = %s\n", szIndent, 
                        resv->FlowDescList[i].FilterList[j].FilterSpecV6Flow.FlowLabel);
                    break;
                case FILTERSPECV4_GPI:
                    addr.sin_addr.s_addr = resv->FlowDescList[i].FilterList[j].FilterSpecV4Gpi.Address.Addr;
                    printf("%s    FILTERSPECV4_GPI\n", szIndent);
                    printf("%s      Address = %s\n", szIndent, inet_ntoa(addr.sin_addr));
                    printf("%s      Port    = %d\n", szIndent, 
                        resv->FlowDescList[i].FilterList[j].FilterSpecV4Gpi.GeneralPortId);
                    break;
                case FILTERSPECV6_GPI:
                    printf("%s    FILTERSPECV6_GPI\n", szIndent);
                    WSAAddressToString(
                        (LPSOCKADDR)&resv->FlowDescList[i].FilterList[j].FilterSpecV6Gpi.Address,
                        sizeof(IN_ADDR_IPV6),
                        NULL,
                        szIPv6,
                        &dwIPv6Len);
                    printf("%s      Address = %s\n", szIndent, szIPv6);
                    printf("%s      Port    = %hu\n", szIndent,
                        resv->FlowDescList[i].FilterList[j].FilterSpecV6Gpi.GeneralPortId);
                    break;
            }
        }
    }
    return;
}

//
// Function: PrintRsvpAdspec
//
// Description:
//    Prints the RSVP_ADSPEC object.
//
static void PrintRsvpAdspec(RSVP_ADSPEC *adspec, int indent)
{
    DWORD   i;
    char    szIndent[MAX_INDENT];

    memset(szIndent, ' ', MAX_INDENT);
    szIndent[indent * 3] = 0;

    printf("%sGeneralParams\n", szIndent);
    PrintAdGeneralParams(&adspec->GeneralParams, indent+1);

    printf("%sNumberOfServices = %d\n", szIndent, adspec->NumberOfServices);
    for(i=0; i < adspec->NumberOfServices ;i++)
    {
        printf("%s  Services[%d].Length = %lu\n", szIndent, 
            i, adspec->Services[i].Length);
        printf("%s  Services[%d].ServiceType = %s\n", szIndent,
            i, GetServiceTypeStr(adspec->Services[i].Service));
        printf("%s  Services[%d].Overrides\n",  szIndent, i);

        PrintAdGeneralParams(&adspec->Services[i].Overrides, indent+1);

        if (adspec->Services[i].Service == SERVICETYPE_GUARANTEED)
        {
            printf("%s     Services[%lu].CTotal = %lu\n", szIndent, i, 
                adspec->Services[i].Guaranteed.CTotal);
            printf("%s     Services[%lu].DTotal = %lu\n", szIndent, i, 
                adspec->Services[i].Guaranteed.DTotal);
            printf("%s     Services[%lu].CSum   = %lu\n", szIndent, i, 
                adspec->Services[i].Guaranteed.CSum);
            printf("%s     Services[%lu].DSum   = %lu\n", szIndent, i, 
                adspec->Services[i].Guaranteed.DSum);
        }
        else
        {
            printf("%s     Services[%lu].ParamBuffer[].ParameterId = %lu\n",
                szIndent, i, adspec->Services[i].ParamBuffer->ParameterId);
            printf("%s     Services[%lu].ParamBuffer[].Length      = %lu\n",
                szIndent, i, adspec->Services[i].ParamBuffer->Length);
        }
    }
    return;
}

//
// Function: PrintPolicy
//
// Description:
//    Print RSVP_POLICY objects.
//
static void PrintPolicy(RSVP_POLICY *pelements, int num, int indent)
{
    int      i;
    char     szIndent[MAX_INDENT];

    memset(szIndent, ' ', MAX_INDENT);
    szIndent[indent * 3] = 0;

    printf("%sNum Policy Elements = %d\n", szIndent, num);
    for(i=0; i < num ;i++)
    {
        printf("%s  Len  = %hu\n", szIndent, pelements[i].Len);
        printf("%s  Type = %hu\n", szIndent, pelements[i].Type);
    }
    return;
}

//
// Fucnction: PrintAdGeneralParams
//
// Description:
//    Print AD_GENERAL_PARAMS object.
//
static void PrintAdGeneralParams(AD_GENERAL_PARAMS *params, int indent)
{
    char    szIndent[MAX_INDENT];

    memset(szIndent, ' ', MAX_INDENT);
    szIndent[indent * 3] = 0;

    printf("%sIntServAwareHopCount  = 0x%X\n", szIndent, params->IntServAwareHopCount);
    if (params->PathBandwidthEstimate == POSITIVE_INFINITY_RATE)
        printf("%sPathBandwidthEstimate = POSITIVE INFINITY\n", szIndent);
    else
        printf("%sPathBandwidthEstimate = 0x%X\n", szIndent, params->PathBandwidthEstimate);
    printf("%sMinimumLatency        = 0x%X\n", szIndent, params->MinimumLatency);
    printf("%sPathMTU               = 0x%X\n", szIndent, params->PathMTU);
    printf("%sFlags                 = %lu\n", szIndent, params->Flags);

    return;
}

//
// Function: PrintRsvpPolicy
//
// Description:
//    Print the RSVP_POLICY_INFO object.
//
static void PrintRsvpPolicy(RSVP_POLICY_INFO *policy, int indent)
{
    PrintPolicy(policy->PolicyElement, policy->NumPolicyElement, indent+1);
    return;
}

//
// Function: PrintQosPriority
//
// Description:
//    Print the QOS_PRIORITY object.
//
static void PrintQosPriority(QOS_PRIORITY *priority, int indent)
{
    char    szIndent[MAX_INDENT];

    memset(szIndent, ' ', MAX_INDENT);
    szIndent[indent * 3] = 0;

    printf("%sSendPriority    = %u\n", szIndent, priority->SendPriority);
    printf("%sSendFlags       = %u\n", szIndent, priority->SendFlags);
    printf("%sReceivePriority = %u\n", szIndent, priority->ReceivePriority);
    return;
}

//
// Function: PrintQosSDMode
//
// Description:
//    Print the QOS_SD_MODE object.
//
static void PrintQosSDMode(QOS_SD_MODE *sd, int indent)
{
    char    szIndent[MAX_INDENT];

    memset(szIndent, ' ', MAX_INDENT);
    szIndent[indent * 3] = 0;

    printf("%sShapeDiscard Mode = ", szIndent);
    switch (sd->ShapeDiscardMode)
    {
        case TC_NONCONF_BORROW:       // use best efford for non conforming
            printf("TC_NONCONF_BORROW\n"); 
            break;
        case TC_NONCONF_SHAPE:        // hold data until it conforms
            printf("TC_NONCONF_SHAPE\n"); 
            break;
        case TC_NONCONF_DISCARD:      // drop any non-conforming data
            printf("TC_NONCONF_DISCARD\n"); 
            break;
        default:
            printf("Unknown traffic class %lu\n", sd->ShapeDiscardMode);
            break;
    }
    return;
}

//
// Function: PrintQosTrafficClass
//
// Description:
//    Print the QOS_TRAFFIC_CLASS object.
//
static void PrintQosTrafficClass(QOS_TRAFFIC_CLASS *traffic, int indent)
{
    char    szIndent[MAX_INDENT];

    memset(szIndent, ' ', MAX_INDENT);
    szIndent[indent * 3] = 0;
    printf("%sTrafficClass = %lu\n", szIndent, traffic->TrafficClass);
    return;
}

//
// Function: PrintQosDestAddr
//
// Description:
//    Print the QOS_DESTADDR structure.
//
static void PrintQosDestAddr(QOS_DESTADDR *dest, int indent)
{
    char    szIndent[MAX_INDENT];

    memset(szIndent, ' ', MAX_INDENT);
    szIndent[indent * 3] = 0;

    printf("%sDestAddress     = %s\n", szIndent, inet_ntoa(((SOCKADDR_IN *)dest->SocketAddress)->sin_addr));
    printf("%sDestAddress Len = %lu\n", szIndent, dest->SocketAddressLength);
    return;
}

⌨️ 快捷键说明

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