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

📄 m2pppsecuritysecretslibtest.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* m2pppSecuritySecretsLibTest.c *//* Copyright (C) 2003 Wind River Systems, Inc. *//* forwards */STATUS  m2pppSecuritySecretsDatabasePrint(void);/*****************************************/STATUS m2pppSecuritySecretsLibTestPopulate    (    int rl,  /* range of links */    int ri   /* range of identities */    )    {    int l;    int i;    UINT32                          link;    PPP_SECURITY_SECRETS_DIRECTION  direction;    PPP_SECURITY_PROTOCOL           protocol;    char    identity[255];    char    secret[255];    char    aux[255];    if  ((rl>24) || (ri>24))        {        printf("rl or ri greater than 99\n");        return ERROR;        };    PPP_SECRETS_SEM_TAKE;    for (l=0; l<rl; l++)        {        for (i=0; i<ri; i++)            {            strcpy(identity,"i");            strcpy(secret,"s");            sprintf(aux,"%u",i);            strcat(identity,aux);            strcat(secret,aux);            link =      (UINT32)l;            direction = PPP_SECURITY_SECRETS_DIRECTION_LOCAL_TO_REMOTE;            protocol =  PPP_SECURITY_PAP_PROTOCOL;            if  (m2pppSecretsEntrySet(link,                                       direction,                                      protocol,                                      identity, secret,                                       PPP_SECURITY_SECRETS_STATUS_VALID) != OK)                {                m2pppSecuritySecretsDatabasePrint();                printf("m2pppSecretsEntrySet ERROR ==> abort\n");                printf("last attempt's data = [%2d,%1d,%1d,%3s,%3s]\n",                       link, direction, protocol, identity, secret);                return ERROR;                }            link =      (UINT32)l;            direction = PPP_SECURITY_SECRETS_DIRECTION_LOCAL_TO_REMOTE;            protocol =  PPP_SECURITY_CHAP_MD5_PROTOCOL;            if  (m2pppSecretsEntrySet(link,                                       direction,                                      protocol,                                      identity, secret,                                       PPP_SECURITY_SECRETS_STATUS_VALID) != OK)                {                m2pppSecuritySecretsDatabasePrint();                printf("m2pppSecretsEntrySet ERROR ==> abort\n");                printf("last attempt's data = [%2d,%1d,%1d,%3s,%3s]\n",                       link, direction, protocol, identity, secret);                return ERROR;                }            link =      (UINT32)l;            direction = PPP_SECURITY_SECRETS_DIRECTION_REMOTE_TO_LOCAL;            protocol =  PPP_SECURITY_PAP_PROTOCOL;            if  (m2pppSecretsEntrySet(link,                                       direction,                                      protocol,                                      identity, secret,                                       PPP_SECURITY_SECRETS_STATUS_VALID) != OK)                {                m2pppSecuritySecretsDatabasePrint();                printf("m2pppSecretsEntrySet ERROR ==> abort\n");                printf("last attempt's data = [%2d,%1d,%1d,%3s,%3s]\n",                       link, direction, protocol, identity, secret);                return ERROR;                }            link =      (UINT32)l;            direction = PPP_SECURITY_SECRETS_DIRECTION_REMOTE_TO_LOCAL;            protocol =  PPP_SECURITY_CHAP_MD5_PROTOCOL;            if  (m2pppSecretsEntrySet(link,                                       direction,                                      protocol,                                      identity, secret,                                       PPP_SECURITY_SECRETS_STATUS_VALID) != OK)                {                m2pppSecuritySecretsDatabasePrint();                printf("m2pppSecretsEntrySet ERROR ==> abort\n");                printf("last attempt's data = [%2d,%1d,%1d,%3s,%3s]\n",                       link, direction, protocol, identity, secret);                return ERROR;                }            }        }    printf("We attempted to add %u nodes with:\n", 4*(rl*ri));    printf("links: 0 to %u, directions: 1 to 2, protocols: 1 to 2, ",rl-1);     printf("identities: 0 to %u\n", ri-1);    PPP_SECRETS_SEM_GIVE;    return OK;    }/*****************************************/STATUS m2pppSecuritySecretsDatabasePrint(void)    {    printf("BEGIN SNAPSHOT OF DATA TREE ----------------------------------\n");        PPP_SECRETS_SEM_TAKE;    if  (avlTreePrint(pppSecretsDataTreePtr, printSecretsDataNode) != OK)        {        printf("avlTreePrint for pppSecretsDataTree did not return OK\n");        printf("END SNAPSHOT OF DATA TREE --------------------------------\n");        PPP_SECRETS_SEM_GIVE;        return ERROR;        };    printf("END SNAPSHOT OF DATA TREE --------------------------------\n");    printf("BEGIN SNAPSHOT OF PRIMARY TREE ---------------------------\n");    if (avlTreePrint(pppSecretsTreePtr, printSecretsNode) != OK)        {        printf("avlTreePrint for pppSecretsTree did not return OK\n");        printf("END SNAPSHOT OF PRIMARY TREE -------------------------\n");        PPP_SECRETS_SEM_GIVE;        return ERROR;        }    else        {        printf("END SNAPSHOT OF PRIMARY TREE -------------------------\n");        PPP_SECRETS_SEM_GIVE;        return OK;        }    }/*****************************************/void printSecretsDataNode(void * nodep)    {    UINT32                          link;    UINT32                          idIndex;    PPP_SECURITY_SECRETS_DIRECTION  direction;    PPP_SECURITY_PROTOCOL           protocol;    char *                          identity;    char *                          secret;    void *                          left;    void *                          right;    int                             height;    PPP_SECURITY_SECRETS_DATA_ENTRY * aux;    PPP_SECURITY_SECRETS_ENTRY  keyEntry;    PPP_SECURITY_SECRETS_DATA_ENTRY keyDataEntry;    PPP_SECURITY_SECRETS_ENTRY *        retrievedEntryPtr;    if  (NULL == nodep)        {        printf("printSecretsDataNode was called with NULL == <nodep> input\n");        return;        }    aux = (PPP_SECURITY_SECRETS_DATA_ENTRY *)nodep;    link =      aux->pppSecuritySecretsLink;    idIndex =   aux->pppSecuritySecretsIdIndex;    direction = aux->pppSecuritySecretsDirection;    protocol =  aux->pppSecuritySecretsProtocol;    identity =  aux->pppSecuritySecretsIdentity;    secret =    aux->pppSecuritySecretsSecret;    height =    (aux->avlBase).height;    left =      (aux->avlBase).left;    right =     (aux->avlBase).right;     POPULATE_PPP_SECRETS_KEY_ENTRY;    retrievedEntryPtr = avlSearch(pppSecretsTree,                                 (GENERIC_ARGUMENT)((void *)(&keyEntry)),                                 m2pppAgentKeyCompare);      printf("ht=%2d, N=%p=(%2d,%1d,%1d,",           height,           aux,           link,           direction,           protocol);    printf("%8.8s", identity);    if  ( strlen(identity) > 8 )        {        printf("*)");        }    else        {        printf(" )");        }    printf("<-(%2d,%2d) = ",           link,           idIndex);    printf("%p, secret: [%8.8s",retrievedEntryPtr, secret);    if  ( strlen(secret) > 8 )        {        printf("*]\n");        }    else        {        printf(" ]\n");        }    if  (left != NULL)         {        aux = (PPP_SECURITY_SECRETS_DATA_ENTRY *)left;        link =      aux->pppSecuritySecretsLink;        direction = aux->pppSecuritySecretsDirection;        protocol =  aux->pppSecuritySecretsProtocol;        identity =  aux->pppSecuritySecretsIdentity;        printf("       L=%p=(%2d,%1d,%1d,",               aux, link, direction, protocol);        printf("%8.8s", identity);        if  ( strlen(identity) > 8 )            {            printf("*)");            }        else            {            printf(" )");            }        }    else        {        printf("       L=NULL,                        ");        }    if  (right != NULL)         {        aux = (PPP_SECURITY_SECRETS_DATA_ENTRY *)right;        link =      aux->pppSecuritySecretsLink;        direction = aux->pppSecuritySecretsDirection;        protocol =  aux->pppSecuritySecretsProtocol;        identity =  aux->pppSecuritySecretsIdentity;        printf("R=%p=(%2d,%1d,%1d,",               aux, link, direction, protocol);        printf("%8.8s", identity);        if  ( strlen(identity) > 8 )            {            printf("*)\n");            }        else            {            printf(" )\n");            }        }    else        {        printf("R=NULL\n");        }    }/*****************************************/void printSecretsNode(void * nodep)    {    UINT32                          link;    UINT32                          idIndex;    PPP_SECURITY_SECRETS_DIRECTION  direction;    PPP_SECURITY_PROTOCOL           protocol;    char *                          identity;    char *                          secret;    void *                          left;    void *                          right;    int                             height;    PPP_SECURITY_SECRETS_ENTRY * aux;    PPP_SECURITY_SECRETS_DATA_ENTRY * auxData;    aux = (PPP_SECURITY_SECRETS_ENTRY *) nodep;    if  (NULL == nodep)        {        printf("printSecretsDataNode was called with NULL == <nodep> input\n");        return;        }    auxData = (PPP_SECURITY_SECRETS_DATA_ENTRY *)(aux->pSecretsDataEntry);    link =      auxData->pppSecuritySecretsLink;    idIndex =   auxData->pppSecuritySecretsIdIndex;    direction = auxData->pppSecuritySecretsDirection;    protocol =  auxData->pppSecuritySecretsProtocol;    identity =  auxData->pppSecuritySecretsIdentity;    secret =    auxData->pppSecuritySecretsSecret;    height =    (aux->avlBase).height;    left =      (aux->avlBase).left;    right =     (aux->avlBase).right;     printf("ht = %2d, N = %p = (%2d,%2d) -> ",           height,           aux,           link,            idIndex);    printf("%p = (%2d,%1d,%1d,",           auxData,           link,           direction,           protocol);            printf("%8.8s", identity);    if  ( strlen(identity) > 8 )        {        printf("*), [");        }    else        {        printf(" ), [");        }    printf("%8.8s", secret);    if  ( strlen(secret) > 8 )        {        printf("*]\n");        }    else        {        printf(" ]\n");        }    if  (left != NULL)         {        aux = (PPP_SECURITY_SECRETS_ENTRY *)left;        link =      (aux->pSecretsDataEntry)->pppSecuritySecretsLink;        idIndex =   (aux->pSecretsDataEntry)->pppSecuritySecretsIdIndex;        printf("         L = %p = (%2d,%2d), ",               aux, link, idIndex);        }    else        {        printf("         L = NULL,               ");        }    if  (right != NULL)         {        aux = (PPP_SECURITY_SECRETS_ENTRY *)right;        link =      (aux->pSecretsDataEntry)->pppSecuritySecretsLink;        idIndex =   (aux->pSecretsDataEntry)->pppSecuritySecretsIdIndex;        printf("R = %p = (%2d,%2d)\n",               aux, link, idIndex);        }    else        {

⌨️ 快捷键说明

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