puts("-p <port> \t specify port to listen for incoming connections");
puts("-u <port> \t specify udp data port");
puts("-d <device> \t specify audio device");
+ puts("-i <iface> \t specify network interface");
puts("");
return SUCCESS;
ivac.net.l_port=IVAC_LISTEN_PORT;
ivac.net.l_udp_port=IVAC_UDP_PORT;
strcpy(ivac.audio.dsp_dev,SOUND_DEVICE);
+ strcpy(ivac.net.nic,"eth0");
/* parse argv and change default values */
for(i=1;i<argc;i++) {
case 'd':
strncpy(ivac.audio.dsp_dev,argv[++i],MAX_CHAR_DEVICE);
break;
+ case 'i':
+ strncpy(ivac.net.nic,argv[++i],MAX_NIC_DEVICE);
default:
usage();
return ERROR;
int network_udp_listen_init(t_net *net) {
struct sockaddr_in addr;
+ int true;
if((net->l_udp_fd=socket(AF_INET,SOCK_DGRAM,0))==-1) {
perror("[network] socket call (udp-receive)");
addr.sin_port=htons(net->l_udp_port);
addr.sin_addr.s_addr=INADDR_ANY;
if(bind(net->l_udp_fd,(struct sockaddr *)&addr,sizeof(struct sockaddr))==-1) {
- perror("[network] bind call (udp)");
- return N_ERROR;
+ /* try harder ... */
+ true=1;
+ if(setsockopt(net->l_udp_fd,SOL_SOCKET,SO_REUSEADDR,
+ &true,sizeof(true))==-1) {
+ perror("[network] setsockopt call (udp)");
+ return N_ERROR;
+ }
+ puts("[network] reused address (udp)");
}
printf("[network] listening on port %d (udp)\n",net->l_udp_port);
/* defines */
#define MAX_CONNECTIONS 32
+#define MAX_NIC_DEVICE 32
#define IP_DIGITS 16
#define C_IN_USE (1<<0)
int c_count;
t_connection connection[MAX_CONNECTIONS];
unsigned int sendmask; /* 32 bits for maximum of 32 connections */
+ char nic[MAX_NIC_DEVICE];
} t_net;
/* function prototypes */