log & decode socket objects
Dave Jones
7 years ago
16 | 16 |
#include "sanitise.h"
|
17 | 17 |
#include "shm.h"
|
18 | 18 |
#include "trinity.h"
|
|
19 |
#include "udp.h"
|
19 | 20 |
#include "uid.h"
|
20 | 21 |
#include "utils.h"
|
21 | 22 |
|
|
407 | 408 |
static void socket_dump(struct object *obj, __unused__ bool global)
|
408 | 409 |
{
|
409 | 410 |
struct socketinfo *si = &obj->sockinfo;
|
|
411 |
struct msg_objcreatedsocket objmsg;
|
410 | 412 |
|
411 | 413 |
output(0, "socket fd:%d domain:%u (%s) type:0x%u protocol:%u\n",
|
412 | 414 |
si->fd, si->triplet.family, get_domain_name(si->triplet.family),
|
413 | 415 |
si->triplet.type, si->triplet.protocol);
|
|
416 |
|
|
417 |
init_msgobjhdr(&objmsg.hdr, OBJ_CREATED_SOCKET, global, obj);
|
|
418 |
objmsg.si.fd = si->fd;
|
|
419 |
objmsg.si.triplet.family = si->triplet.family;
|
|
420 |
objmsg.si.triplet.type = si->triplet.type;
|
|
421 |
objmsg.si.triplet.protocol = si->triplet.protocol;
|
|
422 |
sendudp((char *) &objmsg, sizeof(objmsg));
|
414 | 423 |
}
|
415 | 424 |
|
416 | 425 |
static int open_sockets(void)
|
4 | 4 |
#include "exit.h"
|
5 | 5 |
#include "maps.h"
|
6 | 6 |
#include "pathnames.h"
|
|
7 |
#include "socketinfo.h"
|
7 | 8 |
#include "types.h"
|
8 | 9 |
|
9 | 10 |
#define TRINITY_LOG_PORT 6665
|
|
34 | 35 |
OBJ_CREATED_USERFAULT,
|
35 | 36 |
OBJ_CREATED_FANOTIFY,
|
36 | 37 |
OBJ_CREATED_BPFMAP,
|
|
38 |
OBJ_CREATED_SOCKET,
|
37 | 39 |
|
38 | 40 |
MAX_LOGMSGTYPE,
|
39 | 41 |
};
|
|
181 | 183 |
int map_type;
|
182 | 184 |
int map_fd;
|
183 | 185 |
};
|
|
186 |
|
|
187 |
struct msg_objcreatedsocket {
|
|
188 |
struct trinity_msgobjhdr hdr;
|
|
189 |
struct socketinfo si;
|
|
190 |
};
|
7 | 7 |
#include <unistd.h>
|
8 | 8 |
#include "decode.h"
|
9 | 9 |
#include "exit.h"
|
|
10 |
#include "socketinfo.h"
|
10 | 11 |
#include "trinity.h"
|
11 | 12 |
#include "types.h"
|
12 | 13 |
#include "udp.h"
|
|
245 | 246 |
objmsg->hdr.global ? "local" : "global",
|
246 | 247 |
objmsg->hdr.address, objmsg->hdr.pid, objmsg->map_fd,
|
247 | 248 |
bpfmaptypes[objmsg->map_type]);
|
|
249 |
}
|
|
250 |
|
|
251 |
static void decode_obj_created_socket(void)
|
|
252 |
{
|
|
253 |
struct msg_objcreatedsocket *objmsg;
|
|
254 |
objmsg = (struct msg_objcreatedsocket *) &buf;
|
|
255 |
|
|
256 |
printf("%s socket object created at %p by pid %d: fd:%d family:%d type:%d protocol:%d\n",
|
|
257 |
objmsg->hdr.global ? "local" : "global",
|
|
258 |
objmsg->hdr.address, objmsg->hdr.pid, objmsg->si.fd,
|
|
259 |
objmsg->si.triplet.family,
|
|
260 |
objmsg->si.triplet.type,
|
|
261 |
objmsg->si.triplet.protocol);
|
248 | 262 |
}
|
249 | 263 |
|
250 | 264 |
|
|
268 | 282 |
[OBJ_CREATED_USERFAULT] = { decode_obj_created_userfault },
|
269 | 283 |
[OBJ_CREATED_FANOTIFY] = { decode_obj_created_fanotify },
|
270 | 284 |
[OBJ_CREATED_BPFMAP] = { decode_obj_created_bpfmap },
|
|
285 |
[OBJ_CREATED_SOCKET] = { decode_obj_created_socket },
|
271 | 286 |
};
|