int dump_socket(struct fd_parms *p, int lfd, struct cr_img *img) { int family; const struct fdtype_ops *ops; if (dump_opt(lfd, SOL_SOCKET, SO_DOMAIN, &family)) return -1; switch (family) { case AF_UNIX: ops = &unix_dump_ops; break; case AF_INET: ops = &inet_dump_ops; break; case AF_INET6: ops = &inet6_dump_ops; break; case AF_PACKET: ops = &packet_dump_ops; break; case AF_NETLINK: ops = &netlink_dump_ops; break; default: pr_err("BUG! Unknown socket collected (family %d)\n", family); return -1; } return do_dump_gen_file(p, lfd, ops, img); }
void vm_pars(int ac, char **av, t_cycles *cycles, t_champ **champs) { int i; i = 1; while (i < ac) { i = dump_opt(i, ac, av, cycles); i = a_opt(i, ac, av, champs); i = n_opt(i, ac, av, champs); i = get_cor(i, ac, av, champs); i++; } }
static int refresh_inet_sk(struct inet_sk_desc *sk) { int size; struct tcp_info info; if (dump_opt(sk->rfd, SOL_TCP, TCP_INFO, &info)) { pr_perror("Failed to obtain TCP_INFO"); return -1; } switch (info.tcpi_state) { case TCP_ESTABLISHED: case TCP_CLOSE: break; default: pr_err("Unknown state %d\n", sk->state); return -1; } if (ioctl(sk->rfd, SIOCOUTQ, &size) == -1) { pr_perror("Unable to get size of snd queue"); return -1; } sk->wqlen = size; if (ioctl(sk->rfd, SIOCOUTQNSD, &size) == -1) { pr_perror("Unable to get size of unsent data"); return -1; } sk->uwqlen = size; if (ioctl(sk->rfd, SIOCINQ, &size) == -1) { pr_perror("Unable to get size of recv queue"); return -1; } sk->rqlen = size; return 0; }
void dump_comp (gpgme_conf_comp_t comp) { gpgme_conf_opt_t opt; printf ("COMPONENT\n"); printf ("=========\n"); printf (" Name: %s\n", comp->name); if (comp->description) printf (" Desc: %s\n", comp->description); if (comp->program_name) printf (" Path: %s\n", comp->program_name); printf ("\n"); opt = comp->options; while (opt) { dump_opt (opt); opt = opt->next; } }
void dump_opt (gpgme_conf_opt_t opt) { char level; char runtime = (opt->flags & GPGME_CONF_RUNTIME) ? 'r' : ' '; switch (opt->level) { case GPGME_CONF_BASIC: level = 'b'; break; case GPGME_CONF_ADVANCED: level = 'a'; break; case GPGME_CONF_EXPERT: level = 'e'; break; case GPGME_CONF_INVISIBLE: level = 'i'; break; case GPGME_CONF_INTERNAL: level = '#'; break; default: level = '?'; } if (opt->flags & GPGME_CONF_GROUP) { printf ("\n"); printf ("%c%c [%s]%s%s\n", level, runtime, opt->name, spaces (opt->name, 5), opt->description ? opt->description : ""); } else { if (opt->argname) { char *more = (opt->flags & GPGME_CONF_LIST) ? "..." : ""; if (opt->flags & GPGME_CONF_OPTIONAL) { printf ("%c%c --%s [%s%s] %s", level, runtime, opt->name, opt->argname, more, spaces (opt->name, 9 + strlen (opt->argname) + strlen (more))); } else { printf ("%c%c --%s %s%s %s", level, runtime, opt->name, opt->argname, more, spaces (opt->name, 7 + strlen (opt->argname) + strlen (more))); } } else printf ("%c%c --%s%s", level, runtime, opt->name, spaces (opt->name, 5)); if (opt->description) printf ("%s", opt->description); printf ("\n"); if (opt->flags & GPGME_CONF_DEFAULT) { printf ("%s%s = ", spaces (NULL, 0), opt->argname ? opt->argname : "(default)"); dump_arg (opt->type, opt->default_value); printf ("\n"); } else if (opt->flags & GPGME_CONF_DEFAULT_DESC) printf ("%s%s = %s\n", spaces (NULL, 0), opt->argname ? opt->argname : "(default)", opt->default_description); if (opt->no_arg_value) { printf ("%sNo Arg Def = ", spaces (NULL, 0)); dump_arg (opt->type, opt->no_arg_value); printf ("\n"); } if (opt->value) { printf ("%sCurrent = ", spaces (NULL, 0)); dump_arg (opt->type, opt->value); printf ("\n"); } } #if 0 arg = comp->options; while (opt) { dump_opt (opt); opt = opt->next; } #endif }
int dump_socket_opts(int sk, SkOptsEntry *soe) { int ret = 0, val; struct timeval tv; ret |= dump_opt(sk, SOL_SOCKET, SO_SNDBUF, &soe->so_sndbuf); ret |= dump_opt(sk, SOL_SOCKET, SO_RCVBUF, &soe->so_rcvbuf); soe->has_so_priority = true; ret |= dump_opt(sk, SOL_SOCKET, SO_PRIORITY, &soe->so_priority); soe->has_so_rcvlowat = true; ret |= dump_opt(sk, SOL_SOCKET, SO_RCVLOWAT, &soe->so_rcvlowat); soe->has_so_mark = true; ret |= dump_opt(sk, SOL_SOCKET, SO_MARK, &soe->so_mark); ret |= dump_opt(sk, SOL_SOCKET, SO_SNDTIMEO, &tv); soe->so_snd_tmo_sec = tv.tv_sec; soe->so_snd_tmo_usec = tv.tv_usec; ret |= dump_opt(sk, SOL_SOCKET, SO_RCVTIMEO, &tv); soe->so_rcv_tmo_sec = tv.tv_sec; soe->so_rcv_tmo_usec = tv.tv_usec; ret |= dump_opt(sk, SOL_SOCKET, SO_REUSEADDR, &val); soe->reuseaddr = val ? true : false; soe->has_reuseaddr = true; ret |= dump_opt(sk, SOL_SOCKET, SO_PASSCRED, &val); soe->has_so_passcred = true; soe->so_passcred = val ? true : false; ret |= dump_opt(sk, SOL_SOCKET, SO_PASSSEC, &val); soe->has_so_passsec = true; soe->so_passsec = val ? true : false; ret |= dump_opt(sk, SOL_SOCKET, SO_DONTROUTE, &val); soe->has_so_dontroute = true; soe->so_dontroute = val ? true : false; ret |= dump_opt(sk, SOL_SOCKET, SO_NO_CHECK, &val); soe->has_so_no_check = true; soe->so_no_check = val ? true : false; ret |= dump_bound_dev(sk, soe); ret |= dump_socket_filter(sk, soe); return ret; }
static int dump_tcp_conn_state(struct inet_sk_desc *sk) { int ret, img_fd, aux; TcpStreamEntry tse = TCP_STREAM_ENTRY__INIT; char *in_buf, *out_buf; /* * Read queue */ pr_info("Reading inq for socket\n"); tse.inq_len = sk->rqlen; ret = tcp_stream_get_queue(sk->rfd, TCP_RECV_QUEUE, &tse.inq_seq, tse.inq_len, &in_buf); if (ret < 0) goto err_in; /* * Write queue */ pr_info("Reading outq for socket\n"); tse.outq_len = sk->wqlen; tse.unsq_len = sk->uwqlen; tse.has_unsq_len = true; ret = tcp_stream_get_queue(sk->rfd, TCP_SEND_QUEUE, &tse.outq_seq, tse.outq_len, &out_buf); if (ret < 0) goto err_out; /* * Initial options */ pr_info("Reading options for socket\n"); ret = tcp_stream_get_options(sk->rfd, &tse); if (ret < 0) goto err_opt; /* * TCP socket options */ if (dump_opt(sk->rfd, SOL_TCP, TCP_NODELAY, &aux)) goto err_opt; if (aux) { tse.has_nodelay = true; tse.nodelay = true; } if (dump_opt(sk->rfd, SOL_TCP, TCP_CORK, &aux)) goto err_opt; if (aux) { tse.has_cork = true; tse.cork = true; } /* * Push the stuff to image */ img_fd = open_image(CR_FD_TCP_STREAM, O_DUMP, sk->sd.ino); if (img_fd < 0) goto err_img; ret = pb_write_one(img_fd, &tse, PB_TCP_STREAM); if (ret < 0) goto err_iw; if (in_buf) { ret = write_img_buf(img_fd, in_buf, tse.inq_len); if (ret < 0) goto err_iw; } if (out_buf) { ret = write_img_buf(img_fd, out_buf, tse.outq_len); if (ret < 0) goto err_iw; } pr_info("Done\n"); err_iw: close(img_fd); err_img: err_opt: xfree(out_buf); err_out: xfree(in_buf); err_in: return ret; }