📄 _w3ng.c
字号:
{
struct w3ng_state *s = find_state (connection);
u_int32_t header;
if (!s)
s = add_state (connection);
PRINTF ("%s <w3ng", Pflag ? "\n " : "");
header = ntohl (*(u_int32_t*)msg);
msg += 4;
if (W3NG_CONTROL_MSG_P (header))
{
switch (W3NG_CONTROL_MSG_ID (header))
{
case W3NG_INITIALIZE_CONNECTION_MSG:
{
char *sid;
u_int major_version, minor_version;
sid = quote_chars ((u_char *) msg, W3NG_INITIALIZE_CONNECTION_SIDLEN (header));
major_version = W3NG_INITIALIZE_CONNECTION_VERSION_H (header);
minor_version = W3NG_INITIALIZE_CONNECTION_VERSION_L (header);
PRINTF (" c(InitializeConnection,sid=\"%s\",protocolversion=%u.%u)",
sid, major_version, minor_version);
msg += ((strlen(sid) + 3) / 4) * 4;
s->caller = 1;
free (sid);
break;
}
case W3NG_TERMINATE_CONNECTION_MSG:
PRINTF (" c(TerminateConnection,cause=%lu,last_sn=%lu)",
(unsigned long) W3NG_TERMINATE_CONNECTION_CAUSE (header),
(unsigned long) W3NG_TERMINATE_CONNECTION_LAST_SN (header));
break;
case W3NG_DEFAULT_CHARSET_MSG:
PRINTF (" c(DefaultCharset,charset=%lu)", (unsigned long) W3NG_DEFAULT_CHARSET_CHARSET (header));
break;
default:
PUTS (" c(unrecognized)");
break;
}
}
else if (s->caller) /* Request */
{
u_int32_t serial_number, op_len;
u_int ext_headers, disc_cached, op_cached;
u_int disc_cache_idx = 0, op_cache_idx = 0;
u_int cache_disc, disc_ih_len, cache_op, op_index;
char *op_typeid, *disc_string;
u_char *disc_ih;
serial_number = ++s->serial_number;
ext_headers = W3NG_EXTENSION_HEADERS_P (header);
disc_cached = W3NG_REQUEST_DISC_CACHED_P (header);
if (disc_cached)
{
cache_disc = 0;
disc_cache_idx = W3NG_REQUEST_DISC_CACHE_IDX (header);
}
else
{
cache_disc = W3NG_REQUEST_CACHE_DISC_P (header);
disc_ih_len = W3NG_REQUEST_DISC_LEN (header);
}
op_cached = W3NG_REQUEST_OP_CACHED_P (header);
if (op_cached)
{
cache_op = 0;
op_cache_idx = W3NG_REQUEST_OP_CACHE_IDX (header);
}
else
{
cache_op = W3NG_REQUEST_CACHE_OP_P (header);
op_index = W3NG_REQUEST_OP_INDEX (header);
op_len = ntohl (*(u_int32_t *) msg);
msg += 4;
op_typeid = (char*) msg;
msg += ((op_len + 3) / 4) * 4;
}
PRINTF (" i(%lu", serial_number);
if (op_cached)
{
if (!get_cached_operation (s, op_cache_idx, (u_char**)&op_typeid,
(u_int*)&op_len, &op_index))
{
PRINTF ("[unknown cached op %lu!]", op_cache_idx);
return;
}
}
PRINTF (",op=\"%*.*s\"/%lu%s",
op_len, op_len, op_typeid, op_index,
op_cached ? "+" : (cache_op ? "" : "-"));
if (cache_op)
cache_operation (s, (u_char*)op_typeid, op_len, op_index);
if (ext_headers)
{
u_int32_t nheaders, i;
u_int32_t headersize;
nheaders = ntohl (*(u_int32_t *) msg);
msg += 4;
for (i = 0; i < nheaders; i += 1)
{
headersize = ntohl (*(u_int32_t *) msg);
msg += 4 + ((headersize + 3) / 4) * 4;
PRINTF (",exthdr(%lu,bytes=%lu)", i, headersize);
}
}
if (disc_cached)
{
if (!get_cached_discriminant (s, disc_cache_idx, &disc_ih, &disc_ih_len))
{
PRINTF ("[unknown cached discriminant %lu!]", disc_cache_idx);
return;
}
}
else
disc_ih = (u_char*) msg;
disc_string = quote_chars ((u_char *) disc_ih, disc_ih_len);
PRINTF (",obj=\"%s\"%s", disc_string,
disc_cached ? "+" : (cache_disc ? "" : "-"));
if (cache_disc)
cache_discriminant (s, (u_char *) msg, disc_ih_len);
if (!disc_cached)
msg += (((disc_ih_len + 3) / 4) * 4);
free (disc_string);
PUTCHAR (')');
}
else /* Reply */
{
u_int ext_headers, reply_status, sn;
u_int32_t excn;
sn = W3NG_REPLY_SERIAL_NUMBER (header);
ext_headers = W3NG_EXTENSION_HEADERS_P (header);
reply_status = W3NG_REPLY_STATUS (header);
PRINTF (" r(%lu", sn);
switch (reply_status)
{
case W3NG_REPLY_STATUS_SUCCESS:
PUTS (",status=Success");
break;
case W3NG_REPLY_STATUS_USEREXN:
PUTS (",status=UserException");
excn = ntohl (*((u_int32_t *) msg));
msg += 4;
PRINTF (",index=%lu)", excn);
break;
case W3NG_REPLY_STATUS_SYSEXNB:
case W3NG_REPLY_STATUS_SYSEXNA:
PRINTF (",status=SystemException%s",
reply_status == W3NG_REPLY_STATUS_SYSEXNA ?
"After" : "Before");
excn = ntohl (*((u_int32_t *) msg));
msg += 4;
switch (excn)
{
case W3NG_SYSEXN_UnknownProblem:
PUTS (":Unknown");
break;
case W3NG_SYSEXN_ImplementationLimit:
PUTS (":ImplementationLimit");
break;
case W3NG_SYSEXN_SwitchSessionCinfo:
{
char *newinfo;
u_int32_t newinfolen = ntohl (*((u_int32_t*)msg));
msg += 4;
newinfo = quote_chars ((u_char*)msg, newinfolen);
msg += ((newinfolen + 3) / 4) * 4;
PRINTF (":SwitchSessionCinfo(\"%s\")", newinfo);
free (newinfo);
}
break;
case W3NG_SYSEXN_Marshal:
PUTS (":Marshal");
break;
case W3NG_SYSEXN_NoSuchObjectType:
PUTS (":NoSuchObjectType");
break;
case W3NG_SYSEXN_NoSuchMethod:
PUTS (":NoSuchMethod");
break;
case W3NG_SYSEXN_Rejected:
{
char *msgtxt;
u_int32_t msglen = ntohl (*((u_int32_t*)msg));
msg += 4;
msgtxt = quote_chars ((u_char*)msg, msglen);
msg += ((msglen + 3) / 4) * 4;
PRINTF (":Rejected(\"%s\"", msgtxt);
free (msgtxt);
}
break;
case W3NG_SYSEXN_DiscOrOpCacheOverflow:
PUTS (":OperationOrDiscriminantCacheOverflow");
break;
default:
PRINTF ("(unknown exception %lu!)", excn);
break;
}
}
if (ext_headers)
{
u_int32_t nheaders, i;
u_int32_t headersize;
nheaders = ntohl (*(u_int32_t*)msg);
msg += 4;
for (i = 0; i < nheaders; i += 1)
{
headersize = ntohl (*(u_int32_t*)msg);
msg += 4 + ((headersize + 3) / 4) * 4;
PRINTF (",exthdr(%lu,bytes=%lu)", i, headersize);
}
}
PUTCHAR (')');
}
PUTCHAR ('>');
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -