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

📄 _giop2.c

📁 This directory contains source code for tcpdump, a tool for network monitoring and data acquisition
💻 C
📖 第 1 页 / 共 2 页
字号:
                        PRINTF (",component(GENERIC_SEC_MECH,bytes=%lu)",
                                component_len);
                        break;

                   default:
                        PRINTF (",component(tag=%lu,bytes=%lu)",
                                component_tag, component_len);
                        break;
                 }
               }
             }
           }
           break;

      case GIOP_PROFILE_MULTICOMPONENT:
           PRINTF ("type=MultiComponent,bytes=%lu", profile_len);
           break;

      case GIOP_PROFILE_ILU_IOP:
           {
             u_int32_t little_endian, sbhlen;

             little_endian  = (profile_bytes[0] != 0);
             profile_bytes += 4;
             sbhlen         = gtohl (*(u_int32_t*)profile_bytes,
                                     little_endian) - 1;
             profile_bytes += 4;
             PRINTF ("type=ILU,sbh=\"%*.*s\"", sbhlen, sbhlen, profile_bytes);
           }
           break;

      default:
           PRINTF ("type=%lu,bytes=%lu", i, profile_tag, profile_len);
           break;
    }
    PUTCHAR (')');
  }
  return (ior - orig_ior);
}

static u_int print_context (u_char *msg, u_int little_endian)
{
  u_int32_t context_id, context_len;
  u_char   *orig_msg_ptr = msg;

  context_id  = gtohl (*(u_int32_t *) msg, little_endian);
  msg        += 4;
  context_len = gtohl (*(u_int32_t *) msg, little_endian);
  msg        += 4;

  switch (context_id)
  {
    case GIOP_SERVICECONTEXT_TRANSACTION_SERVICE:
         {
           u_int     context_endianness, context_major, context_minor;
           u_int32_t timeout, tid_len, bequal_length, otid_formatid;
           u_char   *p;
           char     *s;

           p = msg;
           context_endianness = (p[0] == 1);
           context_major = p[1];
           context_minor = p[2];
           p += 4;
           timeout = gtohl (*(u_int32_t *) p, context_endianness);
           p += 4;

           PRINTF (",context=TransactionService(timeout=%lu,current.coordinator=(",
                   timeout);
           p += print_ior (p, context_endianness);
           PUTS ("),current.terminator=(");
           p += print_ior (p, context_endianness);
           otid_formatid = gtohl (*(u_int32_t*)p, context_endianness);
           p += 4;
           bequal_length = gtohl (*(u_int32_t*)p, context_endianness);
           p += 4;
           tid_len = gtohl (*(u_int32_t *) p, context_endianness);
           p += 4;
           s = quotechars (p, tid_len);
           PRINTF ("),otid=(formatID=%lu,bequal_length=%lu,tid=<%*.*s>)",
                   otid_formatid, bequal_length, tid_len, tid_len, s);
           free (s);

           msg += ((context_len + 3) / 4) * 4;
         }
         break;

    case GIOP_SERVICECONTEXT_CODESETS:
         {
           u_int32_t short_char_codeset, char_codeset;
           u_int     context_endianness, context_major, context_minor;

           context_endianness = (msg[0] == 1);
           context_major = msg[1];
           context_minor = msg[2];
           msg += 4;
           short_char_codeset = gtohl (*(u_int32_t*)msg, context_endianness);
           msg += 4;
           char_codeset = gtohl (*(u_int32_t*)msg, context_endianness);
           msg += 4;
           PRINTF (",context=CodeSets(char=0x%x%s,wchar=0x%x%s)",
                   short_char_codeset, figure_charset_name (short_char_codeset),
                   char_codeset, figure_charset_name (char_codeset));
           context_len -= 12;
           if (context_len > 0)
           {
             PUTS ("[junk]");
             msg += (((context_len + 3) / 4) * 4);
           }
         }
         break;

    default:
         msg += ((context_len + 3) / 4) * 4;
         PRINTF (",context=%u(bytes=%u)", context_id, context_len);
         break;
  }
  return (msg - orig_msg_ptr);
}


void giop_print (u_int connection, const u_char *msg, u_int msglen)
{
  struct giop_state *s = find_state (connection);

  u_int32_t msgtype;
  u_int32_t length;
  u_int     little_endian, last_chunk, i;
  u_int     major, minor, flags;

  PRINTF ("%s <giop", Pflag ? "\n " : "");

  if (strncmp (msg, "GIOP", 4))
  {
    PUTS ("[bad magic!]\n");
    return;
  }

  if (!s)
      s = add_state (connection);

  major = msg[4];
  minor = msg[5];
  flags = msg[6];
  little_endian = ((flags & 0x1) == 0x1);
  last_chunk    = ((minor > 0) ? ((flags & 0x2) == 0) : 1);

  msgtype = msg[7];
  msg += 8;

  length = gtohl (*((u_int32_t *) msg), little_endian);
  msg += 4;

  switch (msgtype)
  {
    case GIOP_MSGTYPE_REQUEST:
         {
           u_int     response_expected;
           u_int32_t contexts, sn;
           u_int32_t okeylen, mnamelen;
           char     *okey, *mname;

           PRINTF (" i(vers=%u.%u", major, minor);

           contexts = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           for (i = 0; i < contexts; i++)
              msg += print_context ((u_char*)msg, little_endian);

           sn = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           response_expected = (msg[0] != 0);
           msg += 4;
           okeylen = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           okey = quotechars ((u_char*)msg, okeylen);
           msg += ((okeylen + 3) / 4) * 4;
           mnamelen = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           mname = quotechars ((u_char*)msg, mnamelen - 1);
           msg += ((mnamelen + 3) / 4) * 4;
           PRINTF (",sn=%lu,method=\"%s\",disc=\"%s\")", sn, mname, okey);
           free (mname);
           free (okey);
         }
         break;   

    case GIOP_MSGTYPE_CANCEL_REQUEST:
         {
           u_int32_t req_to_cancel = gtohl (*(u_int32_t*)msg, little_endian);

           msg += 4;
           PRINTF (" c(CancelRequest,vers=%u.%u,req=%lu)",
                   major, minor, req_to_cancel);
         }
         break;

    case GIOP_MSGTYPE_LOCATE_REQUEST:
         {
           u_int32_t sn, okeylen;

           sn = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           okeylen = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           msg += okeylen;
           PRINTF (" c(LocateRequest,vers=%u.%u,sn=%lu,bytes=%lu)",
                   major, minor, sn);
         }
         break;

    case GIOP_MSGTYPE_LOCATE_REPLY:
         {
           u_int32_t sn, repstat;

           sn = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           repstat = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           PRINTF (" c(LocateReply,vers=%u.%u,sn=%lu", major, minor, sn);

           switch (repstat)
           {
             case IIOP_OBJECT_FORWARD:
                  PUTS ("status=ObjectForward(");
                  msg += print_ior ((u_char *) msg, little_endian);
                  PUTCHAR (')');
                  break;
             case IIOP_OBJECT_HERE:
                  PUTS ("status=ObjectHere");
                  break;
             case IIOP_UNKNOWN_OBJECT:
                  PUTS ("status=UnknownObject");
                  break;
             default:
                  PRINTF ("[unknown reply status %lu!]\n", repstat);
                  return;
           }
           PUTCHAR (')');
         }
         break;

    case GIOP_MSGTYPE_MESSAGE_ERROR:
         PRINTF (" c(MessageError,vers=%u.%u)", major, minor);
         break;

    case GIOP_MSGTYPE_CLOSE_CONNECTION:
         PRINTF (" c(CloseConnection,vers=%u.%u)", major, minor);
         break;

    case GIOP_MSGTYPE_REPLY:
         {
           u_int32_t contexts, sn;
           u_int32_t elen, minor_code, completed, status;
           u_char   *eid;

           PRINTF (" r(vers=%u.%u", major, minor);

           contexts = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           for (i = 0; i < contexts; i++)
              msg += print_context ((u_char*)msg, little_endian);

           sn = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           PRINTF (",sn=%lu", sn);
           status = gtohl (*(u_int32_t*)msg, little_endian);
           msg += 4;
           switch (status)
           {
             case GIOP_REPLYSTATUS_NO_EXCEPTION:
                  PUTS (",Success");
                  break;

             case GIOP_REPLYSTATUS_USER_EXCEPTION:
                  elen = gtohl (*(u_int32_t*)msg, little_endian);
                  msg += 4;
                  eid = (u_char *) msg;
                  msg += ((elen + 3) / 4) * 4;
                  PRINTF (",UserException=\"%*.*s\"", elen - 1, elen - 1, eid);
                  break;

             case GIOP_REPLYSTATUS_SYSTEM_EXCEPTION:
                  elen = gtohl (*(u_int32_t*)msg, little_endian);
                  msg += 4;
                  eid = (u_char *) msg;
                  msg += ((elen + 3) / 4) * 4;
                  minor_code = gtohl (*(u_int32_t*)msg, little_endian);
                  msg += 4;
                  completed = gtohl (*(u_int32_t*)msg, little_endian);
                  msg += 4;
                  PRINTF (",SystemException=\"%*.*s\",minor=%lu,completed=%s",
                          elen - 1, elen - 1, eid, minor_code,
                          completed == 0 ? "Yes" : ((completed == 1) ? "No" : "Maybe"));
                  break;

             case GIOP_REPLYSTATUS_LOCATION_FORWARD:
                  {
                    PUTS (",LocationForward(");
                    msg += print_ior ((u_char*)msg, little_endian);
                    PUTCHAR (')');
                  }
                  break;

             default:
                  PRINTF ("[bad reply status %lu!]\n", status);
                  return;
           }
           PUTCHAR (')');
         }
         break;

    case GIOP_MSGTYPE_FRAGMENT:
         PRINTF (" c(Fragment,vers=%u.%u)", major, minor);
         break;

    default:
         PRINTF ("[unknown msg type %lu!]\n", msgtype);
         return;
  }
  PUTCHAR ('>');
}

⌨️ 快捷键说明

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