summaryrefslogtreecommitdiff
path: root/lib/if.h
diff options
context:
space:
mode:
authorajs <ajs>2005-04-03 03:40:52 +0000
committerajs <ajs>2005-04-03 03:40:52 +0000
commit08dbfb691d8e03c7200138d55447fc29916e0362 (patch)
tree54d8718c7bdb035197cebcedef7d3de4f0038d55 /lib/if.h
parente4319de388b748ba66551f33fecdf7446e754b80 (diff)
2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* if_ioctl.c: (interface_list_ioctl) Use if_get_by_name_len. * if_proc.c: (ifaddr_proc_ipv6) Increase size of ifname buffer to avoid overflow. * kernel_socket.c: (ifan_read) Use if_get_by_name_len. * if.h: Fix comments to reflect that if_lookup_by_name and if_get_by_name now require the argument strings to be NUL-terminated. * if.c: (if_lookup_by_name) Compare using strcmp. (if_get_by_name) Pass strlen(ifname) as 2nd arg to if_create.
Diffstat (limited to 'lib/if.h')
-rw-r--r--lib/if.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/if.h b/lib/if.h
index 4cfc9e77..6946865c 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -217,20 +217,17 @@ struct interface *if_lookup_by_index (unsigned int);
struct interface *if_lookup_exact_address (struct in_addr);
struct interface *if_lookup_address (struct in_addr);
-/* Currently, the code assumes that the interface name arguments to these
- functions have length <= INTERFACE_NAMSIZ, and they must be NUL-terminated
- if they are shorter than INTERFACE_NAMSIZ. After code cleanup, the
- implementation will be changed to require the arguments to these functions
- to terminate with a NUL character (no length limitation). */
-struct interface *if_lookup_by_name (const char *);
-struct interface *if_get_by_name (const char *);
-
-/* For these 2 functions, the 2nd argument should be the precise length
- of the interface name (not counting a trailing NUL which may or may
- not be present). */
-extern struct interface *if_lookup_by_name_len(const char *name,
+/* These 2 functions are to be used when the ifname argument is terminated
+ by a '\0' character: */
+struct interface *if_lookup_by_name (const char *ifname);
+struct interface *if_get_by_name (const char *ifname);
+
+/* For these 2 functions, the namelen argument should be the precise length
+ of the ifname string (not counting any optional trailing '\0' character).
+ In most cases, strnlen should be used to calculate the namelen value. */
+extern struct interface *if_lookup_by_name_len(const char *ifname,
size_t namelen);
-extern struct interface *if_get_by_name_len(const char *name, size_t namelen);
+extern struct interface *if_get_by_name_len(const char *ifname, size_t namelen);
/* Delete the interface, but do not free the structure, and leave it in the