#include "kern_util.h"
#include "user_util.h"
#include "user.h"
+#include "os.h"
#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
goto out;
}
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd < 0){
printk("mcast_open : data socket failed, errno = %d\n",
errno);
fd = -ENOMEM;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
printk("mcast_open: SO_REUSEADDR failed, errno = %d\n",
errno);
- close(fd);
+ os_close_file(fd);
fd = -EINVAL;
goto out;
}
sizeof(pri->ttl)) < 0) {
printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n",
errno);
- close(fd);
+ os_close_file(fd);
fd = -EINVAL;
goto out;
}
if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n",
errno);
- close(fd);
+ os_close_file(fd);
fd = -EINVAL;
goto out;
}
/* bind socket to mcast address */
if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
printk("mcast_open : data bind failed, errno = %d\n", errno);
- close(fd);
+ os_close_file(fd);
fd = -EINVAL;
goto out;
}
"interface on the host.\n");
printk("eth0 should be configured in order to use the "
"multicast transport.\n");
- close(fd);
+ os_close_file(fd);
fd = -EINVAL;
}
errno);
}
- close(fd);
+ os_close_file(fd);
}
int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri)