{
struct select_channel *selchannel, **selchannelp;
- selchannel = (struct select_channel *)malloc(sizeof(struct select_channel));
- if (!selchannel)
- {
- PERROR("No memory!");
- return;
- }
+ selchannel = (struct select_channel *)MALLOC(sizeof(struct select_channel));
memuse++;
- memset(selchannel, 0, sizeof(struct select_channel));
if (ifport->mISDNport->ntmode)
selchannel->channel = CHANNEL_FREE;
if (!ifport->mISDNport->ptp && ifport->mISDNport->ntmode)
{
selchannelp = &(selchannel->next);
- selchannel = (struct select_channel *)malloc(sizeof(struct select_channel));
- if (!selchannel)
- {
- PERROR("No memory!");
- return;
- }
+ selchannel = (struct select_channel *)MALLOC(sizeof(struct select_channel));
memuse++;
- memset(selchannel, 0, sizeof(struct select_channel));
selchannel->channel = CHANNEL_NO; // call waiting
*selchannelp = selchannel;
}
{
struct select_channel *selchannel;
- selchannel = (struct select_channel *)malloc(sizeof(struct select_channel));
- if (!selchannel)
- {
- PERROR("No memory!");
- return;
- }
+ selchannel = (struct select_channel *)MALLOC(sizeof(struct select_channel));
memuse++;
- memset(selchannel, 0, sizeof(struct select_channel));
selchannel->channel = CHANNEL_FREE;
ifport->ptmp = 1;
return(0);
}
+static int inter_nt(struct interface *interface, char *filename, int line, char *parameter, char *value)
+{
+#ifdef SOCKET_MISDN
+ struct interface_port *ifport;
+
+ /* port in chain ? */
+ if (!interface->ifport)
+ {
+ SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects previous 'port' definition.\n", filename, line, parameter);
+ return(-1);
+ }
+ /* goto end of chain */
+ ifport = interface->ifport;
+ while(ifport->next)
+ ifport = ifport->next;
+ /* add value */
+ if (value[0])
+ {
+ SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects no value.\n", filename, line, parameter);
+ return(-1);
+ }
+ ifport->nt = 1;
+#endif
+ return(0);
+}
static int inter_tones(struct interface *interface, char *filename, int line, char *parameter, char *value)
{
if (!strcasecmp(value, "yes"))
{
struct interface_port *ifport, **ifportp;
struct interface *searchif;
- struct interface_port *searchport;
int val;
val = get_number(value);
searchif = interface_newlist;
while(searchif)
{
- searchport = searchif->ifport;
+ ifport = searchif->ifport;
while(ifport)
{
if (ifport->portnum == val)
searchif = searchif->next;
}
/* alloc port substructure */
- ifport = (struct interface_port *)malloc(sizeof(struct interface_port));
- if (!ifport)
- {
- SPRINT(interface_error, "No memory!");
- return(-1);
- }
+ ifport = (struct interface_port *)MALLOC(sizeof(struct interface_port));
memuse++;
- memset(ifport, 0, sizeof(struct interface_port));
ifport->interface = interface;
/* set value */
ifport->portnum = val;
}
selchannel:
/* add to select-channel list */
- selchannel = (struct select_channel *)malloc(sizeof(struct select_channel));
- if (!selchannel)
- {
- SPRINT(interface_error, "No memory!");
- return(-1);
- }
+ selchannel = (struct select_channel *)MALLOC(sizeof(struct select_channel));
memuse++;
- memset(selchannel, 0, sizeof(struct select_channel));
/* set value */
selchannel->channel = val;
/* tail port */
}
selchannel:
/* add to select-channel list */
- selchannel = (struct select_channel *)malloc(sizeof(struct select_channel));
- if (!selchannel)
- {
- SPRINT(interface_error, "No memory!");
- return(-1);
- }
+ selchannel = (struct select_channel *)MALLOC(sizeof(struct select_channel));
memuse++;
- memset(selchannel, 0, sizeof(struct select_channel));
/* set value */
selchannel->channel = val;
/* tail port */
el = p;
p = get_seperated(p);
/* add MSN to list */
- ifmsn = (struct interface_msn *)malloc(sizeof(struct interface_msn));
- if (!ifmsn)
- {
- SPRINT(interface_error, "No memory!");
- return(-1);
- }
+ ifmsn = (struct interface_msn *)MALLOC(sizeof(struct interface_msn));
memuse++;
- memset(ifmsn, 0, sizeof(struct interface_msn));
/* set value */
SCPY(ifmsn->msn, el);
/* tail port */
el = p;
p = get_seperated(p);
/* add screen entry to list*/
- ifscreen = (struct interface_screen *)malloc(sizeof(struct interface_screen));
- if (!ifscreen)
- {
- SPRINT(interface_error, "No memory!");
- return(-1);
- }
+ ifscreen = (struct interface_screen *)MALLOC(sizeof(struct interface_screen));
memuse++;
- memset(ifscreen, 0, sizeof(struct interface_screen));
ifscreen->match_type = -1; /* unchecked */
ifscreen->match_present = -1; /* unchecked */
ifscreen->result_type = -1; /* unchanged */
{ "extension", &inter_extension, "",
"If keyword is given, calls to interface are handled as internal extensions."},
{"tones", &inter_tones, "yes | no",
- "Interface generates tones during call setup and release, or not.\nBy default only NT-mode interfaces generate tones."},
+ "Interface generates tones during call setup and release, or not.\nBy default only NT-mode ports generate tones."},
{"earlyb", &inter_earlyb, "yes | no",
- "Interface receives and bridges tones during call setup and release, or not.\nBy default only TE-mode interfaces receive tones."},
+ "Interface receives and bridges tones during call setup and release, or not.\nBy default only TE-mode ports receive tones."},
{"hunt", &inter_hunt, "linear | roundrobin",
"Select the algorithm for selecting port with free channel."},
"The given port above is opened as point-to-multipoint.\n"
"This is required on PRI NT-mode ports that are point-to-point by default.\n"
"This parameter must follow a 'port' parameter."},
+ {"nt", &inter_nt, "",
+ "The given port above is opened in NT-mode.\n"
+#ifdef SOCKET_MISDN
+ "This is required on interfaces that support both NT-mode and TE-mode.\n"
+#else
+ "This parameter is only required for socket based mISDN driver.\n"
+#endif
+ "This parameter must follow a 'port' parameter."},
- {"channel_out", &inter_channel_out, "[force,][<number>][,...][,free][,any][,no]",
+ {"channel-out", &inter_channel_out, "[force,][<number>][,...][,free][,any][,no]",
"Channel selection list for all outgoing calls to the interface.\n"
"A free channels is searched in order of appearance.\n"
"This parameter must follow a 'port' parameter.\n"
" any - On outgoing calls, signal 'any channel acceptable'. (see DSS1)\n"
" no - Signal 'no channel available' aka 'call waiting'. (see DSS1)"},
- {"channel_in", &inter_channel_in, "[force,][<number>][,...][,free][,any][,no]",
+ {"channel-in", &inter_channel_in, "[<number>][,...][,free]",
"Channel selection list for all incomming calls from the interface.\n"
"A free channels is accepted if in the list.\n"
- "If no channel was requested, the first free channel found is selected.\n"
+ "If any channel was requested, the first free channel found is selected.\n"
"This parameter must follow a 'port' parameter.\n"
" <number>[,...] - List of channels to accept.\n"
" free - Accept any free channel"},
"Incomming caller ID is checked against given MSN numbers.\n"
"If the caller ID is not found in this list, it is overwritten by the first MSN"},
- {"screen-in", &inter_screen_in, "[options] <old caller ID>[%%] [options] <new caller ID>[%%]",
+ {"screen-in", &inter_screen_in, "[options] <old caller ID>[%] [options] <new caller ID>[%]",
"Adds an entry for incomming calls to the caller ID screen list.\n"
"If the given 'old caller ID' matches, it is replaced by the 'new caller ID'\n"
- "If '%%' is given after old caller ID, it matches even if caller ID has\n"
+ "If '%' is given after old caller ID, it matches even if caller ID has\n"
"additional digits.\n"
- "If '%%' is given after mew caller ID, additinal digits of the 'old caller ID'\n"
+ "If '%' is given after mew caller ID, additinal digits of the 'old caller ID'\n"
"are added.\n"
"Options can be:\n"
" unknown | subsciber | national | international - Change caller ID type.\n"
" present | restrict - Change presentation of caller ID."},
- {"screen-out", &inter_screen_out, "<old caller ID> <new caller ID> [options]",
+ {"screen-out", &inter_screen_out, "[options] <old caller ID>[%] [options] <new caller ID>[%]",
"Adds an entry for outgoing calls to the caller ID screen list.\n"
"See 'screen-in' for help."},
"This parameter must follow a 'port' parameter."},
#if 0
+ {"layer2keep", &inter_layer2keep, "yes | no",
+ "By default, layer 2 is establised and kept up on PTP interfaces.\n"
+ ".\n"
+ "This parameter must follow a 'port' parameter."},
+#endif
+
+#if 0
#warning todo: filter, also in the PmISDN object
{"filter", &inter_filter, "<filter> [parameters]",
"Adds/appends a filter. Filters are ordered in transmit direction.\n"
struct interface_param *ifparam;
if (interface_newlist != NULL)
- {
- PERROR("software error, list is not empty.\n");
- exit(-1);
- }
+ FATAL("list is not empty.\n");
interface_error[0] = '\0';
SPRINT(filename, "%s/interface.conf", INSTALL_DATA);
parameter[strlen(parameter)-1] = '\0';
/* check if interface name already exists */
- interface = interface_first;
+ interface = interface_newlist;
while(interface)
{
if (!strcasecmp(interface->name, parameter+1))
}
/* append interface to new list */
- interface = (struct interface *)malloc(sizeof(struct interface));
- if (!interface)
- {
- SPRINT(interface_error, "No memory!");
- goto error;
- }
+ interface = (struct interface *)MALLOC(sizeof(struct interface));
memuse++;
- memset(interface, 0, sizeof(struct interface));
/* name interface */
SCPY(interface->name, parameter+1);
{
if (ifparam->func(interface, filename, line, parameter, value))
goto error;
- continue;
+ break;
}
ifparam++;
}
+ if (ifparam->name)
+ continue;
SPRINT(interface_error, "Error in %s (line %d): unknown parameter: '%s'.\n", filename, line, parameter);
goto error;
{
temp = selchannel;
selchannel = selchannel->next;
- memset(temp, 0, sizeof(struct select_channel));
- free(temp);
+ FREE(temp, sizeof(struct select_channel));
memuse--;
}
selchannel = ifport->out_channel;
{
temp = selchannel;
selchannel = selchannel->next;
- memset(temp, 0, sizeof(struct select_channel));
- free(temp);
+ FREE(temp, sizeof(struct select_channel));
memuse--;
}
temp = ifport;
ifport = ifport->next;
- memset(temp, 0, sizeof(struct interface_port));
- free(temp);
+ FREE(temp, sizeof(struct interface_port));
memuse--;
}
ifmsn = interface->ifmsn;
{
temp = ifmsn;
ifmsn = ifmsn->next;
- memset(temp, 0, sizeof(struct interface_msn));
- free(temp);
+ FREE(temp, sizeof(struct interface_msn));
memuse--;
}
ifscreen = interface->ifscreen_in;
{
temp = ifscreen;
ifscreen = ifscreen->next;
- memset(temp, 0, sizeof(struct interface_screen));
- free(temp);
+ FREE(temp, sizeof(struct interface_screen));
memuse--;
}
ifscreen = interface->ifscreen_out;
{
temp = ifscreen;
ifscreen = ifscreen->next;
- memset(temp, 0, sizeof(struct interface_screen));
- free(temp);
+ FREE(temp, sizeof(struct interface_screen));
memuse--;
}
iffilter = interface->iffilter;
{
temp = iffilter;
iffilter = iffilter->next;
- memset(temp, 0, sizeof(struct interface_filter));
- free(temp);
+ FREE(temp, sizeof(struct interface_filter));
memuse--;
}
temp = interface;
interface = interface->next;
- memset(temp, 0, sizeof(struct interface));
- free(temp);
+ FREE(temp, sizeof(struct interface));
memuse--;
}
}
+/*
+ * defaults of ports if not specified by config
+ */
+static void set_defaults(struct interface_port *ifport)
+{
+ /* default channel selection list */
+ if (!ifport->out_channel)
+ default_out_channel(ifport);
+ if (!ifport->in_channel)
+ default_in_channel(ifport);
+ /* default is_tones */
+ if (ifport->interface->is_tones)
+ ifport->mISDNport->tones = (ifport->interface->is_tones==IS_YES);
+ else
+ ifport->mISDNport->tones = (ifport->mISDNport->ntmode)?1:0;
+ /* default is_earlyb */
+ if (ifport->interface->is_earlyb)
+ ifport->mISDNport->earlyb = (ifport->interface->is_earlyb==IS_YES);
+ else
+ ifport->mISDNport->earlyb = (ifport->mISDNport->ntmode)?0:1;
+ /* set locally flag */
+ if (ifport->interface->extension)
+ ifport->mISDNport->locally = 1;
+ else
+ ifport->mISDNport->locally = 0;
+}
+
/*
* all links between mISDNport and interface are made
{
ifport->mISDNport = mISDNport;
mISDNport->ifport = ifport;
+ set_defaults(ifport);
}
mISDNport = mISDNport->next;
}
{
if (!ifport->mISDNport)
{
- /* open new port */
- mISDNport = mISDNport_open(ifport->portnum, ifport->ptp, ifport->ptmp);
- if (mISDNport)
- {
- ifport->mISDNport = mISDNport;
- mISDNport->ifport = ifport;
- }
- }
- if (ifport->mISDNport)
- {
- /* default channel selection list */
- if (!ifport->out_channel)
- default_out_channel(ifport);
- if (!ifport->in_channel)
- default_in_channel(ifport);
- /* default is_tones */
- if (ifport->interface->is_tones)
- ifport->mISDNport->is_tones = (ifport->interface->is_tones==IS_YES);
- else
- ifport->mISDNport->is_tones = (ifport->mISDNport->ntmode)?1:0;
- /* default is_earlyb */
- if (ifport->interface->is_earlyb)
- ifport->mISDNport->is_earlyb = (ifport->interface->is_earlyb==IS_YES);
- else
- ifport->mISDNport->is_earlyb = (ifport->mISDNport->ntmode)?0:1;
+ load_port(ifport);
}
+ ifport = ifport->next;
}
interface = interface->next;
}
}
+
+/*
+ * load port
+ */
+void load_port(struct interface_port *ifport)
+{
+ struct mISDNport *mISDNport;
+
+ /* open new port */
+ mISDNport = mISDNport_open(ifport->portnum, ifport->ptp, ifport->ptmp, ifport->nt, ifport->interface);
+ if (mISDNport)
+ {
+ /* link port */
+ ifport->mISDNport = mISDNport;
+ mISDNport->ifport = ifport;
+ set_defaults(ifport);
+ } else
+ {
+ ifport->block = 2; /* not available */
+ }
+}
+
/*
* give summary of interface syntax
*/
}
}
-