예제 #1
0
/* Saves the target into in parsable form to stdout. */
static void
save(const struct ipt_ip *ip, const struct ipt_entry_target *target)
{
	const struct ipt_connmark_target_info *markinfo =
		(const struct ipt_connmark_target_info *)target->data;

	switch (markinfo->mode) {
	case IPT_CONNMARK_SET:
	    printf("--set-mark ");
	    print_mark(markinfo->mark);
	    print_mask("/", markinfo->mask);
	    printf(" ");
	    break;
	case IPT_CONNMARK_SAVE:
	    printf("--save-mark ");
	    print_mask("--mask ", markinfo->mask);
	    break;
	case IPT_CONNMARK_RESTORE:
	    printf("--restore-mark ");
	    print_mask("--mask ", markinfo->mask);
	    break;
	default:
	    printf("ERROR: UNKNOWN CONNMARK MODE ");
	    break;
	}
}
예제 #2
0
/* Prints out the target info. */
static void
print(const struct ipt_ip *ip,
      const struct ipt_entry_target *target,
      int numeric)
{
	const struct ipt_connmark_target_info *markinfo =
		(const struct ipt_connmark_target_info *)target->data;
	switch (markinfo->mode) {
	case IPT_CONNMARK_SET:
	case IPT_CONNMARK_SET_RETURN:
	    printf("CONNMARK set%s ", (markinfo->mode == IPT_CONNMARK_SET_RETURN) ? "-return" : "");

//	    printf("CONNMARK set ");
	    print_mark(markinfo->mark);
	    print_mask("/", markinfo->mask);
	    printf(" ");
	    break;
	case IPT_CONNMARK_SAVE:
	    printf("CONNMARK save ");
	    print_mask("mask ", markinfo->mask);
	    printf(" ");
	    break;
	case IPT_CONNMARK_RESTORE:
	    printf("CONNMARK restore ");
	    print_mask("mask ", markinfo->mask);
	    break;
	default:
	    printf("ERROR: UNKNOWN CONNMARK MODE ");
	    break;
	}
}
/* Prints out the target info. */
static void CONNMARK_print(const void *ip,
                           const struct xt_entry_target *target, int numeric)
{
	const struct xt_connmark_target_info *markinfo =
		(const struct xt_connmark_target_info *)target->data;
	switch (markinfo->mode) {
	case XT_CONNMARK_SET:
	    printf("CONNMARK set ");
	    print_mark(markinfo->mark);
	    print_mask("/", markinfo->mask);
	    printf(" ");
	    break;
	case XT_CONNMARK_SAVE:
	    printf("CONNMARK save ");
	    print_mask("mask ", markinfo->mask);
	    printf(" ");
	    break;
	case XT_CONNMARK_RESTORE:
	    printf("CONNMARK restore ");
	    print_mask("mask ", markinfo->mask);
	    break;
	default:
	    printf("ERROR: UNKNOWN CONNMARK MODE ");
	    break;
	}
}
예제 #4
0
/** Sends and receives data via sockets.
 *
 * Each datagram is sent and a reply read consequently.
 * The next datagram is sent after the reply is received.
 *
 * @param[in] verbose A value indicating whether to print out verbose information.
 * @param[in] socket_ids A field of stored socket identifiers.
 * @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
 * @param[in,out] address The destination host address to send data to. The source host address of received datagrams is set instead.
 * @param[in] addrlen The length of the destination address in bytes.
 * @param[in,out] data The data to be sent. The received data are set instead.
 * @param[in] size The data size in bytes.
 * @param[in] messages The number of datagrams per socket to be received.
 * @return EOK on success.
 * @return Other error codes as defined for the recvfrom() function.
 */
int sockets_sendto_recvfrom(int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t *addrlen, char *data, int size, int messages)
{
	int value;
	int index;
	int message;
	int rc;

	if (verbose)
		printf("\tSendto and recvfrom\t");

	fflush(stdout);
	
	for (index = 0; index < sockets; index++) {
		for (message = 0; message < messages; message++) {
			rc = sendto(socket_ids[index], data, size, 0, address, *addrlen);
			if (rc != EOK) {
				printf("Socket %d (%d), message %d error:\n", index, socket_ids[index], message);
				socket_print_error(stderr, rc, "Socket send: ", "\n");
				return rc;
			}
			value = recvfrom(socket_ids[index], data, size, 0, address, addrlen);
			if (value < 0) {
				printf("Socket %d (%d), message %d error:\n", index, socket_ids[index], message);
				socket_print_error(stderr, value, "Socket receive: ", "\n");
				return value;
			}
		}
		if (verbose)
			print_mark(index);
	}
	
	return EOK;
}
예제 #5
0
/* Saves the union ipt_matchinfo in parsable form to stdout. */
static void
save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
{
	printf("--mark ");
	print_mark(((struct ipt_connmark_info *)match->data)->mark,
		  ((struct ipt_connmark_info *)match->data)->mask,
		  ((struct ipt_connmark_info *)match->data)->invert, 0);
}
예제 #6
0
static void MARK_print_v0(const void *ip,
                          const struct xt_entry_target *target, int numeric)
{
	const struct xt_mark_target_info *markinfo =
		(const struct xt_mark_target_info *)target->data;
	printf("MARK set ");
	print_mark(markinfo->mark);
}
예제 #7
0
static void MARK_save_v0(const void *ip, const struct xt_entry_target *target)
{
	const struct xt_mark_target_info *markinfo =
		(const struct xt_mark_target_info *)target->data;

	printf("--set-mark ");
	print_mark(markinfo->mark);
}
예제 #8
0
/* Saves the union ipt_targinfo in parsable form to stdout. */
static void
save(const struct ip6t_ip6 *ip, const struct ip6t_entry_target *target)
{
	const struct ip6t_mark_target_info *markinfo =
		(const struct ip6t_mark_target_info *)target->data;

	printf("--set-mark ");
	print_mark(markinfo->mark);
}
예제 #9
0
static void
connmark_print(const void *ip, const struct xt_entry_match *match, int numeric)
{
	const struct xt_connmark_info *info = (const void *)match->data;

	printf(" CONNMARK match ");
	if (info->invert)
		printf("!");
	print_mark(info->mark, info->mask);
}
예제 #10
0
/* Prints out the matchinfo. */
static void
print(const struct ipt_ip *ip,
      const struct ipt_entry_match *match,
      int numeric)
{
	printf("CONNMARK match ");
	print_mark(((struct ipt_connmark_info *)match->data)->mark,
		  ((struct ipt_connmark_info *)match->data)->mask,
		  ((struct ipt_connmark_info *)match->data)->invert, numeric);
}
예제 #11
0
static void mark_mt_save(const void *ip, const struct xt_entry_match *match)
{
	const struct xt_mark_mtinfo1 *info = (const void *)match->data;

	if (info->invert)
		printf("! ");

	printf("--mark ");
	print_mark(info->mark, info->mask);
}
예제 #12
0
static void
mark_mt_print(const void *ip, const struct xt_entry_match *match, int numeric)
{
	const struct xt_mark_mtinfo1 *info = (const void *)match->data;

	printf("mark match ");
	if (info->invert)
		printf("!");
	print_mark(info->mark, info->mask);
}
예제 #13
0
/* Saves the matchinfo in parsable form to stdout. */
static void
save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match)
{
	struct ipt_connmark_info *info = (struct ipt_connmark_info *)match->data;

	if (info->invert)
		printf("! ");

	printf("--mark ");
	print_mark(info->mark, info->mask, 0);
}
예제 #14
0
/* Prints out the targinfo. */
static void
print(const struct ip6t_ip6 *ip,
      const struct ip6t_entry_target *target,
      int numeric)
{
	const struct ip6t_mark_target_info *markinfo =
		(const struct ip6t_mark_target_info *)target->data;

	printf("MARK set ");
	print_mark(markinfo->mark);
}
예제 #15
0
/* Prints out the matchinfo. */
static void
print(const struct ip6t_ip6 *ip,
      const struct ip6t_entry_match *match,
      int numeric)
{
	struct ipt_connmark_info *info = (struct ipt_connmark_info *)match->data;

	printf("CONNMARK match ");
	if (info->invert)
		printf("!");
	print_mark(info->mark, info->mask, numeric);
}
예제 #16
0
static void MARK_save_v1(const void *ip, const struct xt_entry_target *target)
{
	const struct xt_mark_target_info_v1 *markinfo =
		(const struct xt_mark_target_info_v1 *)target->data;

	switch (markinfo->mode) {
	case XT_MARK_SET:
		printf("--set-mark ");
		break;
	case XT_MARK_AND:
		printf("--and-mark ");
		break;
	case XT_MARK_OR: 
		printf("--or-mark ");
		break;
	}
	print_mark(markinfo->mark);
}
예제 #17
0
static void MARK_print_v1(const void *ip, const struct xt_entry_target *target,
                          int numeric)
{
	const struct xt_mark_target_info_v1 *markinfo =
		(const struct xt_mark_target_info_v1 *)target->data;

	switch (markinfo->mode) {
	case XT_MARK_SET:
		printf("MARK set ");
		break;
	case XT_MARK_AND:
		printf("MARK and ");
		break;
	case XT_MARK_OR: 
		printf("MARK or ");
		break;
	}
	print_mark(markinfo->mark);
}
예제 #18
0
/** Connects sockets.
 *
 * @param[in] verbose A value indicating whether to print out verbose information.
 * @param[in] socket_ids A field of stored socket identifiers.
 * @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
 * @param[in] address The destination host address to connect to.
 * @param[in] addrlen The length of the destination address in bytes.
 * @return EOK on success.
 * @return Other error codes as defined for the connect() function.
 */
int sockets_connect(int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t addrlen)
{
	int index;
	int rc;

	if (verbose)
		printf("\tConnect\t");
	
	fflush(stdout);
	
	for (index = 0; index < sockets; index++) {
		rc = connect(socket_ids[index], address, addrlen);
		if (rc != EOK) {
			socket_print_error(stderr, rc, "Socket connect: ", "\n");
			return rc;
		}
		if (verbose)
			print_mark(index);
	}
	
	return EOK;
}
예제 #19
0
/** Creates new sockets.
 *
 * @param[in] verbose A value indicating whether to print out verbose information.
 * @param[out] socket_ids A field to store the socket identifiers.
 * @param[in] sockets The number of sockets to create. Should be at most the size of the field.
 * @param[in] family The socket address family.
 * @param[in] type The socket type.
 * @return EOK on success.
 * @return Other error codes as defined for the socket() function.
 */
int sockets_create(int verbose, int *socket_ids, int sockets, int family, sock_type_t type)
{
	int index;

	if (verbose)
		printf("Create\t");
		
	fflush(stdout);
	
	for (index = 0; index < sockets; index++) {
		socket_ids[index] = socket(family, type, 0);
		if (socket_ids[index] < 0) {
			printf("Socket %d (%d) error:\n", index, socket_ids[index]);
			socket_print_error(stderr, socket_ids[index], "Socket create: ", "\n");
			return socket_ids[index];
		}
		if (verbose)
			print_mark(index);
	}
	
	return EOK;
}
예제 #20
0
/** Closes sockets.
 *
 * @param[in] verbose A value indicating whether to print out verbose information.
 * @param[in] socket_ids A field of stored socket identifiers.
 * @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
 * @return EOK on success.
 * @return Other error codes as defined for the closesocket() function.
 */
int sockets_close(int verbose, int *socket_ids, int sockets)
{
	int index;
	int rc;

	if (verbose)
		printf("\tClose\t");

	fflush(stdout);
	
	for (index = 0; index < sockets; index++) {
		rc = closesocket(socket_ids[index]);
		if (rc != EOK) {
			printf("Socket %d (%d) error:\n", index, socket_ids[index]);
			socket_print_error(stderr, rc, "Socket close: ", "\n");
			return rc;
		}
		if (verbose)
			print_mark(index);
	}
	
	return EOK;
}
예제 #21
0
파일: box.c 프로젝트: syntheticpp/cpptex
void tex::show_mark(ptr p)
	{
	print_esc("mark");
	print_mark(mark_ptr(p));
	}