aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/mcast_user.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-10-16 04:27:29 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:08 -0400
commitcd1ae0e49bdd814cfaa2e5ab28cff21a30e20085 (patch)
tree1b993b9de4cb9a8578022a4014063c3e87ec996e /arch/um/drivers/mcast_user.c
parent1a80521990a0e30e61a92994a009adc52161b070 (diff)
uml: network formatting
Style and other non-functional changes in the UML networking code, including include tidying style violations copyright updates printks getting severities userspace code calling libc directly rather than using the os_* wrappers There's also a exit path cleanup in the pcap driver. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers/mcast_user.c')
-rw-r--r--arch/um/drivers/mcast_user.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c
index 236a3dfc297d..e427b5322a36 100644
--- a/arch/um/drivers/mcast_user.c
+++ b/arch/um/drivers/mcast_user.c
@@ -1,9 +1,10 @@
1/* 1/*
2 * user-mode-linux networking multicast transport 2 * user-mode-linux networking multicast transport
3 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org> 4 * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
4 * 5 *
5 * based on the existing uml-networking code, which is 6 * based on the existing uml-networking code, which is
6 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and 7 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
7 * James Leu (jleu@mindspring.net). 8 * James Leu (jleu@mindspring.net).
8 * Copyright (C) 2001 by various other people who didn't put their name here. 9 * Copyright (C) 2001 by various other people who didn't put their name here.
9 * 10 *
@@ -11,18 +12,13 @@
11 * 12 *
12 */ 13 */
13 14
14#include <errno.h>
15#include <unistd.h> 15#include <unistd.h>
16#include <sys/socket.h> 16#include <errno.h>
17#include <sys/un.h>
18#include <sys/time.h>
19#include <netinet/in.h> 17#include <netinet/in.h>
20#include "net_user.h"
21#include "mcast.h" 18#include "mcast.h"
22#include "kern_util.h" 19#include "net_user.h"
23#include "user.h"
24#include "os.h"
25#include "um_malloc.h" 20#include "um_malloc.h"
21#include "user.h"
26 22
27#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) 23#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
28 24
@@ -31,8 +27,9 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port)
31 struct sockaddr_in *sin; 27 struct sockaddr_in *sin;
32 28
33 sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL); 29 sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
34 if(sin == NULL){ 30 if (sin == NULL) {
35 printk("new_addr: allocation of sockaddr_in failed\n"); 31 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in "
32 "failed\n");
36 return NULL; 33 return NULL;
37 } 34 }
38 sin->sin_family = AF_INET; 35 sin->sin_family = AF_INET;
@@ -71,17 +68,17 @@ static int mcast_open(void *data)
71 68
72 fd = socket(AF_INET, SOCK_DGRAM, 0); 69 fd = socket(AF_INET, SOCK_DGRAM, 0);
73 70
74 if (fd < 0){ 71 if (fd < 0) {
75 err = -errno; 72 err = -errno;
76 printk("mcast_open : data socket failed, errno = %d\n", 73 printk(UM_KERN_ERR "mcast_open : data socket failed, "
77 errno); 74 "errno = %d\n", errno);
78 goto out; 75 goto out;
79 } 76 }
80 77
81 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { 78 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
82 err = -errno; 79 err = -errno;
83 printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", 80 printk(UM_KERN_ERR "mcast_open: SO_REUSEADDR failed, "
84 errno); 81 "errno = %d\n", errno);
85 goto out_close; 82 goto out_close;
86 } 83 }
87 84
@@ -89,45 +86,46 @@ static int mcast_open(void *data)
89 if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl, 86 if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl,
90 sizeof(pri->ttl)) < 0) { 87 sizeof(pri->ttl)) < 0) {
91 err = -errno; 88 err = -errno;
92 printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", 89 printk(UM_KERN_ERR "mcast_open: IP_MULTICAST_TTL failed, "
93 errno); 90 "error = %d\n", errno);
94 goto out_close; 91 goto out_close;
95 } 92 }
96 93
97 /* set LOOP, so data does get fed back to local sockets */ 94 /* set LOOP, so data does get fed back to local sockets */
98 if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { 95 if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
99 err = -errno; 96 err = -errno;
100 printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", 97 printk(UM_KERN_ERR "mcast_open: IP_MULTICAST_LOOP failed, "
101 errno); 98 "error = %d\n", errno);
102 goto out_close; 99 goto out_close;
103 } 100 }
104 101
105 /* bind socket to mcast address */ 102 /* bind socket to mcast address */
106 if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { 103 if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
107 err = -errno; 104 err = -errno;
108 printk("mcast_open : data bind failed, errno = %d\n", errno); 105 printk(UM_KERN_ERR "mcast_open : data bind failed, "
106 "errno = %d\n", errno);
109 goto out_close; 107 goto out_close;
110 } 108 }
111 109
112 /* subscribe to the multicast group */ 110 /* subscribe to the multicast group */
113 mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr; 111 mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr;
114 mreq.imr_interface.s_addr = 0; 112 mreq.imr_interface.s_addr = 0;
115 if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, 113 if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP,
116 &mreq, sizeof(mreq)) < 0) { 114 &mreq, sizeof(mreq)) < 0) {
117 err = -errno; 115 err = -errno;
118 printk("mcast_open: IP_ADD_MEMBERSHIP failed, error = %d\n", 116 printk(UM_KERN_ERR "mcast_open: IP_ADD_MEMBERSHIP failed, "
119 errno); 117 "error = %d\n", errno);
120 printk("There appears not to be a multicast-capable network " 118 printk(UM_KERN_ERR "There appears not to be a multicast-"
121 "interface on the host.\n"); 119 "capable network interface on the host.\n");
122 printk("eth0 should be configured in order to use the " 120 printk(UM_KERN_ERR "eth0 should be configured in order to use "
123 "multicast transport.\n"); 121 "the multicast transport.\n");
124 goto out_close; 122 goto out_close;
125 } 123 }
126 124
127 return fd; 125 return fd;
128 126
129 out_close: 127 out_close:
130 os_close_file(fd); 128 close(fd);
131 out: 129 out:
132 return err; 130 return err;
133} 131}
@@ -142,11 +140,11 @@ static void mcast_close(int fd, void *data)
142 mreq.imr_interface.s_addr = 0; 140 mreq.imr_interface.s_addr = 0;
143 if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP, 141 if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP,
144 &mreq, sizeof(mreq)) < 0) { 142 &mreq, sizeof(mreq)) < 0) {
145 printk("mcast_open: IP_DROP_MEMBERSHIP failed, error = %d\n", 143 printk(UM_KERN_ERR "mcast_open: IP_DROP_MEMBERSHIP failed, "
146 errno); 144 "error = %d\n", errno);
147 } 145 }
148 146
149 os_close_file(fd); 147 close(fd);
150} 148}
151 149
152int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri) 150int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri)