net/ipv4/ipconfig.c
changeset 2 d1f6d8b6f81c
parent 0 aa628870c1d3
equal deleted inserted replaced
1:0056487c491e 2:d1f6d8b6f81c
   372 	 *	At this point we have no userspace running so need not
   372 	 *	At this point we have no userspace running so need not
   373 	 *	claim locks on system_utsname
   373 	 *	claim locks on system_utsname
   374 	 */
   374 	 */
   375 
   375 
   376 	if (!ic_host_name_set)
   376 	if (!ic_host_name_set)
   377 		sprintf(init_utsname()->nodename, NIPQUAD_FMT, NIPQUAD(ic_myaddr));
   377 		sprintf(init_utsname()->nodename, "%pI4", &ic_myaddr);
   378 
   378 
   379 	if (root_server_addr == NONE)
   379 	if (root_server_addr == NONE)
   380 		root_server_addr = ic_servaddr;
   380 		root_server_addr = ic_servaddr;
   381 
   381 
   382 	if (ic_netmask == NONE) {
   382 	if (ic_netmask == NONE) {
   385 		else if (IN_CLASSB(ntohl(ic_myaddr)))
   385 		else if (IN_CLASSB(ntohl(ic_myaddr)))
   386 			ic_netmask = htonl(IN_CLASSB_NET);
   386 			ic_netmask = htonl(IN_CLASSB_NET);
   387 		else if (IN_CLASSC(ntohl(ic_myaddr)))
   387 		else if (IN_CLASSC(ntohl(ic_myaddr)))
   388 			ic_netmask = htonl(IN_CLASSC_NET);
   388 			ic_netmask = htonl(IN_CLASSC_NET);
   389 		else {
   389 		else {
   390 			printk(KERN_ERR "IP-Config: Unable to guess netmask for address " NIPQUAD_FMT "\n",
   390 			printk(KERN_ERR "IP-Config: Unable to guess netmask for address %pI4\n",
   391 				NIPQUAD(ic_myaddr));
   391 				&ic_myaddr);
   392 			return -1;
   392 			return -1;
   393 		}
   393 		}
   394 		printk("IP-Config: Guessing netmask " NIPQUAD_FMT "\n", NIPQUAD(ic_netmask));
   394 		printk("IP-Config: Guessing netmask %pI4\n", &ic_netmask);
   395 	}
   395 	}
   396 
   396 
   397 	return 0;
   397 	return 0;
   398 }
   398 }
   399 
   399 
   977 
   977 
   978 				/* Let's accept that offer. */
   978 				/* Let's accept that offer. */
   979 				ic_myaddr = b->your_ip;
   979 				ic_myaddr = b->your_ip;
   980 				ic_servaddr = server_id;
   980 				ic_servaddr = server_id;
   981 #ifdef IPCONFIG_DEBUG
   981 #ifdef IPCONFIG_DEBUG
   982 				printk("DHCP: Offered address " NIPQUAD_FMT,
   982 				printk("DHCP: Offered address %pI4 by server %pI4\n",
   983 				       NIPQUAD(ic_myaddr));
   983 				       &ic_myaddr, &ic_servaddr);
   984 				printk(" by server " NIPQUAD_FMT "\n",
       
   985 				       NIPQUAD(ic_servaddr));
       
   986 #endif
   984 #endif
   987 				/* The DHCP indicated server address takes
   985 				/* The DHCP indicated server address takes
   988 				 * precedence over the bootp header one if
   986 				 * precedence over the bootp header one if
   989 				 * they are different.
   987 				 * they are different.
   990 				 */
   988 				 */
  1175 	if (!ic_got_reply) {
  1173 	if (!ic_got_reply) {
  1176 		ic_myaddr = NONE;
  1174 		ic_myaddr = NONE;
  1177 		return -1;
  1175 		return -1;
  1178 	}
  1176 	}
  1179 
  1177 
  1180 	printk("IP-Config: Got %s answer from " NIPQUAD_FMT ", ",
  1178 	printk("IP-Config: Got %s answer from %pI4, ",
  1181 		((ic_got_reply & IC_RARP) ? "RARP"
  1179 		((ic_got_reply & IC_RARP) ? "RARP"
  1182 		 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
  1180 		 : (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
  1183 		NIPQUAD(ic_servaddr));
  1181 		&ic_servaddr);
  1184 	printk("my address is " NIPQUAD_FMT "\n", NIPQUAD(ic_myaddr));
  1182 	printk("my address is %pI4\n", &ic_myaddr);
  1185 
  1183 
  1186 	return 0;
  1184 	return 0;
  1187 }
  1185 }
  1188 
  1186 
  1189 #endif /* IPCONFIG_DYNAMIC */
  1187 #endif /* IPCONFIG_DYNAMIC */
  1204 	if (ic_domain[0])
  1202 	if (ic_domain[0])
  1205 		seq_printf(seq,
  1203 		seq_printf(seq,
  1206 			   "domain %s\n", ic_domain);
  1204 			   "domain %s\n", ic_domain);
  1207 	for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
  1205 	for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
  1208 		if (ic_nameservers[i] != NONE)
  1206 		if (ic_nameservers[i] != NONE)
  1209 			seq_printf(seq,
  1207 			seq_printf(seq, "nameserver %pI4\n",
  1210 				   "nameserver " NIPQUAD_FMT "\n",
  1208 				   &ic_nameservers[i]);
  1211 				   NIPQUAD(ic_nameservers[i]));
       
  1212 	}
  1209 	}
  1213 	if (ic_servaddr != NONE)
  1210 	if (ic_servaddr != NONE)
  1214 		seq_printf(seq,
  1211 		seq_printf(seq, "bootserver %pI4\n",
  1215 			   "bootserver " NIPQUAD_FMT "\n",
  1212 			   &ic_servaddr);
  1216 			   NIPQUAD(ic_servaddr));
       
  1217 	return 0;
  1213 	return 0;
  1218 }
  1214 }
  1219 
  1215 
  1220 static int pnp_seq_open(struct inode *indoe, struct file *file)
  1216 static int pnp_seq_open(struct inode *indoe, struct file *file)
  1221 {
  1217 {
  1270  */
  1266  */
  1271 
  1267 
  1272 static int __init ip_auto_config(void)
  1268 static int __init ip_auto_config(void)
  1273 {
  1269 {
  1274 	__be32 addr;
  1270 	__be32 addr;
       
  1271 #ifdef IPCONFIG_DYNAMIC
       
  1272 	int retries = CONF_OPEN_RETRIES;
       
  1273 #endif
  1275 
  1274 
  1276 #ifdef CONFIG_PROC_FS
  1275 #ifdef CONFIG_PROC_FS
  1277 	proc_net_fops_create(&init_net, "pnp", S_IRUGO, &pnp_seq_fops);
  1276 	proc_net_fops_create(&init_net, "pnp", S_IRUGO, &pnp_seq_fops);
  1278 #endif /* CONFIG_PROC_FS */
  1277 #endif /* CONFIG_PROC_FS */
  1279 
  1278 
  1306 	     && ic_servaddr == NONE
  1305 	     && ic_servaddr == NONE
  1307 	     && ROOT_DEV == Root_NFS) ||
  1306 	     && ROOT_DEV == Root_NFS) ||
  1308 #endif
  1307 #endif
  1309 	    ic_first_dev->next) {
  1308 	    ic_first_dev->next) {
  1310 #ifdef IPCONFIG_DYNAMIC
  1309 #ifdef IPCONFIG_DYNAMIC
  1311 
       
  1312 		int retries = CONF_OPEN_RETRIES;
       
  1313 
       
  1314 		if (ic_dynamic() < 0) {
  1310 		if (ic_dynamic() < 0) {
  1315 			ic_close_devs();
  1311 			ic_close_devs();
  1316 
  1312 
  1317 			/*
  1313 			/*
  1318 			 * I don't know why, but sometimes the
  1314 			 * I don't know why, but sometimes the
  1385 	/*
  1381 	/*
  1386 	 * Clue in the operator.
  1382 	 * Clue in the operator.
  1387 	 */
  1383 	 */
  1388 	printk("IP-Config: Complete:");
  1384 	printk("IP-Config: Complete:");
  1389 	printk("\n     device=%s", ic_dev->name);
  1385 	printk("\n     device=%s", ic_dev->name);
  1390 	printk(", addr=" NIPQUAD_FMT, NIPQUAD(ic_myaddr));
  1386 	printk(", addr=%pI4", &ic_myaddr);
  1391 	printk(", mask=" NIPQUAD_FMT, NIPQUAD(ic_netmask));
  1387 	printk(", mask=%pI4", &ic_netmask);
  1392 	printk(", gw=" NIPQUAD_FMT, NIPQUAD(ic_gateway));
  1388 	printk(", gw=%pI4", &ic_gateway);
  1393 	printk(",\n     host=%s, domain=%s, nis-domain=%s",
  1389 	printk(",\n     host=%s, domain=%s, nis-domain=%s",
  1394 	       utsname()->nodename, ic_domain, utsname()->domainname);
  1390 	       utsname()->nodename, ic_domain, utsname()->domainname);
  1395 	printk(",\n     bootserver=" NIPQUAD_FMT, NIPQUAD(ic_servaddr));
  1391 	printk(",\n     bootserver=%pI4", &ic_servaddr);
  1396 	printk(", rootserver=" NIPQUAD_FMT, NIPQUAD(root_server_addr));
  1392 	printk(", rootserver=%pI4", &root_server_addr);
  1397 	printk(", rootpath=%s", root_server_path);
  1393 	printk(", rootpath=%s", root_server_path);
  1398 	printk("\n");
  1394 	printk("\n");
  1399 #endif /* !SILENT */
  1395 #endif /* !SILENT */
  1400 
  1396 
  1401 	return 0;
  1397 	return 0;