/* * netsniff-ng - the packet sniffing beast * Copyright 2009, 2010 Daniel Borkmann. * Copyright 2014, 2015 Tobias Klauser * Subject to the GPL, version 2. */ #include #include #include #include #include "hash.h" #include "str.h" #include "lookup.h" #include "xmalloc.h" static bool lookup_initialized[LT_MAX]; static struct hash_table lookup_tables[LT_MAX]; static const char * const lookup_files[] = { [LT_PORTS_UDP] = ETCDIRE_STRING "/udp.conf", [LT_PORTS_TCP] = ETCDIRE_STRING "/tcp.conf", [LT_ETHERTYPES] = ETCDIRE_STRING "/ether.conf", [LT_OUI] = ETCDIRE_STRING "/oui.conf", }; struct lookup_entry { unsigned int id; char *str; struct lookup_entry *next; }; void lookup_init(enum lookup_type which) { FILE *fp; char buff[128], *ptr, *end; const char *file; struct hash_table *table; struct lookup_entry *p; void **pos; bug_on(which >= LT_MAX); if (lookup_initialized[which]) return; table = &lookup_tables[which]; file = lookup_files[which]; fp = fopen(file, "r"); if (!fp) { fprintf(stderr, "Cannot open %s: %s." "Port name resolution won't be available.\n", file, strerror(errno)); return; } memset(buff, 0, sizeof(buff)); while (fgets(buff, sizeof(buff), fp) != NULL) { buff[sizeof(buff) - 1] = 0; ptr = buff; p = xmalloc(sizeof(*p)); p->id = strtol(ptr, &end, 0); /* not a valid line, skip */ if (p->id == 0 && end == ptr) { xfree(p); continue; } ptr = strstr(buff, ", "); /* likewise */ if (!ptr) { xfree(p); continue; } ptr += strlen(", "); ptr = strtrim_right(ptr, '\n'); ptr = strtrim_right(ptr, ' '); p->str = xstrdup(ptr); p->next = NULL; pos = insert_hash(p->id, p, table); if (pos) { p->next = *pos; *pos = p; } memset(buff, 0, sizeof(buff)); } fclose(fp); lookup_initialized[which] = true; } static int __lookup_cleanup_single(void *ptr) { struct lookup_entry *tmp, *p = ptr; if (!ptr) return 0; while ((tmp = p->next)) { xfree(p->str); xfree(p); p = tmp; } xfree(p->str); xfree(p); return 0; } void lookup_cleanup(enum lookup_type which) { struct hash_table *table; bug_on(which >= LT_MAX); if (!lookup_initialized[which]) return; table = &lookup_tables[which]; for_each_hash(table, __lookup_cleanup_single); free_hash(table); lookup_initialized[which] = false; } static inline const char *__lookup_inline(unsigned int id, struct hash_table *tbl) { struct lookup_entry *entry = lookup_hash(id, tbl); while (entry && id != entry->id) entry = entry->next; return (entry && id == entry->id ? entry->str : NULL); } const char *lookup_ether_type(unsigned int id) { return __lookup_inline(id, &lookup_tables[LT_ETHERTYPES]); } const char *lookup_port_udp(unsigned int id) { return __lookup_inline(id, &lookup_tables[LT_PORTS_UDP]); } const char *lookup_port_tcp(unsigned int id) { return __lookup_inline(id, &lookup_tables[LT_PORTS_TCP]); } const char *lookup_vendor(unsigned int id) { return __lookup_inline(id, &lookup_tables[LT_OUI]); } 67835a97b4d00e6a20e0e4b62'>root/Documentation/devicetree
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-29 10:17:52 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-29 10:17:52 -0700
commit37cc6bb8f28aee667835a97b4d00e6a20e0e4b62 (patch)
tree86c8ad77595af96b5c9123a8664448956beb59a8 /Documentation/devicetree
parent9af6f26a1a7f152f7736c0c20247eef0ab3df190 (diff)
parentd0f4bce2bce7e998abc906f3590e9032af7a41ba (diff)
Merge tag 'tty-4.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial driver fixes from Greg KH: "Here are a number of small tty and serial driver fixes for reported issues for 4.9-rc3. Nothing major, but they do resolve a bunch of problems with the tty core changes that are in 4.9-rc1, and finally the atmel serial driver is back working properly. All have been in linux-next with no reported issues" * tag 'tty-4.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: tty: serial_core: fix NULL struct tty pointer access in uart_write_wakeup tty: serial_core: Fix serial console crash on port shutdown tty/serial: at91: fix hardware handshake on Atmel platforms vt: clear selection before resizing sc16is7xx: always write state when configuring GPIO as an output sh-sci: document R8A7743/5 support tty: serial: 8250: 8250_core: NXP SC16C2552 workaround tty: limit terminal size to 4M chars tty: serial: fsl_lpuart: Fix Tx DMA edge case serial: 8250_lpss: enable MSI for sure serial: core: fix console problems on uart_close serial: 8250_uniphier: fix clearing divisor latch access bit serial: 8250_uniphier: fix more unterminated string serial: pch_uart: add terminate entry for dmi_system_id tables devicetree: bindings: uart: Add new compatible string for ZynqMP serial: xuartps: Add new compatible string for ZynqMP serial: SERIAL_STM32 should depend on HAS_DMA serial: stm32: Fix comparisons with undefined register tty: vt, fix bogus division in csi_J
Diffstat (limited to 'Documentation/devicetree')