| 1 | #include "config.h"
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 | #include <string.h>
|
|---|
| 4 | #include <orbit/orbit.h>
|
|---|
| 5 | #include <ctype.h>
|
|---|
| 6 |
|
|---|
| 7 | #include "../src/orb/orb-core/iop-profiles.h"
|
|---|
| 8 |
|
|---|
| 9 | static void
|
|---|
| 10 | print_objkey (ORBit_ObjectKey *objkey)
|
|---|
| 11 | {
|
|---|
| 12 | int i;
|
|---|
| 13 | GString *str = g_string_sized_new (objkey->_length * 2 + 8);
|
|---|
| 14 |
|
|---|
| 15 | for (i = 0; i < objkey->_length; i++)
|
|---|
| 16 | g_string_append_printf (str, "%02x", objkey->_buffer [i]);
|
|---|
| 17 |
|
|---|
| 18 | printf ("(%d) '%s'", objkey->_length, str->str);
|
|---|
| 19 |
|
|---|
| 20 | g_string_free (str, TRUE);
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | static void
|
|---|
| 24 | print_components (CORBA_Object obj, GSList *components)
|
|---|
| 25 | {
|
|---|
| 26 | GSList *l;
|
|---|
| 27 |
|
|---|
| 28 | for (l = components; l; l = l->next) {
|
|---|
| 29 | IOP_Component_info *c = l->data;
|
|---|
| 30 |
|
|---|
| 31 | switch (c->component_type) {
|
|---|
| 32 |
|
|---|
| 33 | case IOP_TAG_COMPLETE_OBJECT_KEY:
|
|---|
| 34 | printf (" IOP_TAG_COMPLETE_OBJECT_KEY: object_key ");
|
|---|
| 35 | print_objkey (obj->object_key);
|
|---|
| 36 | printf ("\n");
|
|---|
| 37 | break;
|
|---|
| 38 |
|
|---|
| 39 | case IOP_TAG_SSL_SEC_TRANS: {
|
|---|
| 40 | IOP_TAG_SSL_SEC_TRANS_info *sst = l->data;
|
|---|
| 41 | printf (" IOP_TAG_SSL_SEC_TRANS: %d:%d port %d\n",
|
|---|
| 42 | sst->target_supports, sst->target_requires,
|
|---|
| 43 | sst->port);
|
|---|
| 44 | break;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | case IOP_TAG_GENERIC_SSL_SEC_TRANS: {
|
|---|
| 48 | IOP_TAG_GENERIC_SSL_SEC_TRANS_info *sst = l->data;
|
|---|
| 49 | printf (" IOP_TAG_GENERIC_SSL_SEC_TRANS: service %s\n",
|
|---|
| 50 | sst->service);
|
|---|
| 51 | break;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | default:
|
|---|
| 55 | printf (" Unknown component %#x\n", c->component_type);
|
|---|
| 56 | break;
|
|---|
| 57 | }
|
|---|
| 58 | printf ("\n");
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | static void
|
|---|
| 63 | print_iiop_version (GIOPVersion ver)
|
|---|
| 64 | {
|
|---|
| 65 | switch (ver) {
|
|---|
| 66 | case GIOP_1_0:
|
|---|
| 67 | printf ("GIOP 1.0");
|
|---|
| 68 | break;
|
|---|
| 69 | case GIOP_1_1:
|
|---|
| 70 | printf ("GIOP 1.1");
|
|---|
| 71 | break;
|
|---|
| 72 | case GIOP_1_2:
|
|---|
| 73 | printf ("GIOP 1.2");
|
|---|
| 74 | break;
|
|---|
| 75 | default:
|
|---|
| 76 | g_assert_not_reached ();
|
|---|
| 77 | break;
|
|---|
| 78 | }
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | int
|
|---|
| 82 | main (int argc, char *argv[])
|
|---|
| 83 | {
|
|---|
| 84 | GSList *l;
|
|---|
| 85 | CORBA_ORB orb;
|
|---|
| 86 | const char *ior;
|
|---|
| 87 | const char *type_id;
|
|---|
| 88 | CORBA_Object obj;
|
|---|
| 89 | CORBA_Environment ev;
|
|---|
| 90 |
|
|---|
| 91 | CORBA_exception_init (&ev);
|
|---|
| 92 |
|
|---|
| 93 | orb = CORBA_ORB_init (&argc, argv, "orbit-local-orb", &ev);
|
|---|
| 94 |
|
|---|
| 95 | if (argc != 2) {
|
|---|
| 96 | fprintf (stderr, "Usage: ior-decode <IOR>\n");
|
|---|
| 97 | return 1;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | ior = strstr (argv [1], "IOR:");
|
|---|
| 101 | if (!ior)
|
|---|
| 102 | g_error ("Input doesn't look like an IOR\n");
|
|---|
| 103 |
|
|---|
| 104 | obj = CORBA_ORB_string_to_object (orb, ior, &ev);
|
|---|
| 105 | if (ev._major) {
|
|---|
| 106 | g_error ("Couldn't do string_to_object on '%s': %s\n",
|
|---|
| 107 | ior, CORBA_exception_id (&ev));
|
|---|
| 108 | return 2;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | if (obj == CORBA_OBJECT_NIL) {
|
|---|
| 112 | fprintf (stderr, "Resolved to a NIL object reference\n");
|
|---|
| 113 | return 3;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | type_id = g_quark_to_string (obj->type_qid);
|
|---|
| 117 | printf ("Object ID: %s\n", type_id ? type_id : "<error no type id>");
|
|---|
| 118 |
|
|---|
| 119 | for (l = obj->profile_list; l; l = l->next) {
|
|---|
| 120 | IOP_Profile_info *pi = l->data;
|
|---|
| 121 |
|
|---|
| 122 | switch (pi->profile_type) {
|
|---|
| 123 | case IOP_TAG_INTERNET_IOP: {
|
|---|
| 124 | IOP_TAG_INTERNET_IOP_info *iiop = l->data;
|
|---|
| 125 |
|
|---|
| 126 | printf ("IOP_TAG_INTERNET_IOP: ");
|
|---|
| 127 | print_iiop_version (iiop->iiop_version);
|
|---|
| 128 | printf (" %s:%d\n",
|
|---|
| 129 | iiop->host, iiop->port);
|
|---|
| 130 | printf (" object_key ");
|
|---|
| 131 | print_objkey (obj->object_key);
|
|---|
| 132 | printf ("\n");
|
|---|
| 133 | print_components (obj, iiop->components);
|
|---|
| 134 | break;
|
|---|
| 135 | }
|
|---|
| 136 | case IOP_TAG_GENERIC_IOP: {
|
|---|
| 137 | IOP_TAG_GENERIC_IOP_info *giop = l->data;
|
|---|
| 138 | printf ("IOP_TAG_GENERIC_IOP: ");
|
|---|
| 139 | print_iiop_version (giop->iiop_version);
|
|---|
| 140 | printf ("[%s] %s:%s\n",
|
|---|
| 141 | giop->proto,
|
|---|
| 142 | giop->host, giop->service);
|
|---|
| 143 | print_components (obj, giop->components);
|
|---|
| 144 | break;
|
|---|
| 145 | }
|
|---|
| 146 | case IOP_TAG_MULTIPLE_COMPONENTS: {
|
|---|
| 147 | IOP_TAG_MULTIPLE_COMPONENTS_info *mci = l->data;
|
|---|
| 148 | printf ("IOP_TAG_MULTIPLE_COMPONENTS:\n");
|
|---|
| 149 | print_components (obj, mci->components);
|
|---|
| 150 | break;
|
|---|
| 151 | }
|
|---|
| 152 | case IOP_TAG_ORBIT_SPECIFIC: {
|
|---|
| 153 | IOP_TAG_ORBIT_SPECIFIC_info *osi = l->data;
|
|---|
| 154 | printf ("IOP_TAG_ORBIT_SPECIFIC: usock %s IPv6 port %d\n",
|
|---|
| 155 | osi->unix_sock_path, osi->ipv6_port);
|
|---|
| 156 | printf (" object_key ");
|
|---|
| 157 | print_objkey (obj->object_key);
|
|---|
| 158 | printf ("\n");
|
|---|
| 159 | break;
|
|---|
| 160 | }
|
|---|
| 161 | default:
|
|---|
| 162 | printf ("Unknown profile type %#x\n", pi->profile_type);
|
|---|
| 163 | break;
|
|---|
| 164 | }
|
|---|
| 165 | printf ("\n");
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | return 0;
|
|---|
| 169 | }
|
|---|