tracedump
single application IP packet sniffer
Enumerations | Functions

inject.h File Reference

#include <stdbool.h>
#include <stdint.h>
#include <sys/socket.h>
#include <linux/net.h>
#include <netinet/in.h>
#include <sys/user.h>
#include <libpjf/lib.h>
#include "tracedump.h"

Go to the source code of this file.

Enumerations

enum  arg_type { AT_LAST = 0, AT_VALUE, AT_MEM_IN, AT_MEM_INOUT }
 

Argument type used in _inject_socketcall.

More...

Functions

void inject_escape_socketcall (struct tracedump *td, struct pid *sp)
 Circumvent an on-going socketcall.
void inject_restore_socketcall (struct tracedump *td, struct pid *sp)
 Cancel inject_escape_socketcall() effects.
int32_t inject_socketcall (struct tracedump *td, struct pid *sp, uint32_t sc_code,...)
 Inject socketcall() into running process.
static int inject_autobind (struct tracedump *td, struct pid *sp, int fd)
 Inject bind(fd, {AF_INET, INADDR_ANY, .port = 0}, 16)
static int inject_getsockname_in (struct tracedump *td, struct pid *sp, int fd, struct sockaddr_in *sa)
 Inject getsockname(fd, sa, 16)
static int inject_getsockopt (struct tracedump *td, struct pid *sp, int fd, int level, int optname, void *optval, socklen_t *optlen)
 Inject getsockopt()

Enumeration Type Documentation

enum arg_type

Argument type used in _inject_socketcall.

Enumerator:
AT_LAST 

it was the last argument

AT_VALUE 

pass the value

AT_MEM_IN 

memory buffer: an input

AT_MEM_INOUT 

memory buffer: an input and an output

Definition at line 35 of file inject.h.


Function Documentation

static int inject_autobind ( struct tracedump td,
struct pid sp,
int  fd 
) [inline, static]

Inject bind(fd, {AF_INET, INADDR_ANY, .port = 0}, 16)

Definition at line 59 of file inject.h.

Referenced by handle_socket().

void inject_escape_socketcall ( struct tracedump td,
struct pid sp 
)

Circumvent an on-going socketcall.

Implemented by calling socketcall with an invalid subcode, which will result in an -EINVAL. This will put the traced process in normal state, ie. executing the code under EIP, which is required for the inject_*() functions to work properly.

Definition at line 133 of file inject.c.

Referenced by handle_socket().

static int inject_getsockname_in ( struct tracedump td,
struct pid sp,
int  fd,
struct sockaddr_in *  sa 
) [inline, static]

Inject getsockname(fd, sa, 16)

Return values:
-2socket not AF_INET

Definition at line 76 of file inject.h.

Referenced by handle_socket().

static int inject_getsockopt ( struct tracedump td,
struct pid sp,
int  fd,
int  level,
int  optname,
void *  optval,
socklen_t *  optlen 
) [inline, static]

Inject getsockopt()

Definition at line 94 of file inject.h.

Referenced by handle_socket().

void inject_restore_socketcall ( struct tracedump td,
struct pid sp 
)

Cancel inject_escape_socketcall() effects.

This function will execute the whole socketcall until it finishes

Definition at line 151 of file inject.c.

Referenced by handle_socket().

int32_t inject_socketcall ( struct tracedump td,
struct pid sp,
uint32_t  sc_code,
  ... 
)

Inject socketcall() into running process.

Supports variable list of arguments to socketcall(), each may be of different kind

Parameters:
tdtracedump root
pidprocess id
sc_codesocketcall subcode (see include/linux/net.h)
varg1enum arg_type
varg2uint32_t: memory size or a value
varg3OPTIONAL void *: address of the memory
...
1,0,1
Returns:
socketcall() return code

Definition at line 16 of file inject.c.

Referenced by inject_autobind(), inject_getsockname_in(), and inject_getsockopt().

 All Data Structures Files Functions Variables Enumerations Enumerator Defines