15 const unsigned int proto
;
18 static const struct protocol protocols
[] = {
21 { "PF_UNIX", PF_LOCAL
},
22 { "PF_FILE", PF_LOCAL
},
26 { "PF_APPLETALK", 5 },
35 { "PF_SECURITY", 14 },
38 { "PF_ROUTE", PF_NETLINK
},
51 { "PF_BLUETOOTH", 31 },
56 { "PF_IEEE802154", 36 },
63 static const struct protocol
*lookup_proto(const char *name
, unsigned int proto
)
67 for (i
= 0; i
< ARRAY_SIZE(protocols
); i
++) {
68 if ((name
&& strcmp(name
, protocols
[i
].name
) == 0) ||
69 (proto
!= -1u && protocols
[i
].proto
== proto
))
76 const char * get_proto_name(unsigned int proto
)
80 for (i
= 0; i
< ARRAY_SIZE(protocols
); i
++)
81 if (protocols
[i
].proto
== proto
)
82 return protocols
[i
].name
;
86 void find_specific_proto(const char *protoarg
)
88 const struct protocol
*p
;
91 p
= lookup_proto(protoarg
, specific_proto
? : -1u);
93 specific_proto
= p
->proto
;
94 output(2, "Using protocol %s (%u) for all sockets\n", p
->name
, p
->proto
);
98 outputerr("Protocol unknown. Pass a numeric value [0-%d] or one of ", TRINITY_PF_MAX
);
99 for (i
= 0; i
< ARRAY_SIZE(protocols
); i
++)
100 outputerr("%s ", protocols
[i
].name
);
106 unsigned int find_next_enabled_proto(unsigned int from
)
110 from
%= ARRAY_SIZE(no_protos
);
112 for (i
= from
; i
< ARRAY_SIZE(no_protos
); i
++) {
113 if (no_protos
[i
] == FALSE
)
117 for (i
= 0; i
< from
; i
++) {
118 if (no_protos
[i
] == FALSE
)
125 void parse_exclude_protos(const char *arg
)
127 char *_arg
= strdup(arg
);
128 const struct protocol
*p
;
132 outputerr("No free memory\n");
136 for (tok
= strtok(_arg
, ","); tok
; tok
= strtok(NULL
, ",")) {
137 p
= lookup_proto(tok
, (unsigned int)atoi(tok
));
139 BUG_ON(p
->proto
>= ARRAY_SIZE(no_protos
));
140 no_protos
[p
->proto
] = TRUE
;
150 outputerr("Protocol unknown in argument %s\n", arg
);