+/* hunts for the given interface
+ * it does not need to have an mISDNport instance */
+struct interface *EndpointAppPBX::hunt_interface(char *ifname)
+{
+ struct interface *interface;
+ int there_is_an_external = 0;
+
+ interface = interface_first;
+
+ /* first find the given interface or, if not given, one with no extension */
+ checknext:
+ if (!interface) {
+ if (!there_is_an_external && !(ifname && ifname[0])) {
+ trace_header("CHANNEL SELECTION (no external interface specified)", DIRECTION_NONE);
+ add_trace("info", NULL, "Add 'extern' parameter to interface.conf.");
+ end_trace();
+ }
+ return(NULL);
+ }
+
+ /* check for given interface */
+ if (ifname && ifname[0]) {
+ if (!strcasecmp(interface->name, ifname)) {
+ /* found explicit interface */
+ trace_header("CHANNEL SELECTION (found given interface)", DIRECTION_NONE);
+ add_trace("interface", NULL, "%s", ifname);
+ end_trace();
+ goto foundif;
+ }
+ } else {
+ if (interface->external) {
+ there_is_an_external = 1;
+ /* found non extension */
+ trace_header("CHANNEL SELECTION (found external interface)", DIRECTION_NONE);
+ add_trace("interface", NULL, "%s", interface->name);
+ end_trace();
+ goto foundif;
+ }
+ }