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

📄 _rx.c

📁 This directory contains source code for tcpdump, a tool for network monitoring and data acquisition
💻 C
📖 第 1 页 / 共 4 页
字号:

trunc:
  PUTS (" [|cb]");
}

/*
 * Handle calls to the AFS protection database server
 */

static void prot_print (const u_char * bp, int length)
{
  unsigned long i;
  char     s[AFSNAMEMAX];
  int      pt_op;

  if (length <= sizeof(struct rx_header))
     return;

  if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t))
     goto trunc;

  /*
   * Print out the afs call we're invoking.  The table used here was
   * gleaned from ptserver/ptint.xg
   */

  pt_op = ntohl (*((int *) (bp + sizeof(struct rx_header))));

  PUTS (" pt");

  if (is_ubik (pt_op))
  {
    ubik_print (bp, length);
    return;
  }

  PRINTF (" call %s", tok2str (pt_req, "op#%d", pt_op));

  /*
   * Decode some of the arguments to the PT calls
   */

  bp += sizeof(struct rx_header) + 4;

  switch (pt_op)
  {
    case 500:                /* I New User */
         STROUT (PRNAMEMAX);
         PUTS (" id");
         INTOUT();
         PUTS (" oldid");
         INTOUT();
         break;
    case 501:                /* Where is it */
    case 506:                /* Delete */
    case 508:                /* Get CPS */
    case 512:                /* List entry */
    case 514:                /* List elements */
    case 517:                /* List owned */
    case 518:                /* Get CPS2 */
    case 519:                /* Get host CPS */
         PUTS (" id");
         INTOUT();
         break;
    case 502:                /* Dump entry */
         PUTS (" pos");
         INTOUT();
         break;
    case 503:                /* Add to group */
    case 507:                /* Remove from group */
    case 515:                /* Is a member of? */
         PUTS (" uid");
         INTOUT();
         PUTS (" gid");
         INTOUT();
         break;
    case 504:                /* Name to ID */
         {
           unsigned long j;

           TRUNC (4);
           j = ntohl (*((int *) bp));
           bp += sizeof(int32_t);

           /*
            * Who designed this chicken-shit protocol?
            *
            * Each character is stored as a 32-bit
            * integer!
            */

           for (i = 0; i < j; i++)
           {
             VECOUT (PRNAMEMAX);
           }
           if (j == 0)
             PUTS (" <none!>");
         }
         break;
    case 505:                /* Id to name */
         {
           unsigned long j;

           PUTS (" ids:");
           TRUNC (4);
           i = ntohl (*((int *) bp));
           bp += sizeof(int32_t);
           for (j = 0; j < i; j++)
             INTOUT();
           if (j == 0)
             PUTS (" <none!>");
         }
         break;
    case 509:                /* New entry */
         STROUT (PRNAMEMAX);
         PUTS (" flag");
         INTOUT();
         PUTS (" oid");
         INTOUT();
         break;
    case 511:                /* Set max */
         PUTS (" id");
         INTOUT();
         PUTS (" gflag");
         INTOUT();
         break;
    case 513:                /* Change entry */
         PUTS (" id");
         INTOUT();
         STROUT (PRNAMEMAX);
         PUTS (" oldid");
         INTOUT();
         PUTS (" newid");
         INTOUT();
         break;
    case 520:                /* Update entry */
         PUTS (" id");
         INTOUT();
         STROUT (PRNAMEMAX);
         break;
  }
  return;

trunc:
  PUTS (" [|pt]");
}

/*
 * Handle replies to the AFS protection service
 */
static void prot_reply_print (const u_char * bp, int length, int32_t opcode)
{
  struct   rx_header *rxh;
  unsigned long i;
  char     s[AFSNAMEMAX];

  if (length < sizeof(struct rx_header))
     return;

  rxh = (struct rx_header *) bp;

  /*
   * Print out the afs call we're invoking.  The table used here was
   * gleaned from ptserver/ptint.xg.  Check to see if it's a
   * Ubik call, however.
   */

  PUTS (" pt");

  if (is_ubik (opcode))
  {
    ubik_reply_print (bp, length, opcode);
    return;
  }

  PRINTF (" reply %s", tok2str (pt_req, "op#%d", opcode));

  bp += sizeof(struct rx_header);

  /*
   * If it was a data packet, interpret the response
   */

  if (rxh->type == RX_PACKET_TYPE_DATA)
    switch (opcode)
    {
      case 504:              /* Name to ID */
           {
             unsigned long j;

             PUTS (" ids:");
             TRUNC (4);
             i = ntohl (*((int *) bp));
             bp += sizeof(int32_t);
             for (j = 0; j < i; j++)
               INTOUT();
             if (j == 0)
               PUTS (" <none!>");
           }
           break;
      case 505:              /* ID to name */
           {
             unsigned long j;

             TRUNC (4);
             j = ntohl (*((int *) bp));
             bp += sizeof(int32_t);

             /*
              * Who designed this chicken-shit protocol?
              *
              * Each character is stored as a 32-bit
              * integer!
              */

             for (i = 0; i < j; i++)
             {
               VECOUT (PRNAMEMAX);
             }
             if (j == 0)
               PUTS (" <none!>");
           }
           break;
      case 508:              /* Get CPS */
      case 514:              /* List elements */
      case 517:              /* List owned */
      case 518:              /* Get CPS2 */
      case 519:              /* Get host CPS */
           {
             unsigned long j;

             TRUNC (4);
             j = ntohl (*((int *) bp));
             bp += sizeof(int32_t);
             for (i = 0; i < j; i++)
             {
               INTOUT();
             }
             if (j == 0)
               PUTS (" <none!>");
           }
           break;
      case 510:              /* List max */
           PUTS (" maxuid");
           INTOUT();
           PUTS (" maxgid");
           INTOUT();
           break;
      default:
           ;
    }
  else
  {
    /*
     * Otherwise, just print out the return code
     */
    PUTS (" errcode");
    INTOUT();
  }

  return;

trunc:
  PUTS (" [|pt]");
}

/*
 * Handle calls to the AFS volume location database service
 */

static void vldb_print (const u_char * bp, int length)
{
  int      vldb_op;
  unsigned long i;
  char     s[AFSNAMEMAX];

  if (length <= sizeof(struct rx_header))
     return;

  if (snapend - bp + 1 <= sizeof(struct rx_header) + sizeof(int32_t))
     goto trunc;

  /*
   * Print out the afs call we're invoking.  The table used here was
   * gleaned from vlserver/vldbint.xg
   */

  vldb_op = ntohl (*((int *) (bp + sizeof(struct rx_header))));

  PUTS (" vldb");

  if (is_ubik (vldb_op))
  {
    ubik_print (bp, length);
    return;
  }
  PRINTF (" call %s", tok2str (vldb_req, "op#%d", vldb_op));

  /*
   * Decode some of the arguments to the VLDB calls
   */

  bp += sizeof(struct rx_header) + 4;

  switch (vldb_op)
  {
    case 501:                /* Create new volume */
    case 517:                /* Create entry N */
         VECOUT (VLNAMEMAX);
         break;
    case 502:                /* Delete entry */
    case 503:                /* Get entry by ID */
    case 507:                /* Update entry */
    case 508:                /* Set lock */
    case 509:                /* Release lock */
    case 518:                /* Get entry by ID N */
         PUTS (" volid");
         INTOUT();
         TRUNC (sizeof(int32_t));
         i = ntohl (*((int *) bp));
         bp += sizeof(int32_t);
         if (i <= 2)
           PRINTF (" type %s", voltype[i]);
         break;
    case 504:                /* Get entry by name */
    case 519:                /* Get entry by name N */
    case 524:                /* Update entry by name */
    case 527:                /* Get entry by name U */
         STROUT (VLNAMEMAX);
         break;
    case 505:                /* Get new vol id */
         PUTS (" bump");
         INTOUT();
         break;
    case 506:                /* Replace entry */
    case 520:                /* Replace entry N */
         PUTS (" volid");
         INTOUT();
         TRUNC (sizeof(int32_t));
         i = ntohl (*((int *) bp));
         bp += sizeof(int32_t);
         if (i <= 2)
           PRINTF (" type %s", voltype[i]);
         VECOUT (VLNAMEMAX);
         break;
    case 510:                /* List entry */
    case 521:                /* List entry N */
         PUTS (" index");
         INTOUT();
         break;
    default:
         ;
  }

  return;

trunc:
  PUTS (" [|vldb]");
}

/*
 * Handle replies to the AFS volume location database service
 */

static void vldb_reply_print (const u_char * bp, int length, int32_t opcode)
{
  struct   rx_header *rxh;
  unsigned long i;
  char     s[AFSNAMEMAX];

  if (length < sizeof(struct rx_header))
     return;

  rxh = (struct rx_header *) bp;

  /*
   * Print out the afs call we're invoking.  The table used here was
   * gleaned from vlserver/vldbint.xg.  Check to see if it's a
   * Ubik call, however.
   */

  PUTS (" vldb");

  if (is_ubik (opcode))
  {
    ubik_reply_print (bp, length, opcode);
    return;
  }

  PRINTF (" reply %s", tok2str (vldb_req, "op#%d", opcode));

  bp += sizeof(struct rx_header);

  /*
   * If it was a data packet, interpret the response
   */

  if (rxh->type == RX_PACKET_TYPE_DATA)
    switch (opcode)
    {
      case 510:              /* List entry */
           PUTS (" count");
           INTOUT();
           PUTS (" nextindex");
           INTOUT();
      case 503:              /* Get entry by id */
      case 504:              /* Get entry by name */
           {
             unsigned long nservers, j;

             VECOUT (VLNAMEMAX);
             TRUNC (sizeof(int32_t));
             bp += sizeof(int32_t);
             PUTS (" numservers");
             TRUNC (sizeof(int32_t));
             nservers = ntohl (*((int *) bp));
             bp += sizeof(int32_t);
             PRINTF (" %lu", nservers);
             PUTS (" servers");
             for (i = 0; i < 8; i++)
             {
               TRUNC (sizeof(int32_t));
               if (i < nservers)
                 PRINTF (" %s", inet_ntoa (*((struct in_addr *) bp)));
               bp += sizeof(int32_t);
             }
             PUTS (" partitions");
             for (i = 0; i < 8; i++)
             {
               TRUNC (sizeof(int32_t));
               j = ntohl (*((int *) bp));
               if (i < nservers && j <= 26)
                 PRINTF (" %c", 'a' + (int) j);
               else if (i < nservers)
                 PRINTF (" %lu", j);
               bp += sizeof(int32_t);
             }
             TRUNC (8 * sizeof(int32_t));
             bp += 8 * sizeof(int32_t);
             PUTS (" rwvol");
             UINTOUT();
             PUTS (" rovol");
             UINTOUT();
             PUTS (" backup");
             UINTOUT();
           }
           break;
      case 505:              /* Get new volume ID */
           PUTS (" newvol");
           UINTOUT();
           break;
      case 521:              /* List entry */
      case 529:              /* List entry U */
           PUTS (" count");
           INTOUT();
           PUTS (" nextindex");
           INTOUT();
      case 518:              /* Get entry by ID N */
      case 519:              /* Get entry by name N */
           {
             unsigned long nservers, j;

             VECOUT (VLNAMEMAX);
             PUTS (" numservers");
             TRUNC (sizeof(int32_t));
             nservers = ntohl (*((int *) bp));
             bp += sizeof(int32_t);
             PRINTF (" %lu", nservers);
             PUTS (" servers");
             for (i = 0; i < 13; i++)
             {
               TRUNC (sizeof(int32_t));
               if (i < nservers)
                 PRINTF (" %s", inet_ntoa (*((struct in_addr *) bp)));
               bp += sizeof(int32_t);
             }
             PUTS (" partitions");
             for (i = 0; i < 13; i++)
             {
               TRUNC (sizeof(int32_t));
               j = ntohl (*((int *) bp));
               if (i < nservers && j <= 26)
                 PRINTF (" %c", 'a' + (int) j);
               else if (i < nservers)
                 PRINTF (" %lu", j);
               bp += sizeof(int32_t);
             }
             TRUNC (13 * sizeof(int32_t));
             bp += 13 * sizeof(int32_t);
             PUTS (" rwvol");
             UINTOUT();
             PUTS (" rovol");
             UINTOUT();
             PUTS (" backup");
             UINTOUT();
           }
           break;
      case 526:              /* Get entry by ID U */
      case 527:              /* Get entry by name U */
           {
             unsigned long nservers, j;

             VECOUT (VLNAMEMAX);
             PUTS (" numservers");
             TRUNC (sizeof(int32_t));
             nservers = ntohl (*((int *) bp));
             bp += sizeof(int32_t);
             PRINTF (" %lu", nservers);
             PUTS (" servers");
             for (i = 0; i < 13; i++)
             {
               if (i < nservers)
               {
                 PUTS (" afsuuid");
                 AFSUUIDOUT();
               }
               else
               {
                 TRUNC (44);
                 bp += 44;
               }
             }
             TRUNC (4 * 13);
             bp += 4 * 13;
             PUTS (" partitions");
             for (i = 0; i < 13; i++)
             {
               TRUNC (sizeof(int32_t));
               j = ntohl (*((int *) bp));
               if (i < nservers && j <= 26)
                 PRINTF (" %c", 'a' + (int) j);
               else if (i < nservers)
                 PRINTF (" %lu", j);
               bp += sizeof(int32_t);
             }
             TRUNC (13 * sizeof(int32_t));
             bp += 13 * sizeof(int32_t);
             PUTS (" rwvol");
             UINTOUT();
             PUTS (" rovol");
             UINTOUT();
             PUTS (" backup");
             UINTOUT();
           }
  }
  else
  {
    /*
     * Otherwise, just print out the return code
     */

⌨️ 快捷键说明

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