case AF_NETROM: if (address[0] == NULL) { fprintf(stderr, "call: too few arguments for NET/ROM\n"); return (-1); } if ((fd = socket(AF_NETROM, SOCK_SEQPACKET, 0)) < 0) { perror("socket"); return (-1); } ax25_aton(nr_config_get_addr(port), &sockaddr.ax25); sockaddr.ax25.fsa_ax25.sax25_family = AF_NETROM; addrlen = sizeof(struct full_sockaddr_ax25); break;  case AF_AX25: if (address[0] == NULL) { fprintf(stderr, "call: too few arguments for AX.25\n"); return (-1); } if ((fd = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) { perror("socket"); return (-1); } ax25_aton(ax25_config_get_addr(port), &sockaddr.ax25); if (sockaddr.ax25.fsa_ax25.sax25_ndigis == 0) { ax25_aton_entry(ax25_config_get_addr(port), sockaddr.ax25.fsa_digipeater[0].ax25_call); sockaddr.ax25.fsa_ax25.sax25_ndigis = 1; } sockaddr.ax25.fsa_ax25.sax25_family = AF_AX25; addrlen = sizeof(struct full_sockaddr_ax25);  if (setsockopt(fd, SOL_AX25, AX25_WINDOW, &window, sizeof(window)) == -1) { perror("AX25_WINDOW"); close(fd); return (-1); } if (setsockopt(fd, SOL_AX25, AX25_PACLEN, &paclen, sizeof(paclen)) == -1) { perror("AX25_PACLEN"); close(fd); return (-1); } if (backoff != -1) { if (setsockopt(fd, SOL_AX25, AX25_BACKOFF, &backoff, sizeof(backoff)) == -1) { perror("AX25_BACKOFF");
if (debug && setsockopt(fd, SOL_SOCKET, SO_DEBUG, &one, sizeof(one)) == -1) { perror("SO_DEBUG");
static int connect_to(char *address[]){    int fd = 0;    int addrlen = 0;    union {	struct full_sockaddr_ax25 ax25;	struct sockaddr_rose rose;    } sockaddr;    char *digi;    int one = debug;    switch (af_mode) {    case AF_ROSE:	if (address[0] == NULL || address[1] == NULL) {	    fprintf(stderr, "call: too few arguments for Rose\n");	    return (-1);	}	if ((fd = socket(AF_ROSE, SOCK_SEQPACKET, 0)) < 0) {	    perror("socket");	    return (-1);	}	break;    case AF_NETROM:	if (address[0] == NULL) {	    fprintf(stderr, "call: too few arguments for NET/ROM\n");	    return (-1);	}	if ((fd = socket(AF_NETROM, SOCK_SEQPACKET, 0)) < 0) {	    perror("socket");	    return (-1);	}	ax25_aton(nr_config_get_addr(port), &sockaddr.ax25);	sockaddr.ax25.fsa_ax25.sax25_family = AF_NETROM;	addrlen = sizeof(struct full_sockaddr_ax25);	break;    case AF_AX25:	if (address[0] == NULL) {	    fprintf(stderr, "call: too few arguments for AX.25\n");	    return (-1);	}	if ((fd = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) {	    perror("socket");	    return (-1);	}	ax25_aton(ax25_config_get_addr(port), &sockaddr.ax25);	if (sockaddr.ax25.fsa_ax25.sax25_ndigis == 0) {		ax25_aton_entry(ax25_config_get_addr(port),		        sockaddr.ax25.fsa_digipeater[0].ax25_call);		sockaddr.ax25.fsa_ax25.sax25_ndigis = 1;	}	sockaddr.ax25.fsa_ax25.sax25_family = AF_AX25;	addrlen = sizeof(struct full_sockaddr_ax25);	if (setsockopt(fd, SOL_AX25, AX25_WINDOW, &window, sizeof(window)) == -1) {	    perror("AX25_WINDOW");	    close(fd);	    return (-1);	}	if (setsockopt(fd, SOL_AX25, AX25_PACLEN, &paclen, sizeof(paclen)) == -1) {	    perror("AX25_PACLEN");	    close(fd);	    return (-1);	}	if (backoff != -1) {	    if (setsockopt(fd, SOL_AX25, AX25_BACKOFF, &backoff, sizeof(backoff)) == -1) {		perror("AX25_BACKOFF");		close(fd);		return (-1);	    }	}	if (ax25mode != -1) {	    if (setsockopt(fd, SOL_AX25, AX25_EXTSEQ, &ax25mode, sizeof(ax25mode)) == -1) {		perror("AX25_EXTSEQ");		close(fd);		return (-1);	    }	}	break;    }    if (debug && setsockopt(fd, SOL_SOCKET, SO_DEBUG, &one, sizeof(one)) == -1) {	perror("SO_DEBUG");	close(fd);	return (-1);    }    if (af_mode != AF_ROSE) {	/* Let Rose autobind */	if (bind(fd, (struct sockaddr *) &sockaddr, addrlen) == -1) {	    perror("bind");	    close(fd);	    return (-1);	}    }    switch (af_mode) {    case AF_ROSE:	memset(&sockaddr.rose, 0x00, sizeof(struct sockaddr_rose));	if (ax25_aton_entry(address[0], sockaddr.rose.srose_call.ax25_call) == -1) {	    close(fd);	    return (-1);	}	if (rose_aton(address[1], sockaddr.rose.srose_addr.rose_addr) == -1) {	    close(fd);	    return (-1);	}	if (address[2] != NULL) {	    digi = address[2];	    if (strcasecmp(address[2], "VIA") == 0) {		if (address[3] == NULL) {		    fprintf(stderr, "call: callsign must follow 'via'\n");		    close(fd);		    return (-1);		}		digi = address[3];	    }	    if (ax25_aton_entry(digi, sockaddr.rose.srose_digi.ax25_call) == -1) {		close(fd);		return (-1);	    }	    sockaddr.rose.srose_ndigis = 1;	}	sockaddr.rose.srose_family = AF_ROSE;	addrlen = sizeof(struct sockaddr_rose);	break;    case AF_NETROM:	if (nr_convert_call(address[0], &sockaddr.ax25) == -1) {	    close(fd);	    return (-1);	}	sockaddr.rose.srose_family = AF_NETROM;	addrlen = sizeof(struct sockaddr_ax25);	break;    case AF_AX25:	if (ax25_aton_arglist((const char**)address, &sockaddr.ax25) == -1) {	    close(fd);	    return (-1);	}	sockaddr.rose.srose_family = AF_AX25;	addrlen = sizeof(struct full_sockaddr_ax25);	break;    }    printf("Trying...\r");    fflush(stdout);    if (connect(fd, (struct sockaddr *) &sockaddr, addrlen)) {	printf("\n");	perror("connect");	close(fd);	return (-1);    }    printf("*** Connected to %s\n", address[0]);    return (fd);}