#include "main.h"
#include "myisdn.h"
-extern "C" {
-#define MISDN_OLD_AF_COMPATIBILITY 1
-#include <compat_af_isdn.h>
-}
-#include <q931.h>
+#include <mISDN/mISDNcompat.h>
+int __af_isdn = MISDN_AF_ISDN;
+#include <mISDN/q931.h>
#undef offsetof
#ifdef __compiler_offsetof
#define B_TIMER_ACTIVATING 1 // seconds
#define B_TIMER_DEACTIVATING 1 // seconds
+/* GSM condition */
+#if defined WITH_GSM_BS && defined WITH_GSM_MS
+ #define MISDNPORT_GSM (mISDNport->gsm_bs || mISDNport->gsm_ms)
+#else
+ #ifdef WITH_GSM_BS
+ #define MISDNPORT_GSM (mISDNport->gsm_bs)
+ #endif
+ #ifdef WITH_GSM_MS
+ #define MISDNPORT_GSM (mISDNport->gsm_ms)
+ #endif
+#endif
+#ifndef MISDNPORT_GSM
+ #define MISDNPORT_GSM (0)
+#endif
+
/* list of mISDN ports */
struct mISDNport *mISDNport_first;
{
char filename[256];
- init_af_isdn();
-
/* try to open raw socket to check kernel */
mISDNsocket = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE);
if (mISDNsocket < 0) {
- fprintf(stderr, "Cannot open mISDN due to '%s'. (Does your Kernel support socket based mISDN?)\n", strerror(errno));
+ fprintf(stderr, "Cannot open mISDN due to '%s'. (Does your Kernel support socket based mISDN? Protocol family is %d.)\n", strerror(errno), PF_ISDN);
return(-1);
}
mISDNport = mISDNport_first;
while(mISDNport) {
/* handle queued up-messages (d-channel) */
- if (!mISDNport->gsm) {
+ if (!MISDNPORT_GSM) {
while ((mb = mdequeue(&mISDNport->upqueue))) {
l3m = &mb->l3;
switch(l3m->type) {
if (!mISDNport->ntmode || mISDNport->ptp)
mISDNport->l2link = 0;
}
- if (!mISDNport->gsm && (!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127) {
+ if (!MISDNPORT_GSM && (!mISDNport->ntmode || mISDNport->ptp) && l3m->pid < 127) {
if (!mISDNport->l2establish.active && mISDNport->l2hold) {
PDEBUG(DEBUG_ISDN, "set timer and establish.\n");
schedule_timer(&mISDNport->l2establish, 5, 0);
{
struct mISDNport *mISDNport = (struct mISDNport *)instance;
- if (!mISDNport->gsm && mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode)) {
+ if (!MISDNPORT_GSM && mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode)) {
// PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link portnum=%d.\n", mISDNport->portnum);
mISDNport->ml3->to_layer3(mISDNport->ml3, MT_L2ESTABLISH, 0, NULL);
schedule_timer(&mISDNport->l2establish, 5, 0); /* 5 seconds */
int force_nt = ifport->nt;
int l1hold = ifport->l1hold;
int l2hold = ifport->l2hold;
- int gsm = ifport->gsm;
+ int gsm = 0;
int ss5 = ifport->ss5;
int i, cnt;
int pri, bri, pots;
struct mISDN_devinfo devinfo;
unsigned int protocol, prop;
+#if defined WITH_GSM_BS && defined WITH_GSM_MS
+ gsm = ifport->gsm_ms | ifport->gsm_bs;
+#else
+#ifdef WITH_GSM_BS
+ gsm = ifport->gsm_bs;
+#endif
+#ifdef WITH_GSM_MS
+ gsm = ifport->gsm_ms;
+#endif
+#endif
+
/* check port counts */
ret = ioctl(mISDNsocket, IMGETCOUNT, &cnt);
if (ret < 0) {
mISDNport->l1link = -1;
mISDNport->l2link = -1;
}
- mISDNport->gsm = gsm;
+#ifdef WITH_GSM_BS
+ mISDNport->gsm_bs = ifport->gsm_bs;
+#endif
+#ifdef WITH_GSM_MS
+ mISDNport->gsm_ms = ifport->gsm_ms;
+#endif
pmemuse++;
*mISDNportp = mISDNport;
prop |= (1 << MISDN_FLG_L2_HOLD);
/* open layer 3 and init upqueue */
if (gsm) {
+#if defined WITH_GSM_BS || defined WITH_GSM_MS
unsigned long on = 1;
struct sockaddr_mISDN addr;
mISDNport_close(mISDNport);
return(NULL);
}
+#endif
} else {
/* queue must be initializes, because l3-thread may send messages during open_layer3() */
mqueue_init(&mISDNport->upqueue);
}
/* if ptp, pull up the link */
- if (!mISDNport->gsm && mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode)) {
+ if (!MISDNPORT_GSM && mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode)) {
mISDNport->ml3->to_layer3(mISDNport->ml3, MT_L2ESTABLISH, 0, NULL);
l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
add_trace("tei", NULL, "%d", 0);
del_timer(&mISDNport->l2establish);
/* close layer 3, if open */
- if (!mISDNport->gsm && mISDNport->ml3) {
+ if (!MISDNPORT_GSM && mISDNport->ml3) {
close_layer3(mISDNport->ml3);
}
+#if defined WITH_GSM_BS || defined WITH_GSM_MS
/* close gsm socket, if open */
- if (mISDNport->gsm && mISDNport->lcr_sock > -1) {
+ if (MISDNPORT_GSM && mISDNport->lcr_sock > -1) {
close(mISDNport->lcr_sock);
}
+#endif
/* purge upqueue */
- if (!mISDNport->gsm)
+ if (!MISDNPORT_GSM)
mqueue_purge(&mISDNport->upqueue);
/* remove from list */