summaryrefslogtreecommitdiffstats
path: root/rose/rsattach.c
diff options
context:
space:
mode:
Diffstat (limited to 'rose/rsattach.c')
-rw-r--r--rose/rsattach.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/rose/rsattach.c b/rose/rsattach.c
index 924d152..62892d8 100644
--- a/rose/rsattach.c
+++ b/rose/rsattach.c
@@ -35,7 +35,7 @@ int readconfig(char *port)
FILE *fp;
char buffer[90], *s;
int n = 0;
-
+
if ((fp = fopen(CONF_RSPORTS_FILE, "r")) == NULL) {
fprintf(stderr, "rsattach: cannot open rsports file\n");
return FALSE;
@@ -43,7 +43,7 @@ int readconfig(char *port)
while (fgets(buffer, 90, fp) != NULL) {
n++;
-
+
if ((s = strchr(buffer, '\n')) != NULL)
*s = '\0';
@@ -54,10 +54,10 @@ int readconfig(char *port)
fprintf(stderr, "rsattach: unable to parse line %d of the rsports file\n", n);
return FALSE;
}
-
+
if (strcmp(s, port) != 0)
continue;
-
+
if ((s = strtok(NULL, " \t\r\n")) == NULL) {
fprintf(stderr, "rsattach: unable to parse line %d of the rsports file\n", n);
return FALSE;
@@ -66,14 +66,14 @@ int readconfig(char *port)
address = strdup(s);
fclose(fp);
-
+
return TRUE;
}
-
+
fclose(fp);
fprintf(stderr, "rsattach: cannot find port %s in rsports\n", port);
-
+
return FALSE;
}
@@ -82,7 +82,7 @@ int getfreedev(char *dev)
struct ifreq ifr;
int fd;
int i;
-
+
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("rsattach: socket");
return FALSE;
@@ -91,7 +91,7 @@ int getfreedev(char *dev)
for (i = 0; i < 6; i++) {
sprintf(dev, "rose%d", i);
strcpy(ifr.ifr_name, dev);
-
+
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
perror("rsattach: SIOCGIFFLAGS");
return FALSE;
@@ -113,17 +113,17 @@ int startiface(char *dev, struct hostent *hp)
struct ifreq ifr;
char addr[5];
int fd;
-
+
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("rsattach: socket");
return FALSE;
}
strcpy(ifr.ifr_name, dev);
-
+
if (hp != NULL) {
ifr.ifr_addr.sa_family = AF_INET;
-
+
ifr.ifr_addr.sa_data[0] = 0;
ifr.ifr_addr.sa_data[1] = 0;
ifr.ifr_addr.sa_data[2] = hp->h_addr_list[0][0];
@@ -143,7 +143,7 @@ int startiface(char *dev, struct hostent *hp)
ifr.ifr_hwaddr.sa_family = ARPHRD_ROSE;
memcpy(ifr.ifr_hwaddr.sa_data, addr, 5);
-
+
if (ioctl(fd, SIOCSIFHWADDR, &ifr) != 0) {
perror("rsattach: SIOCSIFHWADDR");
return FALSE;
@@ -169,12 +169,12 @@ int startiface(char *dev, struct hostent *hp)
perror("rsattach: SIOCSIFFLAGS");
return FALSE;
}
-
+
close(fd);
-
+
return TRUE;
}
-
+
int main(int argc, char *argv[])
{
@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
return 1;
}
}
-
+
if ((argc - optind) != 1) {
fprintf(stderr, "usage: rsattach [-i inetaddr] [-v] port\n");
return 1;
@@ -212,11 +212,11 @@ int main(int argc, char *argv[])
fprintf(stderr, "rsattach: cannot find free Rose device\n");
return 1;
}
-
+
if (!startiface(dev, hp))
- return 1;
+ return 1;
printf("Rose port %s bound to device %s\n", argv[optind], dev);
-
+
return 0;
}