+ }
+
+ printf("attached tty %s to netdevice %s\n", tty, buf);
+
+ /* try to rename the created device if requested */
+ if (name) {
+ struct ifreq ifr;
+ int s = socket(PF_INET, SOCK_DGRAM, 0);
+
+ printf("rename netdevice %s to %s ... ", buf, name);
+
+ if (s < 0)
+ perror("socket for interface rename");
+ else {
+ strncpy (ifr.ifr_name, buf, IFNAMSIZ);
+ strncpy (ifr.ifr_newname, name, IFNAMSIZ);
+
+ if (ioctl(s, SIOCSIFNAME, &ifr) < 0)
+ printf("failed!\n");
+ else
+ printf("ok.\n");
+
+ close(s);
+ }
+ }