diff options
Diffstat (limited to 'pfinet/linux-src/net/ipv4/devinet.c')
-rw-r--r-- | pfinet/linux-src/net/ipv4/devinet.c | 97 |
1 files changed, 76 insertions, 21 deletions
diff --git a/pfinet/linux-src/net/ipv4/devinet.c b/pfinet/linux-src/net/ipv4/devinet.c index 41b42a52..d980631b 100644 --- a/pfinet/linux-src/net/ipv4/devinet.c +++ b/pfinet/linux-src/net/ipv4/devinet.c @@ -23,7 +23,7 @@ */ #include <linux/config.h> - + #include <asm/uaccess.h> #include <asm/system.h> #include <asm/bitops.h> @@ -370,8 +370,8 @@ inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) #endif -/* - * Determine a default network mask, based on the IP address. +/* + * Determine a default network mask, based on the IP address. */ static __inline__ int inet_abc_len(u32 addr) @@ -380,21 +380,79 @@ static __inline__ int inet_abc_len(u32 addr) return 0; addr = ntohl(addr); - if (IN_CLASSA(addr)) + if (IN_CLASSA(addr)) return 8; - if (IN_CLASSB(addr)) + if (IN_CLASSB(addr)) return 16; - if (IN_CLASSC(addr)) + if (IN_CLASSC(addr)) return 24; /* - * Something else, probably a multicast. + * Something else, probably a multicast. */ - + return -1; } +#ifdef _HURD_ + +#define devinet_ioctl 0 + +error_t +configure_device (struct device *dev, + uint32_t addr, uint32_t netmask) +{ + struct in_device *in_dev = dev->ip_ptr; + struct in_ifaddr *ifa = in_dev ? in_dev->ifa_list : 0; + + if (ifa) + { + inet_del_ifa (in_dev, &in_dev->ifa_list, 0); + ifa->ifa_broadcast = 0; + ifa->ifa_anycast = 0; + } + else + { + ifa = inet_alloc_ifa (); + if (!ifa) + return ENOBUFS; + memcpy(ifa->ifa_label, dev->name, IFNAMSIZ); + } + + if (addr != INADDR_NONE) + ifa->ifa_address = ifa->ifa_local = addr; + if (netmask != INADDR_NONE) + { + ifa->ifa_mask = netmask; + ifa->ifa_prefixlen = inet_mask_len (ifa->ifa_mask); + if ((dev->flags&IFF_BROADCAST) && ifa->ifa_prefixlen < 31) + ifa->ifa_broadcast = ifa->ifa_address|~ifa->ifa_mask; + else + ifa->ifa_broadcast = 0; + } + + return - inet_set_ifa (dev, ifa); +} + +void +inquire_device (struct device *dev, + uint32_t *addr, uint32_t *netmask) +{ + struct in_device *in_dev = dev->ip_ptr; + struct in_ifaddr *ifa = in_dev ? in_dev->ifa_list : 0; + + if (ifa) + { + *addr = ifa->ifa_local; + *netmask = ifa->ifa_mask; + } + else + *addr = *netmask = INADDR_NONE; +} + +#else + int devinet_ioctl(unsigned int cmd, void *arg) { struct ifreq ifr; @@ -514,7 +572,7 @@ int devinet_ioctl(unsigned int cmd, void *arg) #endif ret = dev_change_flags(dev, ifr.ifr_flags); break; - + case SIOCSIFADDR: /* Set interface address (and family) */ if (inet_abc_len(sin->sin_addr.s_addr) < 0) { ret = -EINVAL; @@ -563,7 +621,7 @@ int devinet_ioctl(unsigned int cmd, void *arg) inet_insert_ifa(in_dev, ifa); } break; - + case SIOCSIFDSTADDR: /* Set the destination address */ if (ifa->ifa_address != sin->sin_addr.s_addr) { if (inet_abc_len(sin->sin_addr.s_addr) < 0) { @@ -605,6 +663,8 @@ rarok: return 0; } +#endif + static int inet_gifconf(struct device *dev, char *buf, int len) { @@ -657,8 +717,8 @@ u32 inet_select_addr(struct device *dev, u32 dst, int scope) if (!addr) addr = ifa->ifa_local; } endfor_ifa(in_dev); - - if (addr) + + if (addr || scope >= RT_SCOPE_LINK) return addr; /* Not loopback addresses on loopback should be preferred @@ -670,9 +730,7 @@ u32 inet_select_addr(struct device *dev, u32 dst, int scope) continue; for_primary_ifa(in_dev) { - if (!IN_DEV_HIDDEN(in_dev) && - ifa->ifa_scope <= scope && - ifa->ifa_scope != RT_SCOPE_LINK) + if (ifa->ifa_scope <= scope) return ifa->ifa_local; } endfor_ifa(in_dev); } @@ -693,7 +751,7 @@ int unregister_inetaddr_notifier(struct notifier_block *nb) { return notifier_chain_unregister(&inetaddr_chain,nb); } - + static int inetdev_event(struct notifier_block *this, unsigned long event, void *ptr) { struct device *dev = ptr; @@ -727,7 +785,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, void case NETDEV_DOWN: ip_mc_down(in_dev); break; - case NETDEV_CHANGEMTU: + case NETDEV_CHANGEMTU: if (dev->mtu >= 68) break; /* MTU falled under minimal IP mtu. Disable IP. */ @@ -925,7 +983,7 @@ int devinet_sysctl_forward(ctl_table *ctl, int write, struct file * filp, static struct devinet_sysctl_table { struct ctl_table_header *sysctl_header; - ctl_table devinet_vars[13]; + ctl_table devinet_vars[12]; ctl_table devinet_dev[2]; ctl_table devinet_conf_dir[2]; ctl_table devinet_proto_dir[2]; @@ -965,9 +1023,6 @@ static struct devinet_sysctl_table {NET_IPV4_CONF_LOG_MARTIANS, "log_martians", &ipv4_devconf.log_martians, sizeof(int), 0644, NULL, &proc_dointvec}, - {NET_IPV4_CONF_HIDDEN, "hidden", - &ipv4_devconf.hidden, sizeof(int), 0644, NULL, - &proc_dointvec}, {0}}, {{NET_PROTO_CONF_ALL, "all", NULL, 0, 0555, devinet_sysctl.devinet_vars},{0}}, |