From: Mattias ?g. <mat...@us...> - 2001-03-02 12:34:24
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: fixed typo The diff of the modified file(s): --- btd.c 2001/03/02 10:59:57 1.1 +++ btd.c 2001/03/02 12:35:41 1.2 @@ -46,7 +46,7 @@ =20 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -= =20 =20 -Syntax: ./bti [options] +Syntax: ./btdm [options] =20=09=20=20=20=20=20 options:=20 =20=20=20 @@ -73,7 +73,7 @@ default: 115200 baud=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20=09 e.g - ./bti --reset --speed 460800 --physdev /dev/ttyS0 --local-name OpenBT + ./btdm --reset --speed 460800 --physdev /dev/ttyS0 --local-name OpenBT =20 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - = - */ =20 |
From: Olov H. <ol...@us...> - 2001-03-09 15:55:45
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added support for SIGTERM signal. Received by btdm when kill cmd is used. The diff of the modified file(s): --- btd.c 2001/03/02 12:35:41 1.2 +++ btd.c 2001/03/09 15:57:33 1.3 @@ -611,6 +611,7 @@ sigaction(SIGCHLD, &act, 0); /* Catches when pppd childs are done */ sigaction(SIGUSR1, &act, 0); /* Restart application */ sigaction(SIGUSR2, &act, 0); /* HW Upgrade ? */ + sigaction(SIGTERM, &act, 0); /* Received when kill cmd is used */ } =20 static void @@ -680,6 +681,8 @@ =20=20=20=20=20 return; } + else if(sig =3D=3D SIGTERM) + exit(0); } =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ |
From: Mattias A. <mat...@us...> - 2001-03-21 20:48:07
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: fixed communication with IPA server added option -i, --hwinit to set initial baud rate on physdev made strings used for building pppd options static added SIGTERM in sighandler to handle atexit() functionality fixed some warnings & minor changes The diff of the modified file(s): --- btd.c 2001/03/13 22:21:17 1.4 +++ btd.c 2001/03/21 20:48:04 1.5 @@ -50,6 +50,10 @@ =20=09=20=20=20=20=20 options:=20 =20=20=20 + -i, --hwinit=20 +=09 + default: ttyS0 +=20=20 -u, --physdev <uart device> Sets which uart device that will be used by the stack default: ttyS0 @@ -106,6 +110,8 @@ #include "bt_if.h" #include "bt_ipa.h" =20 +#define D(x) //x + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* PPPD stuff */ =20 @@ -129,13 +135,22 @@ struct peer_struct peerlist[BT_NBR_DATAPORTS]; struct ip_set ipsetlist[BT_NBR_DATAPORTS]; =20 +static unsigned char dev[20]; +static unsigned char ip_addresses[35]; +static unsigned char ms_dns1[35]; +static unsigned char ms_dns2[35]; +static unsigned char ms_wins1[35]; +static unsigned char ms_wins2[35]; +static unsigned char netmask[35]; + static fd_set rfd; static struct timeval tv; =20 #define PEER(line) (peerlist[line]) +#define IPSET(line) (ipsetlist[line]) #define STATE(line) (peerlist[line].state) =20 -char *pppd_options[32]; +static unsigned char *pppd_options[32]; =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* IPA stuff */ @@ -145,7 +160,7 @@ static struct ipa_msg *msg; static unsigned char ipa_buf[256]; static int parse_ipa_response(struct ipa_msg *msg); -static int ipa_sendrequest(int line, unsigned char bd[6], +static int ipa_sendrequest(int line, unsigned char *bd, unsigned short type); #endif =20 @@ -165,6 +180,7 @@ static char local_name[LOCAL_NAME_LENGTH+1]; /* 'friendly' name in HW modu= le */ static int do_hwinit =3D 1; /* do vendor specific initialization */ static int do_reset =3D 0; /* reset hw using I/O pins */ +static int init_hw_speed =3D 0; /* not set */ static int modem_emul =3D 1; /* default modem emulation is enabled */ static int phys_fd =3D -1; /* physical device e.g ttyS0 */ static jmp_buf jmpbuffer; /* used to jump back in program after doing rese= t */ @@ -189,7 +205,7 @@ static void btd_killchilds(void); static void sighandler(int sig); =20 -static void handle_new_connections(int bt_cfd); +static void discover_connections(int bt_cfd); static void build_pppdopts(int line, char **opts); static int start_pppd(int line, char *speedstr, char **opts); =20 @@ -210,13 +226,19 @@ } =20=20=20 /* now parse options */ -#define OPTIONS_STRING "mnRs:u:" +#define OPTIONS_STRING "i:m:nRs:u:" =20=20=20 while ((opt =3D getopt_long(argc, argv, OPTIONS_STRING, long_options, &option_index)) !=3D -1) { switch(opt) { + case 'i': + /* uart device */ + init_hw_speed =3D atoi(optarg); + syslog(LOG_INFO, "init_hw_speed %d baud\n", init_hw_speed); + break; + case 'm': /* uart device */ modem_emul =3D atoi(optarg); @@ -270,12 +292,16 @@ exit(1); } =20=20=20 + /* Sets initial HW baudrate */ + if (init_hw_speed !=3D 0) + fd_setup(phys_fd, init_hw_speed, 1); + else init_phys(phys_fd); =20=20=20 /* Set the current tty to the bluetooth discpline */ set_bt_line_disc(phys_fd, bt_disc, physdev); =20=20=20 - bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY); + bt_cfd =3D bt_openctrl(); =20=20=20 init_stack(bt_cfd, atoi(speedstr)); =20=20=20 @@ -284,24 +310,22 @@ =20=20=20 /* All initialized and ready to accept connections */ =20=20=20 - bt_waitnewconnections(bt_cfd); - syslog(LOG_INFO, "handle_new_connections"); - handle_new_connections(bt_cfd); + while (1) + { + int i, waiting_iparsp =3D 0; + tv.tv_sec =3D 1; + tv.tv_usec =3D 0; =20=20=20 FD_ZERO(&rfd);=20=20 FD_SET(ipa_fd, &rfd); FD_SET(0, &rfd); =20=20=20 - while (1) - { - int i; - tv.tv_sec =3D 2; - tv.tv_usec =3D 0; result =3D select(FD_SETSIZE, &rfd, (fd_set*)0,=20 (fd_set*)0, &tv); switch (result) { case 0: + { /* Timeout, check for new rfcomm cons */ =20=20=20=20=20=20=20 /* Check for outstanding IPA requests */ @@ -310,38 +334,42 @@ { if ((STATE(i) =3D=3D WAITING_PPPCONF) || (STATE(i) =3D=3D WAITING_RETURN_PPPCONF)) - break;=20=20 + { + D(syslog(LOG_INFO, "Waiting for IPA response\n")); + waiting_iparsp =3D 1; + } i++; } -=20=20=20=20=20=20 - /* If no outstanding IPA req, simply wait for new rfcomm */ - if (i =3D=3D BT_NBR_DATAPORTS) - bt_waitnewconnections(bt_cfd);=20=20=20=20=20 =20=20=20=20=20=20=20 - handle_new_connections(bt_cfd); + if (waiting_iparsp) + break; =20=20=20=20=20=20=20 + discover_connections(bt_cfd); + } break; =20=20=20=20=20=20=20 case -1: + {=20=20 /* Error */ perror("select"); + + /* FIXME -- e.g if ipa server restarts !!! */ + } break; =20=20=20=20=20=20=20 default: { /* Got data on some fd */ int i;=20=20=20=20=20=20=20=20 +=20 for (i=3D0; i < result; i++)=20 { -=20 #ifdef USE_IPASSIGN /* IPA response */ if (FD_ISSET(ipa_fd, &rfd)) { msg =3D (struct ipa_msg*) ipa_buf; -=20=20=20=20=20=20=20=20=20=20=20=20 /* Got response from IPA, if ok then start pppd or modem emul = */ - syslog(LOG_INFO, "IPA data\n");=20=20=20=20=20=20=20=20=20=20= =20=20 ipa_read(ipa_fd, msg); parse_ipa_response(msg); } @@ -357,41 +385,44 @@ } /* main */ =20=20 /* Checks for new connections and starts pppd/modememulator */ -static void handle_new_connections(int bt_cfd) +static void discover_connections(int bt_cfd) { int line; =20=20=20 - syslog(LOG_INFO, "handle_new_connections"); + D(syslog(LOG_INFO, "discover_connections")); for (line =3D 0; line < BT_NBR_DATAPORTS; line++) { - if ((STATE(line) =3D=3D NOCONNECTION) &&=20 bt_isconnected(bt_cfd, line)) { - syslog(LOG_INFO, "We got a new connection on line : %d !\n", line); + syslog(LOG_INFO, "Found connection on line : %d !\n", line); STATE(line) =3D CONNECTED; =20=20=20=20=20=20=20 read_remote_bd(bt_cfd, PEER(line).remote_bd); print_bd_addr("remote bd ", PEER(line).remote_bd); =20=20=20=20=20=20=20 #ifdef USE_IPASSIGN - syslog(LOG_INFO, "Sending IPA request\n"); + D(syslog(LOG_INFO, "Sending IPA request\n")); +=20=20=20=20=20=20 + PEER(line).ipset =3D &IPSET(line); + STATE(line) =3D WAITING_PPPCONF; - if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_GETIPSET) < 0) + if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd,=20 + IPAREQ_GETIPSET) < 0) { syslog(LOG_INFO, "IPA request failed or no IPA server"); =20 /* Build without IPA anyway */ STATE(line) =3D PPPCONF_DONE; - build_pppdopts(line, pppd_options);=20=20=20=20=20=20 - start_pppd(line, speedstr, pppd_options);=20=20=20=20=20 + build_pppdopts(line, (char**)pppd_options);=20=20=20=20=20=20 + start_pppd(line, speedstr, (char**)pppd_options);=20=20=20=20=20 } else - syslog(LOG_INFO, "IPA request sent"); + D(syslog(LOG_INFO, "IPA request sent")); #else STATE(line) =3D PPPCONF_DONE; - build_pppdopts(line, pppd_options);=20=20=20=20=20=20 - start_pppd(line, speedstr, pppd_options);=20=20=20=20=20 + build_pppdopts(line, (char**)pppd_options);=20=20=20=20=20=20 + start_pppd(line, speedstr, (char**)pppd_options);=20=20=20=20=20 #endif=20=20 } } @@ -400,35 +431,28 @@ /* only server */ void build_pppdopts(int line, char **opts) { -=20=20 int i=3D0; - char dev[20]; - char ip_addresses[35]; - char ms_dns1[35]; - char ms_dns2[35]; - char ms_wins1[35]; - char ms_wins2[35]; - char netmask[35]; struct ip_set *ipset =3D PEER(line).ipset; + char local_ip[20]; =20=20=20 #ifdef USE_IPASSIGN show_ipset(ipset, line); #endif =20=20=20 - syslog(LOG_INFO, "build_pppdopts\n"); + D(syslog(LOG_INFO, "build_pppdopts\n")); =20=20=20 sprintf(dev, "/dev/ttyBT%d",line); =20=20=20 /* general options */ - pppd_options[i++] =3D (char*)PPPDCMD; - pppd_options[i++] =3D dev; - pppd_options[i++] =3D speedstr; + opts[i++] =3D (char*)PPPDCMD; + opts[i++] =3D dev; + opts[i++] =3D speedstr; =20=20=20 /* move these to options file ? */ - pppd_options[i++] =3D "crtscts"; - pppd_options[i++] =3D "nopersist"; - pppd_options[i++] =3D "silent"; - pppd_options[i++] =3D "passive"; + opts[i++] =3D "crtscts"; + opts[i++] =3D "nopersist"; + opts[i++] =3D "silent"; + opts[i++] =3D "passive"; =20=20=20 /* check if we have used IPA */ if (ipset) @@ -439,75 +463,80 @@ /* Use radius ? */ if (ipset->useradius) { - pppd_options[i++] =3D "useradius"; - pppd_options[i++] =3D "auth"; - pppd_options[i++] =3D "login"; + opts[i++] =3D "useradius"; + opts[i++] =3D "auth"; + opts[i++] =3D "login"; =20=20=20=20=20=20=20 if (ipset->useradiusip) { - pppd_options[i++] =3D "useautoip"; + opts[i++] =3D "useautoip"; }=20=20=20 }=20=20 else=20 { - pppd_options[i++] =3D "noauth"; + opts[i++] =3D "noauth"; }=20=20 =20=20=20=20=20 if (ipset->proxyarp) { - pppd_options[i++] =3D "proxyarp"; + opts[i++] =3D "proxyarp"; /* ktune only works on pppd version > 2.3.10 */ /* similar as doing ' echo 1 > /proc/sys/net/ipv4/ip_forward */ - pppd_options[i++] =3D "ktune"; /* enables ip_forwarding */ + opts[i++] =3D "ktune"; /* enables ip_forwarding */ }=20=20 =20 + get_local_addr(local_ip); /* local/remote ip */ - sprintf(ip_addresses, "%s:%s", get_local_addr(),=20 + sprintf(ip_addresses, "%s:%s", local_ip,=20 inet_ntoa(ipset->ip)); =20=20=20=20=20 printf("IP used : %s\n", ip_addresses); =20=20=20=20=20 + opts[i++] =3D ip_addresses; +=20=20=20=20 /* DNS */ if (ipset->nbr_of_dns > 0) { - /* at lease one... */ - pppd_options[i++] =3D "ms-dns"; + /* at least one... */ + opts[i++] =3D "ms-dns"; sprintf(ms_dns1, "%s", inet_ntoa(ipset->dns[0])); - pppd_options[i++] =3D ms_dns1; + opts[i++] =3D ms_dns1; =20=20=20=20=20=20=20 if (ipset->nbr_of_dns > 1) { - pppd_options[i++] =3D "ms-dns"; + opts[i++] =3D "ms-dns"; sprintf(ms_dns2, "%s", inet_ntoa(ipset->dns[1])); - pppd_options[i++] =3D ms_dns2; + opts[i++] =3D ms_dns2; } } =20=20=20=20=20 /* WINS */ if (ipset->nbr_of_wins > 0) { - /* at lease one... */ - pppd_options[i++] =3D "ms-wins"; + /* at least one... */ + opts[i++] =3D "ms-wins"; sprintf(ms_wins1, "%s", inet_ntoa(ipset->wins[0])); - pppd_options[i++] =3D ms_wins1; + opts[i++] =3D ms_wins1; =20=20=20=20=20=20=20 if (ipset->nbr_of_wins > 1) { - pppd_options[i++] =3D "ms-wins"; - sprintf(ms_dns2, "%s", inet_ntoa(ipset->wins[1])); - pppd_options[i++] =3D ms_wins2; + opts[i++] =3D "ms-wins"; + sprintf(ms_wins2, "%s", inet_ntoa(ipset->wins[1])); + opts[i++] =3D ms_wins2; } } =20=20=20=20=20 /* Netmask */=20=20=20=20=20=20 - pppd_options[i++] =3D "netmask"; + opts[i++] =3D "netmask"; sprintf(netmask, "%s", inet_ntoa(ipset->netmask)); - pppd_options[i++] =3D netmask; + opts[i++] =3D netmask; } else { - /* local ip */ - sprintf(ip_addresses, "%s:", get_local_addr()); + get_local_addr(local_ip); +=20=20=20=20 + /* local IP */ + sprintf(ip_addresses, "%s:", local_ip); =20=20=20=20=20 /* Use /etc/ppp/options file for remote ppp settings. IPA is needed for correct multipoint setting or use a=20 @@ -515,26 +544,28 @@ options.ttyBT1 which contains the remote IP address,=20 dns, wins etc*/ =20=20=20=20=20 - syslog(LOG_INFO, "WARNING NO REMOTE IP SET, only local %s\n",=20 + syslog(LOG_INFO, "WARNING No remote ip addr set, only local %s",=20 ip_addresses); - printf("WARNING NO REMOTE IP SET, only local %s\n", ip_addresses); =20 + opts[i++] =3D ip_addresses; + /* always do proxyarp */=20 - pppd_options[i++] =3D "proxyarp"; + opts[i++] =3D "proxyarp"; =20 /* ktune only works on pppd version > 2.3.10 */ /* similar as doing ' echo 1 > /proc/sys/net/ipv4/ip_forward */ - pppd_options[i++] =3D "ktune"; /* enables ip_forwarding */ - } + opts[i++] =3D "ktune"; /* enables ip_forwarding */ =20=20=20 - pppd_options[i] =3D NULL; + } /* end -- no ipa */ =20=20=20 -#if 1 + opts[i] =3D NULL; +=20=20 +#if 0 /* print pppd_options */ i =3D 0; syslog(LOG_INFO, "pppd options used :"); - while (pppd_options[i]) - syslog(LOG_INFO, "%s", pppd_options[i++]); + while (opts[i]) + syslog(LOG_INFO, "%s", opts[i++]); #endif } =20 @@ -543,18 +574,16 @@ char dev[20]; =20=20=20 sprintf(dev, "/dev/ttyBT%d",line); - printf("start_pppd on %s at %s baud\n", dev, speedstr); =20=20=20 /* check state */ if (STATE(line) !=3D PPPCONF_DONE) { - syslog(LOG_INFO, "Warning : ppp config not done!!!\n"); + syslog(LOG_INFO, "Warning : ppp config not done (%d)\n", STATE(line)); return -1; } =20=20=20 if (PEER(line).do_modememul)=20 { - printf("Starting modem emulator...\n"); STATE(line) =3D MODEM_STARTED; =20=20=20=20=20 /* run modem emulator in a child */ @@ -565,9 +594,9 @@ /* replace first arg with MODEMEMULCMD (is handled by=20 modem emulator) */ =20=20=20=20=20=20=20 - pppd_options[0]=3D (char*)MODEMEMULCMD;=20=20=20=20=20=20 + opts[0]=3D (char*)MODEMEMULCMD; =20=20=20=20=20=20=20 - execvp(MODEMEMULCMD, pppd_options); + execvp(MODEMEMULCMD, opts); =20=20=20=20=20=20=20 fprintf(stderr, "%s: no such file or directory\n", MODEMEMULCMD); =20=20=20=20=20=20=20 @@ -578,14 +607,13 @@ } else { - printf("Starting pppd...\n"); STATE(line) =3D PPPD_STARTED; if (!(PEER(line).pppd_pid =3D vfork())) { syslog(LOG_INFO, "Starting pppd on %s", dev); =20=20=20=20=20=20=20 - /* FIXME -- use opts inparam and not static pppd_options */ - execvp(PPPDCMD, pppd_options); + /* FIXME -- use opts inparam and not static opts */ + execvp(PPPDCMD, opts); =20=20=20=20=20=20=20 fprintf(stderr, "%s: no such file or directory\n", PPPDCMD); =20=20=20=20=20=20=20 @@ -617,7 +645,7 @@ static void sighandler(int sig) { - printf("Sighandler : %d\n", sig); + syslog(LOG_INFO, "Sighandler got signal : %d\n", sig); =20=20=20 if (sig =3D=3D SIGUSR1) { @@ -629,9 +657,16 @@ {=20=20=20=20 /* Close down phys dev, run hw_upgrade and restart btd */ btd_cleanup(); - /* execvp(hw_upgrade_prog) */ +=20 + /* FIXME -- execvp(hw_upgrade_prog) */ +=20=20=20=20 longjmp(jmpbuffer, 1); } + else if (sig =3D=3D SIGTERM) /* ? */ + {=20 + syslog(LOG_INFO, "Got SIGTERM, now exiting"); + exit(0); + } else if (sig =3D=3D SIGCHLD)=20=20 { int line =3D 0, pid, status; @@ -665,18 +700,21 @@ syslog(LOG_INFO, "PPP line %d was shutdown\n", line); =20=20=20=20=20 #ifdef USE_IPASSIGN - /* FIXME -- Now release IPA settings */ - if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_RELEASEIPSET) <= 0) + STATE(line) =3D WAITING_RETURN_PPPCONF; + + if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd,=20 + IPAREQ_RELEASEIPSET) < 0) { syslog(LOG_INFO, "IPA request failed or no IPA server"); - /* check if still connected first ? */ + /* put peer into state NOCONNECTION, if still connected this + will be discovered in timout */ STATE(line) =3D NOCONNECTION;=20=20=20=20 }=20=20=20=20 #else - /* check if still connected first ? */ STATE(line) =3D NOCONNECTION;=20=20=20=20 #endif =20=20=20=20=20 + PEER(line).ipset =3D NULL; PEER(line).pppd_pid =3D -1; =20=20=20=20=20 return; @@ -691,6 +729,7 @@ static void init() {=20 int i; + btd_pid =3D write_pidfile(PID_FILE);=20=20 init_sighandler(); =20=20=20 @@ -714,6 +753,7 @@ if (ipa_fd < 0) { printf("Found no IPA server\n"); + exit(1);=20 } #endif =20=20=20 @@ -762,7 +802,6 @@ printf("btd_killchilds\n"); if (sdpsrv_pid > 0) { - printf("btd_killchilds SDP server\n"); syslog(LOG_INFO, "Killing SDP server\n"); kill(sdpsrv_pid, SIGTERM); =20=20=20=20=20 @@ -777,7 +816,6 @@ { if (STATE(line) =3D=3D PPPD_STARTED) { - printf("btd_killchilds PPP server on line %d\n", line); syslog(LOG_INFO, "Killing pppd on line %d\n", line); kill(PEER(line).pppd_pid, SIGTERM); if (waitpid(PEER(line).pppd_pid, NULL, 0) < 0) @@ -792,20 +830,20 @@ =20 #ifdef USE_IPASSIGN =20 -static int ipa_sendrequest(int line, unsigned char bd[6], unsigned short t= ype) +static int ipa_sendrequest(int line, unsigned char *bd, unsigned short typ= e) { unsigned char buf[IPA_MSG_MAXSIZE]; struct ipa_msg *msg; struct ipa_request *req; =20=20=20 - printf("ipa_request : type %d\n", type); + D(syslog(LOG_INFO, "ipa_request : type %d\n", type)); =20=20=20 msg =3D (struct ipa_msg*)buf; msg->type =3D type; msg->len =3D sizeof(struct ipa_request); req =3D (struct ipa_request*)msg->msg; req->id =3D line; - memcpy(&req->remote_bd, &bd, 6);=20 + memcpy(&req->remote_bd, bd, 6);=20 return ipa_write(ipa_fd, msg); } =20 @@ -816,20 +854,28 @@ case IPARSP_STATUS: { ipa_status *rsp =3D (struct ipa_status*)(msg->msg); - syslog(LOG_INFO, "ipa_parse_msg : got status %d on line\n",=20 - rsp->status, rsp->id);=20=20 + D(syslog(LOG_INFO, "ipa_parse_msg : got status %d on line\n",=20 + rsp->status, rsp->id)); =20=20=20=20=20=20=20 /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) - printf("parse_ipa_response : request failed [line:%d]\n", rsp->id); + syslog(LOG_INFO, "parse_ipa_response : request failed [line:%d]\n"= ,=20 + rsp->id); + else + D(syslog(LOG_INFO, "parse_ipa_response : request succeeded [line:%d]\n", = rsp->id)); =20=20=20=20=20=20=20 + /* put peer into NOCONNECTION, if still connected this will=20 + be discovered from timeout */ + + STATE(rsp->id) =3D NOCONNECTION; + return rsp->status; } =20=20=20=20=20 case IPARSP_PEERSETTINGS: { ipa_response* rsp =3D (struct ipa_response*)(msg->msg); - syslog(LOG_INFO, "ipa_parse_msg : got client settings\n");=20=20=20= =20=20=20 + D(syslog(LOG_INFO, "ipa_parse_msg : got client settings\n")); =20=20=20=20=20=20=20 /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) @@ -842,12 +888,17 @@ /* Store ipa settings in peer struct */ memcpy(PEER(rsp->id).ipset, &rsp->set, msg->len); =20=20=20=20=20=20=20 - /* print settings ! */ - show_ipset(PEER(rsp->id).ipset, rsp->id); + /* Now proceed to next state */ + if (PEER(rsp->id).state =3D=3D WAITING_PPPCONF) + { + PEER(rsp->id).state =3D PPPCONF_DONE; + }=20=20=20=20=20=20 + else + syslog(LOG_INFO, "Warning : Wrong state on line %d, should have been WAIT= ING_PPPCONF", rsp->id); =20=20=20=20=20=20=20 /* Build options and start ppp */ - build_pppdopts(rsp->id, pppd_options); - start_pppd(rsp->id, speedstr, pppd_options); + build_pppdopts(rsp->id, (char**)pppd_options); + start_pppd(rsp->id, speedstr, (char**)pppd_options); return 0; }=20 =20=20=20=20=20 |
From: Mattias A. <mat...@us...> - 2001-03-26 15:30:37
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: btd now retries if IPA server is not responding forgot to set peer state to PPP_CONFDONE after successfully received ipa pa= rs added state checks when parsing ipa responses added ipa error return values fixed typos The diff of the modified file(s): --- btd.c 2001/03/21 20:48:04 1.5 +++ btd.c 2001/03/26 15:30:36 1.6 @@ -360,25 +360,26 @@ default: { /* Got data on some fd */ - int i;=20=20=20=20=20=20=20=20 + int i, retval; =20=20 +#ifdef USE_IPASSIGN=20 for (i=3D0; i < result; i++)=20 { -#ifdef USE_IPASSIGN /* IPA response */ if (FD_ISSET(ipa_fd, &rfd)) { msg =3D (struct ipa_msg*) ipa_buf; /* Got response from IPA, if ok then start pppd or modem emul = */ ipa_read(ipa_fd, msg); - parse_ipa_response(msg); + if ((retval =3D parse_ipa_response(msg)) < 0) + { + /* FIXME -- we got an error. Reset peer ? */ + syslog(LOG_INFO, "Got IPA error %d", retval); } -#else - /* Got data on a line */ - printf("Other data (?)\n"); -#endif=09=20=20 }=20 } +#endif + } break; }=20=20=20=20 } /* while */ @@ -749,12 +750,27 @@ =20=20=20 #ifdef USE_IPASSIGN /* Look for IPA server */ + ipa_fd =3D -1; + i =3D 1; + while (ipa_fd < 0)=20 + {=20=20 ipa_fd =3D open_socket(IPASERVER, CLIENT); if (ipa_fd < 0) { - printf("Found no IPA server\n"); + syslog(LOG_INFO, "Found no IPA server"); + + if (i > 8) + {=20=20 exit(1);=20 } + else + { + syslog(LOG_INFO, "Retrying in %d sec", i); + sleep(i); + i*=3D2; + }=20=20=20=20=20=20 + }=20 + }=20 #endif =20=20=20 if (modem_emul =3D=3D 1) @@ -854,13 +870,23 @@ case IPARSP_STATUS: { ipa_status *rsp =3D (struct ipa_status*)(msg->msg); - D(syslog(LOG_INFO, "ipa_parse_msg : got status %d on line\n",=20 + D(syslog(LOG_INFO, "parse_ipa_response : got status %d on line\n",= =20 rsp->status, rsp->id)); =20=20=20=20=20=20=20=20=20 + /* Check state */ + if (STATE(rsp->id) !=3D WAITING_RETURN_PPPCONF) + { + syslog(LOG_INFO, "parse_ipa_response : wrong state"); + return -ERR_WRONGSTATE; + } + /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) + { syslog(LOG_INFO, "parse_ipa_response : request failed [line:%d]\n"= ,=20 rsp->id); + return -IPA_STATUSFAILED; + }=20=20=20=20=20=20 else D(syslog(LOG_INFO, "parse_ipa_response : request succeeded [line:%d]\n", = rsp->id)); =20 @@ -869,32 +895,33 @@ =20 STATE(rsp->id) =3D NOCONNECTION; =20 - return rsp->status; + return 0; } =20=20=20=20=20 case IPARSP_PEERSETTINGS: { ipa_response* rsp =3D (struct ipa_response*)(msg->msg); - D(syslog(LOG_INFO, "ipa_parse_msg : got client settings\n")); + D(syslog(LOG_INFO, "parse_ipa_response : got client settings\n")); =20=20=20=20=20=20=20 + /* Check state */ + if (STATE(rsp->id) !=3D WAITING_PPPCONF) + { + syslog(LOG_INFO, "parse_ipa_response : wrong state"); + return -ERR_WRONGSTATE; + } + /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) { /* error */ printf("parse_ipa_response : failed to get client settings\n"); - return rsp->status; + return -ERR_REQUESTFAILED; } =20 /* Store ipa settings in peer struct */ memcpy(PEER(rsp->id).ipset, &rsp->set, msg->len); =20 - /* Now proceed to next state */ - if (PEER(rsp->id).state =3D=3D WAITING_PPPCONF) - { PEER(rsp->id).state =3D PPPCONF_DONE; - }=20=20=20=20=20=20 - else - syslog(LOG_INFO, "Warning : Wrong state on line %d, should have been WAIT= ING_PPPCONF", rsp->id); =20 /* Build options and start ppp */ build_pppdopts(rsp->id, (char**)pppd_options); @@ -903,6 +930,7 @@ }=20 =20=20=20=20=20 default : + syslog(LOG_INFO, "Error : Unknown message type"); break; } return 0; |
From: Peter K. <pk...@us...> - 2001-04-17 18:09:16
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Do not add ipa_fd to the set of selected file descriptos if USE_IPASSIGN is not defined. * The --modem-emul (-m) option now has an effect again. * Removed some unnecessary includes. The diff of the modified file(s): --- btd.c 2001/04/04 10:43:04 1.7 +++ btd.c 2001/04/17 18:09:15 1.8 @@ -81,26 +81,17 @@ =20 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - = - */ =20 -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <fcntl.h> -#include <time.h> #include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <termios.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> +#include <fcntl.h> #include <syslog.h> -#include <errno.h> -#include <stdarg.h> -#include <signal.h> #include <getopt.h> #include <setjmp.h> - -/* inet_ntoa */ +#include <termios.h> +#include <sys/ioctl.h> +#include <sys/wait.h> #include <arpa/inet.h> =20 #include "btd.h" @@ -155,8 +146,8 @@ /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* IPA stuff */ =20 -static int ipa_fd =3D -1; #ifdef USE_IPASSIGN +static int ipa_fd =3D -1; static struct ipa_msg *msg; static unsigned char ipa_buf[256]; static int parse_ipa_response(struct ipa_msg *msg); @@ -316,11 +307,12 @@ tv.tv_usec =3D 0; =20 FD_ZERO(&rfd);=20=20 +#ifdef USE_IPASSIGN FD_SET(ipa_fd, &rfd); +#endif FD_SET(0, &rfd); =20 - result =3D select(FD_SETSIZE, &rfd, (fd_set*)0,=20 - (fd_set*)0, &tv); + result =3D select(FD_SETSIZE, &rfd, NULL, NULL, &tv); switch (result) { case 0: @@ -487,8 +479,7 @@ =20=20=20=20=20 get_local_addr(local_ip); /* local/remote ip */ - sprintf(ip_addresses, "%s:%s", local_ip,=20 - inet_ntoa(ipset->ip)); + sprintf(ip_addresses, "%s:%s", local_ip, inet_ntoa(ipset->ip)); =20=20=20=20=20 printf("IP used : %s\n", ip_addresses); =20 @@ -602,9 +593,12 @@ =20=20=20=20=20=20=20 _exit(0); }=20 + else if (PEER(line).pppd_pid > 0) + { syslog(LOG_INFO, "Started modem emulator on %s [pid : %d]",=20 dev, PEER(line).pppd_pid);=20 } + } else { STATE(line) =3D PPPD_STARTED; @@ -619,6 +613,10 @@ =20=20=20=20=20=20=20 _exit(0); }=20 + else if (PEER(line).pppd_pid > 0) + { + D(syslog(LOG_INFO, "Started pppd on %s [pid: %d]", dev, PEER(line).p= ppd_pid)); + } } =20=20=20 return 0;=20 @@ -743,7 +741,7 @@ { PEER(i).state =3D NOCONNECTION; PEER(i).pppd_pid =3D -1; - PEER(i).do_modememul =3D 1; /* all enabled per default */ + PEER(i).do_modememul =3D modem_emul; PEER(i).ipset =3D NULL; }=20=20 =20=20=20 |
From: Peter K. <pk...@us...> - 2001-04-18 14:02:27
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Ok, so I removed two includes too many. Include signal.h and sys/time.h again. The diff of the modified file(s): --- btd.c 2001/04/17 18:09:15 1.8 +++ btd.c 2001/04/18 14:02:24 1.9 @@ -86,11 +86,13 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> +#include <signal.h> #include <syslog.h> #include <getopt.h> #include <setjmp.h> #include <termios.h> #include <sys/ioctl.h> +#include <sys/time.h> #include <sys/wait.h> #include <arpa/inet.h> =20 |
From: Mattias A. <mat...@us...> - 2001-04-25 17:58:25
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added close of ipa_fd when shutting down * minor changes The diff of the modified file(s): --- btd.c 2001/04/18 14:02:24 1.9 +++ btd.c 2001/04/25 17:58:24 1.10 @@ -270,6 +270,7 @@ if (setjmp(jmpbuffer) !=3D 0) { syslog(LOG_INFO, "restart...\n\n\n\n"); + sleep(1); } =20=20=20 init(); @@ -781,7 +782,7 @@ static void btd_cleanup(void) { - printf("btd_cleanup\n"); + syslog(LOG_INFO, "btd_cleanup\n"); btd_killchilds(); =20=20=20 printf("shutdown_stack\n"); @@ -803,6 +804,15 @@ phys_fd =3D -1; } =20=20=20 +#ifdef USE_IPASSIGN + if (ipa_fd !=3D -1) + { + syslog(LOG_INFO, "closing IPA"); + tcflush(ipa_fd, TCIOFLUSH); + close(ipa_fd); + ipa_fd =3D -1; + } +#endif=20 /* pid_fd is set if we created the pid file when we started */ if (btd_pid !=3D -1) { |
From: Olov H. <ol...@us...> - 2001-05-23 11:43:01
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.14 1.15=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added remote_bd as option to pppd The diff of the modified file(s): --- btd.c 2001/05/17 10:23:01 1.14 +++ btd.c 2001/05/23 11:42:59 1.15 @@ -135,6 +135,8 @@ static unsigned char ms_wins1[35]; static unsigned char ms_wins2[35]; static unsigned char netmask[35]; +static char bd_str[18]; + =20 static fd_set rfd; static struct timeval tv; @@ -361,6 +363,8 @@ /* IPA response */ if (FD_ISSET(ipa_fd, &rfd)) { +=09=20=20=20=20 +=09=20=20=20=20 msg =3D (struct ipa_msg*) ipa_buf; /* Got response from IPA, if ok then start pppd or modem emul = */ ipa_read(ipa_fd, msg); @@ -462,6 +466,17 @@ opts[i++] =3D "useradius"; opts[i++] =3D "auth"; opts[i++] =3D "login"; + opts[i++] =3D "remotebdaddr"; + + sprintf(bd_str, "%02x:%02x:%02x:%02x:%02x:%02x",=20 + PEER(line).remote_bd[0],=20 + PEER(line).remote_bd[1],=20 + PEER(line).remote_bd[2],=20 + PEER(line).remote_bd[3],=20 + PEER(line).remote_bd[4],=20 + PEER(line).remote_bd[5]); +=20=20=20=20=20=20 + opts[i++] =3D bd_str; =20=20=20=20=20=20=20 if (ipset->useradiusip) { |
From: Ulf H. <ul...@us...> - 2001-05-23 14:03:44
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.15 1.16=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added missing pppd options The diff of the modified file(s): --- btd.c 2001/05/23 11:42:59 1.15 +++ btd.c 2001/05/23 14:03:43 1.16 @@ -135,8 +135,8 @@ static unsigned char ms_wins1[35]; static unsigned char ms_wins2[35]; static unsigned char netmask[35]; -static char bd_str[18]; - +static char remote_bd_str[18]; +static char local_bd_str[18]; =20 static fd_set rfd; static struct timeval tv; @@ -436,6 +436,7 @@ struct ip_set *ipset =3D PEER(line).ipset; char local_ip[20]; =20 +=20=20 if (ipa_available) show_ipset(ipset, line); =20=20=20 @@ -463,12 +464,29 @@ /* Use radius ? */ if (ipset->useradius) { + unsigned char local_bd[6]; +=20=20=20=20=20=20 opts[i++] =3D "useradius"; opts[i++] =3D "auth"; opts[i++] =3D "login"; +=20=20=20=20=20=20 + opts[i++] =3D "localbdaddr"; + + read_local_bd(bt_cfd, local_bd); +=20=20=20=20=20=20=20=20 + sprintf(local_bd_str, "%02x:%02x:%02x:%02x:%02x:%02x",=20 + local_bd[0],=20 + local_bd[1],=20 + local_bd[2],=20 + local_bd[3],=20 + local_bd[4],=20 + local_bd[5]); +=20=20=20=20=20=20 + opts[i++] =3D local_bd_str; + opts[i++] =3D "remotebdaddr"; =20 - sprintf(bd_str, "%02x:%02x:%02x:%02x:%02x:%02x",=20 + sprintf(remote_bd_str, "%02x:%02x:%02x:%02x:%02x:%02x",=20 PEER(line).remote_bd[0],=20 PEER(line).remote_bd[1],=20 PEER(line).remote_bd[2],=20 @@ -476,7 +494,7 @@ PEER(line).remote_bd[4],=20 PEER(line).remote_bd[5]); =20=20=20=20=20=20=20 - opts[i++] =3D bd_str; + opts[i++] =3D remote_bd_str; =20=20=20=20=20=20=20 if (ipset->useradiusip) { @@ -495,6 +513,12 @@ /* similar as doing ' echo 1 > /proc/sys/net/ipv4/ip_forward */ opts[i++] =3D "ktune"; /* enables ip_forwarding */ }=20=20 + + if (ipset->usingmasq) + { + pppd_options[i++] =3D "usingmasq"; + } + =20=20=20=20=20 strcpy(local_ip, get_local_ip_address()); /* local/remote ip */ |
From: Peter K. <pk...@us...> - 2001-05-31 12:18:39
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.16 1.17=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Use sigsetjmp()/siglongjmp() instead of setjmp()/longjmp() as we need to call siglongjmp() from a signal handler. The diff of the modified file(s): --- btd.c 2001/05/23 14:03:43 1.16 +++ btd.c 2001/05/31 12:18:38 1.17 @@ -179,7 +179,7 @@ static int sdpsrv_pid =3D 0; static int bt_cfd =3D -1; /* control tty for bt stack */ static int phys_fd =3D -1; /* physical device e.g ttyS0 */ -static jmp_buf jmpbuffer; /* used to jump back in program after doing rese= t */ +static sigjmp_buf jmpbuffer; /* used to jump back in program after doing r= eset */ =20 =20 /* long option list */ @@ -267,7 +267,7 @@ } =20=20=20 /* Set restart point */ - if (setjmp(jmpbuffer) !=3D 0) + if (sigsetjmp(jmpbuffer, 1) !=3D 0) { syslog(LOG_INFO, "restart...\n\n\n\n"); sleep(1); @@ -345,11 +345,14 @@ =20=20=20=20=20=20=20 case -1: {=20=20 + if (errno !=3D EINTR) + { /* Error */ perror("select"); =20 /* FIXME -- e.g if ipa server restarts !!! */ } + } break; =20=20=20=20=20=20=20 default: @@ -363,8 +366,6 @@ /* IPA response */ if (FD_ISSET(ipa_fd, &rfd)) { -=09=20=20=20=20 -=09=20=20=20=20 msg =3D (struct ipa_msg*) ipa_buf; /* Got response from IPA, if ok then start pppd or modem emul = */ ipa_read(ipa_fd, msg); @@ -692,16 +693,16 @@ { /* Shutdown all and restart */ btd_cleanup(); - longjmp(jmpbuffer, 1); + siglongjmp(jmpbuffer, 1); } else if (sig =3D=3D SIGUSR2) /* ? */ {=20=20=20=20 /* Close down phys dev, run hw_upgrade and restart btd */ - btd_cleanup(); +// btd_cleanup(); =20=20 /* FIXME -- execvp(hw_upgrade_prog) */ =20=20=20=20=20 - longjmp(jmpbuffer, 1); +// siglongjmp(jmpbuffer, 1); } else if (sig =3D=3D SIGTERM) /* ? */ {=20 |
From: Mattias A. <mat...@us...> - 2001-06-06 15:05:40
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Moved reset of hw closer to init_stack * Check twice as often for new rfcomm cons (select timer 0,5 sec) The diff of the modified file(s): --- btd.c 2001/05/31 12:18:38 1.17 +++ btd.c 2001/06/06 15:05:40 1.18 @@ -181,7 +181,6 @@ static int phys_fd =3D -1; /* physical device e.g ttyS0 */ static sigjmp_buf jmpbuffer; /* used to jump back in program after doing r= eset */ =20 - /* long option list */ static struct option long_options[] =3D { @@ -275,10 +274,6 @@ =20=20=20 init(); =20 - /* Hardreset of BT hardware */ - if (do_reset) - reset_hw(); -=20=20 if ((phys_fd =3D open(physdev, O_RDWR | O_NOCTTY)) < 0) { perror("could not open phys dev\n"); @@ -287,7 +282,8 @@ =20 /* Sets initial HW baudrate */ if (init_hw_speed !=3D 0) - fd_setup(phys_fd, init_hw_speed, USE_FLOW_CTRL, hw_vendor() =3D=3D HW_= CSR_BCSP); + fd_setup(phys_fd, init_hw_speed,=20 + USE_FLOW_CTRL, hw_vendor() =3D=3D HW_CSR_BCSP); else init_phys(phys_fd); =20 @@ -296,6 +292,12 @@ =20=20=20 bt_cfd =3D bt_openctrl(); =20=20=20 + tcflush(phys_fd, TCIOFLUSH); + + /* Hardreset of BT hardware */ + if (do_reset) + reset_hw(); + init_stack(bt_cfd, atoi(speedstr)); =20=20=20 if (do_hwinit) @@ -306,8 +308,8 @@ while (1) { int i, waiting_iparsp =3D 0; - tv.tv_sec =3D 1; - tv.tv_usec =3D 0; + tv.tv_sec =3D 0; + tv.tv_usec =3D 500000; =20 FD_ZERO(&rfd);=20=20 =20 @@ -437,7 +439,6 @@ struct ip_set *ipset =3D PEER(line).ipset; char local_ip[20]; =20 -=20=20 if (ipa_available) show_ipset(ipset, line); =20=20=20 @@ -470,7 +471,6 @@ opts[i++] =3D "useradius"; opts[i++] =3D "auth"; opts[i++] =3D "login"; -=20=20=20=20=20=20 opts[i++] =3D "localbdaddr"; =20 read_local_bd(bt_cfd, local_bd); @@ -701,7 +701,6 @@ // btd_cleanup(); =20 /* FIXME -- execvp(hw_upgrade_prog) */ - // siglongjmp(jmpbuffer, 1); } else if (sig =3D=3D SIGTERM) /* ? */ |
From: Mattias A. <mat...@us...> - 2001-06-13 12:38:11
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.19 1.20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added call to init_failed if init_stack failed... The diff of the modified file(s): --- btd.c 2001/06/08 09:55:47 1.19 +++ btd.c 2001/06/13 12:18:00 1.20 @@ -300,7 +300,8 @@ if (do_reset) reset_hw(); =20 - init_stack(bt_cfd, atoi(speedstr)); + if (init_stack(bt_cfd, atoi(speedstr)) < 0) + init_failed(bt_cfd, phys_fd, atoi(speedstr)); =20 if (do_hwinit) init_hw(bt_cfd, phys_fd, atoi(speedstr)); |
From: Mats F. <ma...@us...> - 2001-06-14 15:13:25
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.20 1.21=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Disconnect bluetooth link if IPA fails The diff of the modified file(s): --- btd.c 2001/06/13 12:18:00 1.20 +++ btd.c 2001/06/14 15:13:23 1.21 @@ -376,11 +376,24 @@ ipa_read(ipa_fd, msg); if ((retval =3D parse_ipa_response(msg)) < 0) { - /* FIXME -- we got an error. Reset peer ? */ - syslog(LOG_INFO, "Got IPA error %d", retval); + unsigned int con_id; + int line =3D ((struct ipa_status*)(msg->msg))->id; + syslog(LOG_INFO, "Got IPA error %d, disconnecting line %d", retval,= line); +=09=20=20=20=20=20=20 + con_id =3D CREATE_RFCOMM_ID(line, 0); +=09=20=20=20=20=20=20 + if (bt_disconnect(bt_cfd, con_id) < 0) + { + /* FIXME: What to do if disconnection fails */ + syslog(LOG_INFO, "Disconnection failed"); + } + else + { + STATE(line) =3D NOCONNECTION; }=20=20=20=20=20=20=20=20=20=20=20 } }=20 + }=20 #endif } break; @@ -929,7 +942,7 @@ /* Check state */ if (STATE(rsp->id) !=3D WAITING_RETURN_PPPCONF) { - syslog(LOG_INFO, __FUNCTION__ ": Wrong state"); + syslog(LOG_INFO, __FUNCTION__ ": Wrong state (case IPARSP_STATUS)"= ); return -ERR_WRONGSTATE; } =20 @@ -959,7 +972,7 @@ /* Check state */ if (STATE(rsp->id) !=3D WAITING_PPPCONF) { - syslog(LOG_INFO, __FUNCTION__ ": Wrong state"); + syslog(LOG_INFO, __FUNCTION__ ": Wrong state case (IPARSP_PEERSETT= INGS)"); return -ERR_WRONGSTATE; } =20 |
From: Peter K. <pk...@us...> - 2001-09-05 15:33:47
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.24 1.25=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Removed redundant code. The diff of the modified file(s): --- btd.c 2001/08/29 10:02:05 1.24 +++ btd.c 2001/09/05 15:33:46 1.25 @@ -776,8 +776,6 @@ =20=20=20=20=20 return; } - else if(sig =3D=3D SIGTERM) - exit(0); } =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ |
From: Peter K. <pk...@us...> - 2001-09-13 12:20:53
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.27 1.28=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Use ipa_fd to check if an IP assigner is used instead of ipa_available. The diff of the modified file(s): --- btd.c 2001/09/10 09:41:50 1.27 +++ btd.c 2001/09/13 12:20:52 1.28 @@ -168,7 +168,6 @@ static int do_hwinit =3D 1; /* do vendor specific initialization */ static int do_reset =3D 0; /* reset hw using I/O pins */ =20 -static int ipa_available =3D 0; /* is set if IPA was successfully initiali= zed */ static int modem_emul =3D 1; /* default modem emulation is enabled */ static int init_hw_speed =3D 0; /* not set */ =20 @@ -323,7 +322,7 @@ =20 FD_ZERO(&rfd);=20=20 =20 - if (ipa_available) + if (ipa_fd >=3D 0) FD_SET(ipa_fd, &rfd); =20=20=20=20=20 FD_SET(0, &rfd); @@ -371,12 +370,10 @@ { #ifdef USE_IPASSIGN /* Got data on some fd */ - int i, retval; + int retval; =20 - for (i =3D 0; i < result; i++)=20 - { /* IPA response */ - if (FD_ISSET(ipa_fd, &rfd)) + if (ipa_fd >=3D 0 && FD_ISSET(ipa_fd, &rfd)) { msg =3D (struct ipa_msg*) ipa_buf; /* Got response from IPA, if ok then start pppd or modem emul = */ @@ -400,7 +397,6 @@ } }=20=20=20=20=20=20=20=20=20=20=20 } - }=20 #endif } break; @@ -425,7 +421,7 @@ read_remote_bd(bt_cfd, line, PEER(line).remote_bd); printf("Remote bd: %s\n", bd2str(PEER(line).remote_bd)); =20=20=20=20=20=20=20 - if (ipa_available) + if (ipa_fd >=3D 0) {=20=20 D(syslog(LOG_INFO, "Sending IPA request")); =20=20=20=20=20=20=20=20=20 @@ -462,7 +458,7 @@ struct ip_set *ipset =3D PEER(line).ipset; char local_ip[20]; =20=20=20 - if (ipa_available) + if (ipa_fd >=3D 0) show_ipset(ipset, line); =20=20=20 D(syslog(LOG_INFO, __FUNCTION__)); @@ -760,7 +756,7 @@ =20=20=20=20=20 D(syslog(LOG_INFO, "PPP line %d was shutdown", line)); =20=20=20=20=20 - if (ipa_available)=20 + if (ipa_fd >=3D 0) {=20 STATE(line) =3D WAITING_RETURN_PPPCONF; =20=20=20=20=20=20=20 @@ -834,7 +830,6 @@ else=20 {=20=20=20=20=20=20 D(syslog(LOG_INFO, "Found IPA server")); - ipa_available =3D 1; } }=20 #endif |
From: Peter K. <pk...@us...> - 2001-10-05 14:14:17
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.29 1.30=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Do not select() on stdin. The diff of the modified file(s): --- btd.c 2001/10/03 17:47:47 1.29 +++ btd.c 2001/10/05 14:14:16 1.30 @@ -317,7 +317,6 @@ =20=20=20 while (1) { - int i, waiting_iparsp =3D 0; tv.tv_sec =3D 0; tv.tv_usec =3D 500000; =20 @@ -326,17 +325,14 @@ if (ipa_fd >=3D 0) FD_SET(ipa_fd, &rfd); =20=20=20=20=20 - FD_SET(0, &rfd); - result =3D select(FD_SETSIZE, &rfd, NULL, NULL, &tv); switch (result) { case 0: { - /* Timeout, check for new rfcomm cons */ - +#ifdef USE_IPASSIGN /* Check for outstanding IPA requests */ - i =3D 0; + int i =3D 0, waiting_iparsp =3D 0; while (i < BT_NBR_DATAPORTS) { if ((STATE(i) =3D=3D WAITING_PPPCONF) || @@ -350,20 +346,21 @@ =20=20=20=20=20=20=20=20=20 if (waiting_iparsp) break; +#endif +=20=20=20=20=20=20=20=20 + /* Timeout, check for new rfcomm cons */ =20=20=20=20=20=20=20=20=20 discover_connections(bt_cfd); } break; =20=20=20=20=20=20=20 case -1: - { if (errno !=3D EINTR) { /* Error */ perror("select"); =20 /* FIXME -- e.g if ipa server restarts !!! */ - } } break; =20=20=20=20=20=20=20 |
From: Peter K. <pk...@us...> - 2001-10-15 13:50:39
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.30 1.31=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Removed a couple of unnecessary &. The diff of the modified file(s): --- btd.c 2001/10/05 14:14:16 1.30 +++ btd.c 2001/10/15 13:50:39 1.31 @@ -426,8 +426,7 @@ PEER(line).ipset =3D &IPSET(line); =20=20=20=20=20=20=20=20=20 STATE(line) =3D WAITING_PPPCONF; - if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd,= =20 - IPAREQ_GETIPSET) < 0) + if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_GETIPSET) <= 0) { syslog(LOG_INFO, "IPA request failed or no IPA server"); =20=20=20=20=20=20=20=20=20=20=20 @@ -758,8 +757,7 @@ {=20 STATE(line) =3D WAITING_RETURN_PPPCONF; =20=20=20=20=20=20=20 - if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd,=20 - IPAREQ_RELEASEIPSET) < 0) + if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_RELEASEIPSET)= < 0) { syslog(LOG_INFO, "IPA request failed or no IPA server"); /* put peer into state NOCONNECTION, if still connected this @@ -923,7 +921,7 @@ msg->len =3D sizeof(struct ipa_request); req =3D (struct ipa_request*)msg->msg; req->id =3D line; - memcpy(&req->remote_bd, bd, 6);=20 + memcpy(req->remote_bd, bd, 6);=20 return ipa_write(ipa_fd, msg); } =20 @@ -933,7 +931,7 @@ { case IPARSP_STATUS: { - ipa_status *rsp =3D (struct ipa_status*)(msg->msg); + ipa_status *rsp =3D (struct ipa_status*)msg->msg; D(syslog(LOG_INFO, __FUNCTION__ ": Got status %d on line %d",=20 rsp->status, rsp->id)); =20 @@ -964,7 +962,7 @@ =20=20=20=20=20 case IPARSP_PEERSETTINGS: { - ipa_response* rsp =3D (struct ipa_response*)(msg->msg); + ipa_response* rsp =3D (struct ipa_response*)msg->msg; D(syslog(LOG_INFO, __FUNCTION__ ": Got client settings")); =20=20=20=20=20=20=20 /* Check state */ |
From: Anders J. <and...@us...> - 2001-11-22 14:42:53
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.32 1.33=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Added option -I, --use-ipa, to enable btdm to use IPA. The diff of the modified file(s): --- btd.c 2001/10/16 15:02:20 1.32 +++ btd.c 2001/11/22 14:42:52 1.33 @@ -80,6 +80,10 @@ force uart communication to not use CTS and RTS default: flow control activated if defined hardware support it =20 + -I, --use-ipa + enable use of ipa + default: not enabled + e.g ./btdm --reset --speed 460800 --physdev /dev/ttyS0 --local-name OpenBT ./btdm --reset --speed 1000000/1 --physdev /dev/ttyS0 --local-name Open= BT @@ -188,6 +192,8 @@ static int phys_fd =3D -1; /* physical device e.g ttyS0 */ static sigjmp_buf jmpbuffer; /* used to jump back in program after doing r= eset */ =20 +static int use_ipa =3D 0;=20 + /* long option list */ static struct option long_options[] =3D { @@ -198,6 +204,7 @@ { "local-name", 1, NULL, 'n' }, /* set local bluetooth name */ { "reset", 0, NULL, 'R' }, /* reset BT HW */ { "speed", 1, NULL, 's' }, /* uart speed towards hw */ + { "use-ipa", 0, NULL, 'I' }, { 0, 0, 0, 0 } }; =20 @@ -230,7 +237,7 @@ } =20=20=20 /* now parse options */ - while ((opt =3D getopt_long(argc, argv, "fi:m:nRs:u:", + while ((opt =3D getopt_long(argc, argv, "fi:m:nRs:u:I", long_options, &option_index)) !=3D -1) { switch(opt) @@ -275,6 +282,10 @@ D(syslog(LOG_INFO, "phys dev: %s", optarg)); physdev =3D optarg; break; + case 'I': + D(syslog(LOG_INFO, "using IPA")); + use_ipa =3D 1; + break; =20 default: break; @@ -335,7 +346,7 @@ =20 FD_ZERO(&rfd);=20=20 =20 - if (ipa_fd >=3D 0) + if (use_ipa && (ipa_fd >=3D 0)) FD_SET(ipa_fd, &rfd); =20=20=20=20=20 result =3D select(FD_SETSIZE, &rfd, NULL, NULL, &tv); @@ -343,7 +354,8 @@ { case 0: { -#ifdef USE_IPASSIGN + if(ipa_fd >=3D 0) + {=20=20 /* Check for outstanding IPA requests */ int i =3D 0, waiting_iparsp =3D 0; while (i < BT_NBR_DATAPORTS) @@ -359,10 +371,8 @@ =20=20=20=20=20=20=20=20=20 if (waiting_iparsp) break; -#endif -=20=20=20=20=20=20=20=20 + } /* Timeout, check for new rfcomm cons */ - discover_connections(bt_cfd); } break; @@ -487,7 +497,7 @@ opts[i++] =3D "passive"; =20=20=20 /* check if we have used IPA */ - if (ipset) + if (use_ipa && ipset) { /* FIXME -- maybe parhand can modify ppp options=20 file directly */ @@ -814,7 +824,8 @@ PEER(i).ipset =3D NULL; } =20 -#ifdef USE_IPASSIGN + if(use_ipa) + { /* Look for IPA server */ ipa_fd =3D -1; i =3D 1; @@ -841,7 +852,7 @@ D(syslog(LOG_INFO, "Found IPA server")); } }=20 -#endif + } =20 if (modem_emul =3D=3D 1) D(syslog(LOG_INFO, "Using modem emulation")); @@ -873,7 +884,7 @@ phys_fd =3D -1; } =20 - if (ipa_fd !=3D -1) + if (ipa_fd >=3D 0) { D(syslog(LOG_INFO, "Closing connection to IPA")); tcflush(ipa_fd, TCIOFLUSH); |
From: Anders J. <and...@us...> - 2001-11-22 15:31:31
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.33 1.34=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * When not using IPA no options to PPP is created except dev and speedstr. The diff of the modified file(s): --- btd.c 2001/11/22 14:42:52 1.33 +++ btd.c 2001/11/22 15:31:30 1.34 @@ -491,10 +491,6 @@ opts[i++] =3D speedstr; =20=20=20 /* move these to options file ? */ - opts[i++] =3D "crtscts"; - opts[i++] =3D "nopersist"; - opts[i++] =3D "silent"; - opts[i++] =3D "passive"; =20=20=20 /* check if we have used IPA */ if (use_ipa && ipset) @@ -502,6 +498,11 @@ /* FIXME -- maybe parhand can modify ppp options=20 file directly */ =20=20=20=20=20 + opts[i++] =3D "crtscts"; + opts[i++] =3D "nopersist"; + opts[i++] =3D "silent"; + opts[i++] =3D "passive"; +=20=20=20=20 /* Use radius ? */ if (ipset->useradius) { @@ -605,32 +606,6 @@ sprintf(netmask, "%s", inet_ntoa(ipset->netmask)); opts[i++] =3D netmask; } - else - {=20=20=20=20 - strcpy(local_ip, get_local_ip_address()); -=20=20=20=20 - /* local IP */ - sprintf(ip_addresses, "%s:", local_ip); - - /* Use /etc/ppp/options file for remote ppp settings. - IPA is needed for correct multipoint setting or use a=20 - ppp options file for each ttyBT e.g options.ttyBT0,=20 - options.ttyBT1 which contains the remote IP address,=20 - dns, wins etc*/ -=20=20=20=20 - syslog(LOG_INFO, "WARNING: No remote ip addr set, only local %s",=20 - ip_addresses); - - opts[i++] =3D ip_addresses; - - /* always do proxyarp */=20 - opts[i++] =3D "proxyarp"; -=20=20=20=20 - /* ktune only works on pppd version > 2.3.10 */ - /* similar as doing ' echo 1 > /proc/sys/net/ipv4/ip_forward */ - opts[i++] =3D "ktune"; /* enables ip_forwarding */ - - } /* end -- no ipa */ =20=20=20=20 opts[i] =3D NULL; =20=20=20 |
From: Peter K. <pk...@us...> - 2001-12-07 18:42:26
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.34 1.35=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Kill all memul children when restarting/exiting (just like we do with pppd). * Added options --use-uart and --use-bcsp. The diff of the modified file(s): --- btd.c 2001/11/22 15:31:30 1.34 +++ btd.c 2001/12/07 18:42:24 1.35 @@ -84,6 +84,14 @@ enable use of ipa default: not enabled =20 + -U, --use-uart + use the UART protocol to communicate with the Bluetooth module + default: whatever the kernel defaults to + + -B, --use-bcsp + use the BCSP protocol to communicate with the Bluetooth module + default: whatever the kernel defaults to + e.g ./btdm --reset --speed 460800 --physdev /dev/ttyS0 --local-name OpenBT ./btdm --reset --speed 1000000/1 --physdev /dev/ttyS0 --local-name Open= BT @@ -193,6 +201,7 @@ static sigjmp_buf jmpbuffer; /* used to jump back in program after doing r= eset */ =20 static int use_ipa =3D 0;=20 +static int use_bcsp =3D -1; =20 /* long option list */ static struct option long_options[] =3D @@ -205,6 +214,8 @@ { "reset", 0, NULL, 'R' }, /* reset BT HW */ { "speed", 1, NULL, 's' }, /* uart speed towards hw */ { "use-ipa", 0, NULL, 'I' }, + { "use-uart", 0, NULL, 'U' }, + { "use-bcsp", 0, NULL, 'B' }, { 0, 0, 0, 0 } }; =20 @@ -237,7 +248,7 @@ } =20=20=20 /* now parse options */ - while ((opt =3D getopt_long(argc, argv, "fi:m:nRs:u:I", + while ((opt =3D getopt_long(argc, argv, "fi:m:nRs:u:IUB", long_options, &option_index)) !=3D -1) { switch(opt) @@ -282,11 +293,22 @@ D(syslog(LOG_INFO, "phys dev: %s", optarg)); physdev =3D optarg; break; + case 'I': D(syslog(LOG_INFO, "using IPA")); use_ipa =3D 1; break; =20 + case 'U': + D(syslog(LOG_INFO, "using UART")); + use_bcsp =3D 0; + break; + + case 'B': + D(syslog(LOG_INFO, "using BCSP")); + use_bcsp =3D 1; + break; + default: break; } @@ -324,6 +346,11 @@ if (do_reset) reset_hw(); =20 + if (use_bcsp >=3D 0) + { + bt_bcsp_mode(bt_cfd, use_bcsp); + } + if (init_stack(bt_cfd) < 0) { /* For some reason, the stack sometimes fails to initialize the first @@ -893,9 +920,9 @@ /* Kill all pppd:s */ for (line =3D 0; line < BT_NBR_DATAPORTS; line++) { - if (STATE(line) =3D=3D PPPD_STARTED) + if (STATE(line) =3D=3D PPPD_STARTED || STATE(line) =3D=3D MODEM_STARTE= D) { - D(syslog(LOG_INFO, "Killing pppd on line %d", line)); + D(syslog(LOG_INFO, "Killing pppd/memul on line %d", line)); kill(PEER(line).pppd_pid, SIGTERM); if (waitpid(PEER(line).pppd_pid, NULL, 0) < 0) perror("waitpid pppd"); |
From: Peter K. <pk...@us...> - 2001-12-20 12:36:01
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.35 1.36=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Need to set the BCSP mode before initialising the physical device. The diff of the modified file(s): --- btd.c 2001/12/07 18:42:24 1.35 +++ btd.c 2001/12/20 12:35:59 1.36 @@ -329,6 +329,13 @@ exit(1); } =20 + bt_cfd =3D bt_openctrl(); + + if (use_bcsp >=3D 0) + { + bt_bcsp_mode(bt_cfd, use_bcsp); + } + /* Sets initial HW baudrate */ if (init_hw_speedstr !=3D NULL) fd_setup(phys_fd, init_hw_speedstr, flow_control); @@ -338,18 +345,11 @@ /* Set the current tty to the bluetooth discpline */ set_bt_line_disc(phys_fd, bt_disc, physdev); =20 - bt_cfd =3D bt_openctrl(); - tcflush(phys_fd, TCIOFLUSH); =20 /* Hardreset of BT hardware */ if (do_reset) reset_hw(); - - if (use_bcsp >=3D 0) - { - bt_bcsp_mode(bt_cfd, use_bcsp); - } =20 if (init_stack(bt_cfd) < 0) { |
From: Peter K. <pk...@us...> - 2001-12-20 14:47:42
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.36 1.37=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Do not wait for children to die when we tell them to. The diff of the modified file(s): --- btd.c 2001/12/20 12:35:59 1.36 +++ btd.c 2001/12/20 14:47:41 1.37 @@ -924,9 +924,6 @@ { D(syslog(LOG_INFO, "Killing pppd/memul on line %d", line)); kill(PEER(line).pppd_pid, SIGTERM); - if (waitpid(PEER(line).pppd_pid, NULL, 0) < 0) - perror("waitpid pppd"); - PEER(line).pppd_pid =3D 0; } } } |
From: Mikael S. <st...@us...> - 2002-10-02 15:28:34
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btd.c 1.38 1.39=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Updated uptions for ppp-2.4 The diff of the modified file(s): --- btd.c 3 Jun 2002 10:07:28 -0000 1.38 +++ btd.c 2 Oct 2002 15:28:31 -0000 1.39 @@ -528,6 +528,7 @@ opts[i++] =3D "nopersist"; opts[i++] =3D "silent"; opts[i++] =3D "passive"; + opts[i++] =3D "local"; =20=20=20=20=20 /* Use radius ? */ if (ipset->useradius) @@ -581,12 +582,6 @@ opts[i++] =3D "ktune"; /* enables ip_forwarding */ } =20 - if (ipset->usingmasq) - { - pppd_options[i++] =3D "usingmasq"; - } - -=20=20=20=20 strcpy(local_ip, get_local_ip_address()); /* local/remote ip */ sprintf(ip_addresses, "%s:%s", local_ip, inet_ntoa(ipset->ip)); |
From: Peter K. <pk...@us...> - 2002-11-20 16:59:25
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btd.c 1.39 1.40=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Modified to use the RADIUS support that is part of the current development version of pppd. The diff of the modified file(s): --- btd.c 2 Oct 2002 15:28:31 -0000 1.39 +++ btd.c 20 Nov 2002 16:59:21 -0000 1.40 @@ -6,7 +6,7 @@ * o Handles multipoint ppp connections * o Handles HW upgrade * - * Copyright (C) 2000, 2001 Axis Communications AB + * Copyright (C) 2000, 2001, 2002 Axis Communications AB * * Author: Mattias Agren <mat...@ax...> * @@ -140,30 +140,18 @@ int pppd_pid; int do_modememul; unsigned char remote_bd[6]; + unsigned char remote_name[BT_NAME_LENGTH]; struct ip_set *ipset; } peer_struct; =20 struct peer_struct peerlist[BT_NBR_DATAPORTS]; struct ip_set ipsetlist[BT_NBR_DATAPORTS]; =20 -static unsigned char dev[20]; -static unsigned char ip_addresses[35]; -static unsigned char ms_dns1[35]; -static unsigned char ms_dns2[35]; -static unsigned char ms_wins1[35]; -static unsigned char ms_wins2[35]; -static unsigned char netmask[35]; -static char remote_bd_str[18]; -static char local_bd_str[18]; - -static fd_set rfd; -static struct timeval tv; - #define PEER(line) (peerlist[line]) #define IPSET(line) (ipsetlist[line]) #define STATE(line) (peerlist[line].state) =20 -static unsigned char *pppd_options[32]; +static unsigned char *pppd_options[64]; =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* IPA stuff */ @@ -219,8 +207,6 @@ { 0, 0, 0, 0 } }; =20 -static int option_index =3D 0; - static void init(); static void init_sighandler(void); static void btd_cleanup(void); @@ -236,6 +222,8 @@ int main(int argc, char **argv) {=20=20 + static fd_set rfd; + static struct timeval tv; int result, opt; int bt_disc =3D N_BT; =20=20=20 @@ -249,7 +237,7 @@ =20=20=20 /* now parse options */ while ((opt =3D getopt_long(argc, argv, "fi:m:n:Rs:u:IUB", - long_options, &option_index)) !=3D -1) + long_options, NULL)) !=3D -1) { switch(opt) { @@ -466,7 +454,8 @@ STATE(line) =3D CONNECTED; =20=20=20=20=20=20=20 read_remote_bd(bt_cfd, line, PEER(line).remote_bd); - printf("Remote bd: %s\n", bd2str(PEER(line).remote_bd)); + read_remote_name(bt_cfd, line, PEER(line).remote_name, sizeof PEER(l= ine).remote_name); + printf("Remote bd: %s (%s)\n", bd2str(PEER(line).remote_bd), PEER(li= ne).remote_name); =20=20=20=20=20=20=20 if (ipa_fd >=3D 0) {=20=20 @@ -500,9 +489,18 @@ /* only server */ void build_pppdopts(int line, char **opts) { - int i =3D 0; + static unsigned char dev[20]; + static unsigned char ip_addresses[35]; + static unsigned char ms_dns1[35]; + static unsigned char ms_dns2[35]; + static unsigned char ms_wins1[35]; + static unsigned char ms_wins2[35]; + static unsigned char netmask[35]; + static char remote_bd_str[36]; + static char local_bd_str[32]; + static char remote_name[20 + BT_NAME_LENGTH]; struct ip_set *ipset =3D PEER(line).ipset; - char local_ip[20]; + int i =3D 0; =20=20=20 if (ipa_fd >=3D 0) show_ipset(ipset, line); @@ -535,14 +533,16 @@ { unsigned char local_bd[6]; =20=20=20=20=20=20=20 - opts[i++] =3D "useradius"; + opts[i++] =3D "plugin"; + opts[i++] =3D "radius.so"; + opts[i++] =3D "plugin"; + opts[i++] =3D "radattr.so"; opts[i++] =3D "auth"; opts[i++] =3D "login"; - opts[i++] =3D "localbdaddr"; =20 +#ifdef __CRIS__ read_local_bd(bt_cfd, local_bd); -=20=20=20=20=20=20=20=20 - sprintf(local_bd_str, "%02x:%02x:%02x:%02x:%02x:%02x",=20 + sprintf(local_bd_str, "Axis-BT-AP-ID=3D%02x:%02x:%02x:%02x:%02x:%02x= ", local_bd[0],=20 local_bd[1],=20 local_bd[2],=20 @@ -550,11 +550,10 @@ local_bd[4],=20 local_bd[5]); =20=20=20=20=20=20=20 + opts[i++] =3D "avpair"; opts[i++] =3D local_bd_str; =20 - opts[i++] =3D "remotebdaddr"; - - sprintf(remote_bd_str, "%02x:%02x:%02x:%02x:%02x:%02x",=20 + sprintf(remote_bd_str, "Axis-BT-Client-ID=3D%02x:%02x:%02x:%02x:%02x= :%02x", PEER(line).remote_bd[0],=20 PEER(line).remote_bd[1],=20 PEER(line).remote_bd[2],=20 @@ -562,12 +561,27 @@ PEER(line).remote_bd[4],=20 PEER(line).remote_bd[5]); =20=20=20=20=20=20=20 + opts[i++] =3D "avpair"; opts[i++] =3D remote_bd_str; =20=20=20=20=20=20=20 + if (*PEER(line).remote_name) + { + sprintf(remote_name, "Axis-BT-Client-Name=3D\"%s\"", PEER(line).re= mote_name); + + opts[i++] =3D "avpair"; + opts[i++] =3D remote_name; + } + if (ipset->useradiusip) { opts[i++] =3D "useautoip"; }=20=20=20 + + if (ipset->usingmasq) + { + pppd_options[i++] =3D "acct-local-addr"; + } +#endif /* __CRIS__ */ }=20=20 else=20 { @@ -582,9 +596,12 @@ opts[i++] =3D "ktune"; /* enables ip_forwarding */ } =20 - strcpy(local_ip, get_local_ip_address()); - /* local/remote ip */ - sprintf(ip_addresses, "%s:%s", local_ip, inet_ntoa(ipset->ip)); + sprintf(ip_addresses, "%s:", get_local_ip_address()); + + if (!ipset->useradius || !ipset->useradiusip) + { + strcat(ip_addresses, inet_ntoa(ipset->ip)); + } =20=20=20=20=20 printf("IP used: %s\n", ip_addresses); =20 @@ -770,7 +787,19 @@ return; } =20=20=20=20=20 + if (WIFEXITED(status) && WEXITSTATUS(status)) + { +// unsigned int con_id; + + syslog(LOG_INFO, "PPP line %d was shutdown due to an error: %d", lin= e, WEXITSTATUS(status)); + +// con_id =3D CREATE_RFCOMM_ID(line, 2); +// bt_disconnect(bt_cfd, con_id); + } + else + { D(syslog(LOG_INFO, "PPP line %d was shutdown", line)); + } =20=20=20=20=20 if (ipa_fd >=3D 0) {=20 |
From: Peter K. <pk...@us...> - 2002-11-22 16:59:04
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btd.c 1.40 1.41=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Use the radaxis.so plugin for RADIUS support in combination with ipa. The diff of the modified file(s): --- btd.c 20 Nov 2002 16:59:21 -0000 1.40 +++ btd.c 22 Nov 2002 16:59:03 -0000 1.41 @@ -160,7 +160,7 @@ static struct ipa_msg *msg; static unsigned char ipa_buf[256]; static int parse_ipa_response(struct ipa_msg *msg); -static int ipa_sendrequest(int line, unsigned char *bd, +static int ipa_send_request(int line, unsigned char *bd, unsigned short type); =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ @@ -464,7 +464,7 @@ PEER(line).ipset =3D &IPSET(line); =20 STATE(line) =3D WAITING_PPPCONF; - if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_GETIPSET) <= 0) + if (ipa_send_request(line, PEER(line).remote_bd, IPAREQ_GETIPSET) = < 0) { syslog(LOG_INFO, "IPA request failed or no IPA server"); =20 @@ -496,6 +496,7 @@ static unsigned char ms_wins1[35]; static unsigned char ms_wins2[35]; static unsigned char netmask[35]; + static char remote_bd_addr[18]; static char remote_bd_str[36]; static char local_bd_str[32]; static char remote_name[20 + BT_NAME_LENGTH]; @@ -541,6 +542,20 @@ opts[i++] =3D "login"; =20 #ifdef __CRIS__ + opts[i++] =3D "plugin"; + opts[i++] =3D "radaxis.so"; + + sprintf(remote_bd_addr, "%02x:%02x:%02x:%02x:%02x:%02x",=20 + PEER(line).remote_bd[0], + PEER(line).remote_bd[1], + PEER(line).remote_bd[2], + PEER(line).remote_bd[3], + PEER(line).remote_bd[4], + PEER(line).remote_bd[5]); + + opts[i++] =3D "remote-bd-addr"; + opts[i++] =3D remote_bd_addr; + read_local_bd(bt_cfd, local_bd); sprintf(local_bd_str, "Axis-BT-AP-ID=3D%02x:%02x:%02x:%02x:%02x:%02x= ", local_bd[0], @@ -574,7 +589,7 @@ =20 if (ipset->useradiusip) { - opts[i++] =3D "useautoip"; + opts[i++] =3D "use-auto-ip"; } =20 if (ipset->usingmasq) @@ -805,7 +820,7 @@ { STATE(line) =3D WAITING_RETURN_PPPCONF; =20 - if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_RELEASEIPSET)= < 0) + if (ipa_send_request(line, PEER(line).remote_bd, IPAREQ_RELEASEIPSET= ) < 0) { syslog(LOG_INFO, "IPA request failed or no IPA server"); /* put peer into state NOCONNECTION, if still connected this @@ -954,7 +969,7 @@ /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* IPA stuff */ =20 -static int ipa_sendrequest(int line, unsigned char *bd, unsigned short typ= e) +static int ipa_send_request(int line, unsigned char *bd, unsigned short ty= pe) { unsigned char buf[IPA_MSG_MAXSIZE]; struct ipa_msg *msg; @@ -964,10 +979,11 @@ =20 msg =3D (struct ipa_msg*)buf; msg->type =3D type; - msg->len =3D sizeof(struct ipa_request); + msg->len =3D sizeof *req; req =3D (struct ipa_request*)msg->msg; req->id =3D line; - memcpy(req->remote_bd, bd, 6); + memcpy(req->remote_bd, bd, sizeof req->remote_bd); + return ipa_write(ipa_fd, msg); } =20 |