diff options
Diffstat (limited to 'nest/proto.c')
-rw-r--r-- | nest/proto.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/nest/proto.c b/nest/proto.c index 94bbbfd8..a0beb5fb 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -499,3 +499,32 @@ proto_show(struct symbol *s, int verbose) } cli_msg(0, ""); } + +struct proto * +proto_get_named(struct symbol *sym, struct protocol *pr) +{ + struct proto *p, *q; + + if (sym) + { + if (sym->class != SYM_PROTO) + cf_error("%s: Not a protocol", sym->name); + p = ((struct proto_config *)sym->def)->proto; + if (!p || p->proto != pr) + cf_error("%s: Not a %s protocol", sym->name, pr->name); + } + else + { + p = NULL; + WALK_LIST(q, proto_list) + if (q->proto == pr) + { + if (p) + cf_error("There are multiple %s protocols running", pr->name); + p = q; + } + if (!p) + cf_error("There is no %s protocol running", pr->name); + } + return p; +} |