summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-01-28 20:53:48 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2016-01-31 23:43:36 +0100
commit89cc69c1d6a3ca6c5818690509af1dbec4319f99 (patch)
treea5b077d47e4fd6dc125818eb2772f80dd24b4e71
parentc177581efa78cce6384e306a2f2ee4b057ef6635 (diff)
proto: proto_dev_type() returns interface type for base protocols too
The device protocol definition provides a mapping between the interface type, ie. ARPHDR_*, and the overlying protocol base definition, eg. proto_eth. This patch updates proto_dev_type() so it also returns a mapping for these overlying ethernet protocol definitions, ie. ip, ip6, vlan, ip, arp. This patch required to resolve problems with automatic dependency generation for vlan in the netdev and inet families. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/proto.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/proto.c b/src/proto.c
index 65ee158f..0cd9fdbd 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -94,13 +94,21 @@ static const struct dev_proto_desc dev_proto_desc[] = {
*/
int proto_dev_type(const struct proto_desc *desc, uint16_t *res)
{
- unsigned int i;
+ const struct proto_desc *base;
+ unsigned int i, j;
for (i = 0; i < array_size(dev_proto_desc); i++) {
- if (dev_proto_desc[i].desc == desc) {
+ base = dev_proto_desc[i].desc;
+ if (base == desc) {
*res = dev_proto_desc[i].type;
return 0;
}
+ for (j = 0; j < array_size(base->protocols); j++) {
+ if (base->protocols[j].desc == desc) {
+ *res = dev_proto_desc[i].type;
+ return 0;
+ }
+ }
}
return -1;
}