summaryrefslogtreecommitdiff
path: root/net/wmnet/files/patch-if.c
blob: a2b10cddfc000ae3ed0178aac98100fde29df6ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
--- if.c.orig	Sun Oct 11 19:13:16 1998
+++ if.c	Fri Nov 22 16:24:50 2002
@@ -88,8 +88,13 @@
 
 			if (!newData) {
 				size -= IF_STEP;
+#if defined(__FreeBSD__) && __FreeBSD_version < 501113
 				fprintf(stderr, "wmnet: Warning -- low memory; "
 						"ignoring %s interface\n", theData->if_name);
+#else
+				fprintf(stderr, "wmnet: Warning -- low memory; "
+						"ignoring %s interface\n", theData->if_xname);
+#endif
 				return 0;
 			}
 
@@ -118,10 +123,13 @@
 		ptr->flags = 0;
 
 #ifndef NDEBUG
+#if defined(__FreeBSD__) && __FreeBSD_version < 501113
 		printf("Added '%.*s%d' to list.\n", IFNAMSIZ, theData->if_name,
 			   theData->if_unit);
+#else
+		printf("Added '%.*s' to list.\n", IFNAMSIZ, theData->if_xname);
+#endif
 #endif
-
 		// Bump the total.
 
 		++total;
@@ -144,7 +152,9 @@
 {
 	static unsigned long c = 0;
 	static struct ifnet d;
+#if defined(__FreeBSD__) && __FreeBSD_version < 501113
 	static char name[IFNAMSIZ];
+#endif
 
 	/* If we are passed a NULL, the caller wants us to stop caching
 	   the current interface. */
@@ -161,6 +171,7 @@
 		return &d;
 	else if (sizeof(d) == kvm_read(kd, a, &d, sizeof(d))) {
 
+#if defined(__FreeBSD__) && __FreeBSD_version < 501113
 		/* We've read the structure's data, but the 'name' field still
 		   points to kernel memory. We transfer the name to a local
 		   buffer, and then modify the pointer to point to our
@@ -172,6 +183,7 @@
 		if (sizeof(name) == n) {
 			name[IFNAMSIZ - 1] = '\0';
 			d.if_name = name;
+#endif
 #ifndef NDEBUG
 
 			/* These are other pointer fields that we shouldn't need
@@ -190,8 +202,10 @@
 #endif
 			c = a;
 			return &d;
+#if defined(__FreeBSD__) && __FreeBSD_version < 501113
 		} else
 			return 0;
+#endif
 	} else
 		return 0;
 }
@@ -306,12 +320,16 @@
 	if (idx < total) {
 		struct ifnet const* const ptr = dereference(ifData[idx].ifNetAddr);
 
+#if defined(__FreeBSD__) && __FreeBSD_version < 501113
 		if (ptr) {
 			static char buffer[IFNAMSIZ + 1];
 
 			sprintf(buffer, "%.*s%d", IFNAMSIZ - 1, ptr->if_name, ptr->if_unit);
 			return buffer;
 		}
+#else
+		return ptr->if_xname;
+#endif
 	}
 	return 0;
 }