make phonenumber ioctl compatible for ctrlconf too

This commit is contained in:
Karsten Keil 1999-11-02 20:41:21 +00:00
parent 1ab5f4c135
commit 8044b57480
3 changed files with 51 additions and 21 deletions

View file

@ -19,6 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log$
* Revision 1.9 1998/11/21 14:03:31 luethje
* isdnctrl: added dialmode into the config file
*
* Revision 1.8 1998/03/20 07:52:13 calle
* Allow readconf to read multilink configs with more than 2 channels.
*
@ -55,6 +58,13 @@
#include <errno.h>
#include <linux/isdn.h>
/* fix version skew between 2.0 and 2.1 kernels (structs are identical) */
#if (NET_DV == 0x04)
# undef NET_DV
# define NET_DV 0x05
#endif
#include <linux/isdnif.h>
#include "isdnctrl.h"
#include "ctrlconf.h"
@ -158,13 +168,13 @@ static char* readoptions(int fd, char *name, int is_master, section *CSec, secti
return NULL;
strcpy(PHONE(inphone)->name, name);
PHONE(inphone)->outgoing = 0;
do_phonenumber(inphone, "", 0);
if (ioctl(fd, IIOCNETGNM, PHONE(inphone)) < 0)
return NULL;
strcpy(PHONE(outphone)->name, name);
PHONE(outphone)->outgoing = 1;
do_phonenumber(outphone, "", 1);
if (ioctl(fd, IIOCNETGNM, PHONE(outphone)) < 0)
return NULL;
@ -634,7 +644,11 @@ static int create_interface(int fd, char *name)
static int set_all_numbers(int fd, char *name, int direction, char *numbers)
{
#if (NET_DV == 5)
isdn_net_ioctl_phone_new phone;
#else
isdn_net_ioctl_phone phone;
#endif
char phonestr[BUFSIZ];
char *ptr = phonestr;
char *ptr2;
@ -645,7 +659,6 @@ static int set_all_numbers(int fd, char *name, int direction, char *numbers)
if (*phonestr != '\0')
{
strcpy(phone.name, name);
phone.outgoing = direction;
do
{
@ -657,7 +670,7 @@ static int set_all_numbers(int fd, char *name, int direction, char *numbers)
while (isspace(*ptr2) && ptr2 != phonestr) *ptr2-- = '\0';
}
strcpy(phone.phone, ptr);
do_phonenumber(&phone, ptr, direction);
if (*ptr != '\0')
{
@ -678,7 +691,11 @@ static int set_all_numbers(int fd, char *name, int direction, char *numbers)
static int del_all_numbers(int fd, char *name, int direction)
{
#if (NET_DV == 5)
isdn_net_ioctl_phone_new phone;
#else
isdn_net_ioctl_phone phone;
#endif
char phonestr[BUFSIZ];
char *ptr = phonestr;
char *ptr2;
@ -688,7 +705,7 @@ static int del_all_numbers(int fd, char *name, int direction)
return -1;
strcpy(PHONE(phonestr)->name, name);
PHONE(phonestr)->outgoing = direction;
do_phonenumber(phonestr, "", direction);
if (ioctl(fd, IIOCNETGNM, PHONE(phonestr)) < 0)
{
@ -699,8 +716,6 @@ static int del_all_numbers(int fd, char *name, int direction)
if (*phonestr != '\0')
{
strcpy(phone.name, name);
phone.outgoing = direction;
do
{
if ((ptr = strrchr(phonestr,' ')) == NULL)
@ -713,8 +728,7 @@ static int del_all_numbers(int fd, char *name, int direction)
if (*ptr != '\0')
{
strcpy(phone.phone, ptr);
do_phonenumber(&phone, ptr, direction);
if (ioctl(fd, IIOCNETDNM, &phone) < 0)
{
perror(name);

View file

@ -21,6 +21,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log$
* Revision 1.35 1999/10/27 14:36:19 keil
* make the phone number struct compatible between NET_DV 5 and 6
*
* Revision 1.34 1999/09/06 08:03:25 fritz
* Changed my mail-address.
*
@ -273,18 +276,6 @@ char nextslaveif[10];
*
*/
typedef struct {
char name[10];
char phone[20];
int outgoing;
} isdn_net_ioctl_phone_old;
typedef struct {
char name[10];
char phone[32];
int outgoing;
} isdn_net_ioctl_phone_new;
int do_phonenumber(void *p, char *number, int outflag) {
isdn_net_ioctl_phone_old *phone_old = (isdn_net_ioctl_phone_old *) p;
isdn_net_ioctl_phone_new *phone_new = (isdn_net_ioctl_phone_new *) p;

View file

@ -21,6 +21,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log$
* Revision 1.15 1999/09/06 08:03:26 fritz
* Changed my mail-address.
*
* Revision 1.14 1999/06/07 19:25:42 paul
* isdnctrl.man.in
*
@ -288,6 +291,28 @@ _EXTERN int exec_args(int fd, int argc, char **argv);
_EXTERN char * defs_basic(char *id);
_EXTERN int MSNLEN_COMPATIBILITY;
/*
* do_phonenumber handle back/forward compatibility between
* version 5 and version 6 of isdn_net_ioctl_phone
*
*/
typedef struct {
char name[10];
char phone[20];
int outgoing;
} isdn_net_ioctl_phone_old;
typedef struct {
char name[10];
char phone[32];
int outgoing;
} isdn_net_ioctl_phone_new;
_EXTERN int do_phonenumber(void *p, char *number, int outflag);
#undef _EXTERN
/*****************************************************************************/