📄 _corba.c
字号:
/* Total length is missing
*/
PRINTF ("missing No_Reply %d ", id);
print_iiop_message (request->hdr);
/* Call duration is missing
*/
PRINTF ("missing ");
/* request-length, missing, request-duration, missing
*/
PRINTF ("%d missing ", length);
ts_diff_print (&request->last, &request->first);
PUTS ("missing missing");
}
static void print_unmatched_corba_reply (struct iiop_msg *reply,
u_int32_t id,
struct iiop_tha *request_tha,
struct timeval *reply_first,
struct timeval *reply_last)
{
struct MessageHeader_1_x *hdr = reply->hdr;
PUTCHAR ('\n');
ts_print (reply_last);
PRINTF ("%s.%d > %s.%d: Corba %d.%d ",
ipaddr_string (&request_tha->src), request_tha->src_port,
ipaddr_string (&request_tha->dst), request_tha->dst_port,
hdr->GIOPVersion.major, hdr->GIOPVersion.minor);
/* Length is missing
*/
PRINTF ("missing No_Request %d ", id);
/* Three unavailable fields: object-key method call-duration
*/
PUTS ("missing missing missing ");
/* missing, reply-length, missing, reply-duration
*/
PRINTF ("missing %d missing ", reply->hdr->messageSize);
ts_diff_print (reply_last, reply_first);
PUTS ("missing");
}
/*
* For now, only one prune per cycle
*/
static void prune_old_requests (struct timeval *time)
{
struct iiop_msg *request = requests;
static const u_int timeout = 30; /* user-settable? */
u_int min = time->tv_sec - timeout;
while (request)
{
if (request->last.tv_sec < min)
{
print_unmatched_corba_request (request);
free_request (request);
break;
}
request = request->nxt;
}
}
static void reply_postprint (struct iiop_msg *reply,
struct iiop_tha *reply_tha,
u_int32_t id,
struct timeval *reply_first,
struct timeval *reply_last)
{
struct iiop_tha request_tha;
struct iiop_msg *request = requests;
request_tha.src = reply_tha->dst;
request_tha.dst = reply_tha->src;
request_tha.src_port = reply_tha->dst_port;
request_tha.dst_port = reply_tha->src_port;
while (request)
{
if (!memcmp (&request_tha, &request->addr, sizeof(request_tha)) &&
id == giop_request_id(request->hdr))
break;
request = request->nxt;
}
if (request)
{
print_corba_call (request, reply, reply_first, reply_last);
}
else
{
/* No matching request */
print_unmatched_corba_reply (reply, id, &request_tha,
reply_first, reply_last);
}
prune_old_requests (reply_last);
}
/*
* Two important points to note about print_corba:
*
* 1. The byte vector passed in to this function is
* from tcpdump's main loop, and will get clobbered
* on the next cycle. Since we need to save it, in
* order to frame iiop and match requests and replies,
* copies are made for Request and Reply types.
*
* 2, The giop printer modifies certain numeric fields in
* place. It's important not to use any of those fields
* until this in-place modification has been done.
*
* res, 13-April-1999
*/
void print_corba (const u_char *bp, u_int length, const u_char *bp2)
{
const struct tcphdr *tp;
const struct ip *ip;
struct iiop_tha tha;
struct iiop_stream *iiop_th;
u_short sport, dport;
u_int32_t seq;
int inMessage, payloadLength;
u_char *giop;
tp = (struct tcphdr*) bp;
ip = (struct ip*) bp2;
sport = ntohs (tp->th_sport);
dport = ntohs (tp->th_dport);
seq = ntohl (tp->th_seq);
tha.src = ip->ip_src;
tha.dst = ip->ip_dst;
tha.src_port = sport;
tha.dst_port = dport;
for (iiop_th = iiop_streams; iiop_th; iiop_th = iiop_th->nxt)
{
if (!memcmp(&tha, &iiop_th->addr, sizeof(iiop_th->addr)))
break;
}
if (!iiop_th)
{
iiop_th = (struct iiop_stream*) calloc (1, sizeof(*iiop_th));
if (!iiop_th)
error ("tcp_print: calloc");
iiop_th->addr = tha;
iiop_th->consumed = iiop_th->size = 0;
iiop_th->nxt = iiop_streams;
iiop_streams = iiop_th;
}
inMessage = iiop_th->msg && (iiop_th->consumed < iiop_th->size);
/* Only do the GIOP stuff if there's actually data
* res 3-Nov-98
*
* Be sure to allow for non-zero options
*/
payloadLength = length - 4*tp->th_off;
if (inMessage)
{
int overflow;
iiop_th->consumed = seq + payloadLength - iiop_th->seq;
#if 0
PRINTF (" seq=%d consumed=%d size=%d ",
iiop_th->seq, iiop_th->consumed, iiop_th->size);
#endif
overflow = iiop_th->consumed - iiop_th->size;
if (overflow >= payloadLength)
{
/* I'm assuming this means that data was dropped from the trace
* and we're picking up somewhere after the end of the pending
* message.
*/
PUTS ("<iiop_incomplete> ");
if (iiop_th->msg->hdr->messageType == Reply)
{
free_msg (iiop_th->msg);
}
else if (iiop_th->msg->hdr->messageType == Request)
{
if (is_oneway ((iiop_th->msg->hdr)))
free_request (iiop_th->msg);
}
iiop_th->msg = 0;
iiop_th->size = iiop_th->consumed = 0;
inMessage = 0;
}
else if (overflow >= 0)
{
/* If overflow is > 0, we could in theory look for GIOP at that
* point in the current packet.
*/
struct iiop_msg *msg = iiop_th->msg;
msg->last.tv_sec = PacketTimestamp->tv_sec;
msg->last.tv_usec = PacketTimestamp->tv_usec;
PUTS ("iiop ");
corba_giop_print (msg->hdr);
/* Duration of extended message
*/
ts_diff_print (PacketTimestamp, &msg->first);
if (msg->hdr->messageType == Reply)
{
u_int id = giop_reply_id (msg->hdr);
reply_postprint (msg, &iiop_th->addr, id, &msg->first, &msg->last);
free_msg (msg);
}
else if (msg->hdr->messageType == Request)
{
if (is_oneway (msg->hdr))
print_corba_call (msg, 0, 0, 0);
}
iiop_th->msg = 0;
iiop_th->size = iiop_th->consumed = 0;
}
}
if (payloadLength > 0 && !inMessage)
{
/* Be sure to allow for non-zero options
*/
giop = (u_char*)tp + 4 * tp->th_off;
if (*((u_int32_t*)giop) == GIOP_MAGIC)
{
iiop_th->msg = 0;
if (snaplen > 80)
{
struct MessageHeader_1_x *header = (struct MessageHeader_1_x *) giop;
struct iiop_msg *msg = NULL;
u_int msg_size = iiop_size (header);
int message_remaining = msg_size - payloadLength + 12;
iiop_th->size = msg_size;
/* Don't count the initial 12 bytes of the iiop header
*/
iiop_th->consumed = payloadLength;
iiop_th->seq = seq + 12;
if (header->messageType == Request)
{
int oneway = is_oneway (header);
msg = calloc (1, sizeof(struct iiop_msg));
msg->first.tv_sec = PacketTimestamp->tv_sec;
msg->first.tv_usec = PacketTimestamp->tv_usec;
msg->last.tv_sec = PacketTimestamp->tv_sec;
msg->last.tv_usec = PacketTimestamp->tv_usec;
msg->hdr = calloc (1, payloadLength);
memcpy (msg->hdr, header, payloadLength);
msg->addr = iiop_th->addr;
msg->nxt = requests;
requests = msg;
iiop_th->msg = msg;
if (message_remaining > 0)
{
PUTS ("<request_begin>");
}
else
{
PUTS ("iiop ");
corba_giop_print (msg->hdr);
PUTS ("00:00:00.0 ");
if (oneway)
{
print_corba_call (msg, 0, 0, 0);
iiop_th->msg = 0;
}
}
}
else if (header->messageType == Reply)
{
if (message_remaining == 0)
{
u_int id;
msg = calloc (1, sizeof(struct iiop_msg));
msg->hdr = calloc (1, payloadLength);
memcpy (msg->hdr, header, payloadLength);
PUTS ("iiop ");
corba_giop_print (msg->hdr);
id = giop_reply_id (msg->hdr);
PUTS ("00:00:00.0 ");
reply_postprint (msg, &iiop_th->addr, id,
(struct timeval*)PacketTimestamp,
(struct timeval*)PacketTimestamp);
free_msg (msg);
}
else
{
msg = calloc (1, sizeof(struct iiop_msg));
msg->first.tv_sec = PacketTimestamp->tv_sec;
msg->first.tv_usec = PacketTimestamp->tv_usec;
msg->hdr = calloc (1, payloadLength);
memcpy (msg->hdr, header, payloadLength);
iiop_th->msg = msg;
PUTS ("<reply_begin>");
}
}
else
{
PUTS ("iiop ");
corba_giop_print (header);
PUTS ("00:00:00.0 ");
}
}
else
{
PUTS ("<iiop_truncated>");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -