if (remote_mtu == 0) remote_mtu = 672;
void parse_arguments(int argc, char **argv, connection_attributes *attrs){	int c;	int option_index = 0;	/* configurable parameters and default values */	sock_family family = PROTO_UNSPECIFIED;	sock_protocol protocol = TCP_PROTOCOL;	address local_address, remote_address;	bool listen_mode = FALSE;	bool file_transfer = FALSE;	bool half_close = FALSE;	int connect_timeout = -1;	int idle_timeout = -1;	bool set_local_hold_timeout = FALSE;	int local_hold_timeout;	bool set_remote_hold_timeout = FALSE;	int remote_hold_timeout;	size_t remote_mtu = 0;	size_t remote_nru = 0;	size_t buffer_size = 0;	size_t sndbuf_size = 0;	size_t rcvbuf_size = 0;	/* check arguments */	assert(argc > 0);	assert(argv != NULL);	assert(*argv != NULL);	assert(attrs != NULL);		/* initialize the addresses of the connection endpoints */	address_init(&remote_address);	address_init(&local_address);	/* set verbosity back to 0 */	_verbosity_level = 0;	/* option recognition loop */	while ((c = getopt_long(argc, argv, "46e:hlnp:q:s:uvw:x" BLUEZ_OPTIONS,	                        long_options, &option_index)) >= 0)	{ 		switch (c) {		case 0:			switch (option_index) {			case OPT_VERSION:				print_version(stdout);				exit(EXIT_SUCCESS);			case OPT_RECV_ONLY:				ca_set_flag(attrs, CA_RECV_DATA_ONLY);				break;			case OPT_SEND_ONLY:				ca_set_flag(attrs, CA_SEND_DATA_ONLY);				break;			case OPT_BUFFER_SIZE:				assert(optarg != NULL);				buffer_size = safe_atoi(optarg);				break;			case OPT_MTU:				assert(optarg != NULL);				remote_mtu = safe_atoi(optarg);				break;			case OPT_NRU:				assert(optarg != NULL);				remote_nru = safe_atoi(optarg);				break;			case OPT_HALF_CLOSE:				half_close = TRUE;				break;			case OPT_DISABLE_NAGLE:				ca_set_flag(attrs, CA_DISABLE_NAGLE);				break;			case OPT_NO_REUSEADDR:				ca_set_flag(attrs, CA_DONT_REUSE_ADDR);				break;			case OPT_SNDBUF_SIZE:				assert(optarg != NULL);				sndbuf_size = safe_atoi(optarg);				break;			case OPT_RCVBUF_SIZE:				assert(optarg != NULL);				rcvbuf_size = safe_atoi(optarg);				break;			case OPT_CONTINUOUS:				ca_set_flag(attrs, CA_CONTINUOUS_ACCEPT);				break;#ifdef ENABLE_BLUEZ			case OPT_SCO:				protocol = SCO_PROTOCOL;				break;#endif			default:				fatal(_("getopt returned unexpected long "				      "option offset index %d\n"), option_index);			}			break;		case '4':			family = PROTO_IPv4;			break;		case '6':				family = PROTO_IPv6;			ca_set_flag(attrs, CA_STRICT_IPV6);			break;#ifdef ENABLE_BLUEZ		case 'b':			family = PROTO_BLUEZ;			protocol = L2CAP_PROTOCOL;			break;#endif		case 'e':			assert(optarg != NULL);			ca_set_local_exec(attrs, optarg);			break;		case 'h':				print_usage(stdout);			exit(EXIT_SUCCESS);		case 'l':			listen_mode = TRUE;			break;		case 'n':				ca_set_flag(attrs, CA_NUMERIC_MODE);			break;		case 'p':				assert(optarg != NULL);			local_address.service = xstrdup(optarg);			break;			case 'q':			assert(optarg != NULL);			switch (parse_int_pair(optarg, &local_hold_timeout,			                       &remote_hold_timeout))			{			case 2: set_remote_hold_timeout = TRUE;			case 1: set_local_hold_timeout = TRUE;			};			break;			case 's':				assert(optarg != NULL);			local_address.address = xstrdup(optarg);			break;			case 't':			assert(optarg != NULL);			idle_timeout = safe_atoi(optarg);			break;		case 'u':				protocol = UDP_PROTOCOL;			/* set remote buffer sizes and mtu's, iff they haven't			 * already been set */			if (remote_mtu == 0)				remote_mtu = DEFAULT_UDP_MTU;			if (remote_nru == 0)				remote_nru = DEFAULT_UDP_NRU;			if (buffer_size == 0)				buffer_size = DEFAULT_UDP_BUFFER_SIZE;			break;		case 'v':				++_verbosity_level;			break;		case 'w':			assert(optarg != NULL);			connect_timeout = safe_atoi(optarg);			break;		case 'x':				file_transfer = TRUE;			break;		case '?':			print_usage(stderr);			exit(EXIT_FAILURE);		default:				fatal(_("getopt returned unexpected character 0%o\n"), c);		}	}		argv += optind;	argc -= optind;	/* set mode flags */	if (listen_mode == TRUE) {		ca_set_flag(attrs, CA_LISTEN_MODE);		ca_clear_flag(attrs, CA_CONNECT_MODE);	} else {		ca_set_flag(attrs, CA_CONNECT_MODE);		ca_clear_flag(attrs, CA_LISTEN_MODE);	}	/* setup file transfer depending on the mode */	if (file_transfer == TRUE) {		if (buffer_size == 0)			buffer_size = DEFAULT_FILE_TRANSFER_BUFFER_SIZE;		if (listen_mode == TRUE) {			ca_set_flag(attrs, CA_RECV_DATA_ONLY);			ca_clear_flag(attrs, CA_SEND_DATA_ONLY);		} else {			ca_set_flag(attrs, CA_SEND_DATA_ONLY);			ca_clear_flag(attrs, CA_RECV_DATA_ONLY);		}	}	/* check nru - if it's too big data will never be received */	if (remote_nru > buffer_size)		remote_nru = buffer_size;	/* check to make sure the user wasn't silly enough to set both	 * --recv-only and --send-only */	if (ca_is_flag_set(attrs, CA_RECV_DATA_ONLY) &&	    ca_is_flag_set(attrs, CA_SEND_DATA_ONLY))	{		fatal(_("Cannot set both --recv-only and --send-only"));	}	/* additional arguments are the remote address/service */	switch (argc) {	case 0:		remote_address.address = NULL;		remote_address.service = NULL;		break;	case 1:		remote_address.address = argv[0];		remote_address.service = NULL;		break;	case 2:		remote_address.address = argv[0];		remote_address.service = argv[1];		break;	default:		print_usage(stderr);		exit(EXIT_FAILURE);	}	/* sanity checks */	if (remote_address.address != NULL && 	    strlen(remote_address.address) == 0)	{		remote_address.address = NULL;	}	if (remote_address.service != NULL &&	    strlen(remote_address.service) == 0)	{		remote_address.service = NULL;	}		switch (family) {		case PROTO_UNSPECIFIED:		case PROTO_IPv4:		case PROTO_IPv6:			if (protocol != UDP_PROTOCOL && 			    protocol != TCP_PROTOCOL)				fatal("unknown/unsupported transport protocol selected");			break;#ifdef ENABLE_BLUEZ		case PROTO_BLUEZ:			if (protocol != SCO_PROTOCOL && 			    protocol != L2CAP_PROTOCOL)				fatal("unknown/unsupported bluez protocol selected");			break;#endif		default:			fatal("unknown/unsupported transport protocol selected");	}		if (listen_mode == TRUE) {#ifdef ENABLE_BLUEZ		/* it is ok not to specify a port with sco */		if (local_address.service == NULL && protocol != SCO_PROTOCOL) {#else		if (local_address.service == NULL) {#endif			warning(_("in listen mode you must specify a port "			          "with the -p switch"));			print_usage(stderr);			exit(EXIT_FAILURE);		}		if (ca_is_flag_set(attrs, CA_CONTINUOUS_ACCEPT) &&		    ca_local_exec(attrs) == NULL)		{			warning(_("--continuous option "			       "must be used with --exec"));			print_usage(stderr);			exit(EXIT_FAILURE);		}	} else {		if (ca_is_flag_set(attrs, CA_DONT_REUSE_ADDR)) {			warning(_("--no-reuseaddr option "			       "can be used only in listen mode"));			print_usage(stderr);			exit(EXIT_FAILURE);		}		if (ca_is_flag_set(attrs, CA_CONTINUOUS_ACCEPT)) {			warning(_("--continuous option "			       "can be used only in listen mode"));			print_usage(stderr);			exit(EXIT_FAILURE);		}		#ifdef ENABLE_BLUEZ		/* it is ok not to specify a port with sco */		if (remote_address.address == NULL || 		    (remote_address.service == NULL && protocol != SCO_PROTOCOL))#else		if (remote_address.address == NULL || 		    remote_address.service == NULL)#endif		{			warning(_("you must specify the address/port couple "			       "of the remote endpoint"));			print_usage(stderr);			exit(EXIT_FAILURE);		}	}	/* setup attrs */	ca_set_family(attrs, family);	ca_set_protocol(attrs, protocol);	ca_set_remote_addr(attrs, remote_address);	ca_set_local_addr(attrs, local_address);	/* setup connection timeout */	if (connect_timeout != -1)		ca_set_connect_timeout(attrs, connect_timeout);	/* setup idle timeout */	if (idle_timeout != -1)		ca_set_idle_timeout(attrs, idle_timeout);		/* setup half close mode */	if (half_close == TRUE) {		/* keep remote open after half close */		ca_set_remote_half_close_suppress(attrs, FALSE);		ca_set_remote_hold_timeout(attrs, -1);	}	/* setup hold timeout */	if (set_remote_hold_timeout == TRUE)		ca_set_remote_hold_timeout(attrs, remote_hold_timeout);	if (set_local_hold_timeout == TRUE)		ca_set_local_hold_timeout(attrs, local_hold_timeout);		/* setup mtu, nru, and buffer sizes if they were specified */	if (remote_mtu > 0)		ca_set_remote_MTU(attrs, remote_mtu);	if (remote_nru > 0)		ca_set_remote_NRU(attrs, remote_nru);	if (buffer_size > 0)		ca_set_buffer_size(attrs, buffer_size);	if (sndbuf_size > 0)		ca_set_sndbuf_size(attrs, sndbuf_size);	if (rcvbuf_size > 0)		ca_set_rcvbuf_size(attrs, rcvbuf_size);}