HDLC patch for 2.5.5 (1/3)
PATCH 1/1 HDLC patch for 2.5.5 (1/3)
[1/3]:
- struct if_settings in struct ifreq becomes struct if_settings *
- anonymous data pointer in struct if_settings is now a pointer to a union of struct containing l2 parameters. So far, hdlc_settings is the only one available
- struct hdlc_settings is declared in (new) include/linux/hdlc/ioctl.h. The underlying settings (raw hdlc, cisco, fr) are moved from include/linux/hdlc.h to here
- shortcuts for accessing protocol specific settings are defined in include/linux/hdlc/ioctl.h (shamelessly inspired from #define ifr_map ifr_ifru.ifru_map and friends)
include/linux/hdlc/ioctl.h +61 -0
@@ -0,0 +1,61 @@ +#ifndef __HDLC_IOCTL_H__ +#define __HDLC_IOCTL_H__ + +typedef struct { +unsigned int clock_rate;/* bits per second */ +unsigned int clock_type;/* internal, external, TX-internal etc. */ +unsigned short loopback; +}sync_serial_settings ;/* V.35, V.24, X.21 */ + +typedef struct { +unsigned int clock_rate;/* bits per second */ +unsigned int clock_type;/* internal, external, TX-internal etc. */ +unsigned short loopback; +unsigned int slot_map; +}te1_settings ;/* T1, E1 */ + +typedef struct { +unsigned short encoding; +unsigned short parity; +}raw_hdlc_proto ; + +typedef struct { +unsigned int t391; +unsigned int t392; +unsigned int n391; +unsigned int n392; +unsigned int n393; +unsigned short lmi; +unsigned short dce;/* 1 for DCE (network side) operation */ +}fr_proto ; + +typedef struct { +unsigned int dlci; +}fr_proto_pvc ;/* for creating/deleting FR PVCs */ + +typedef struct { +unsigned int interval; +unsigned int timeout; +}cisco_proto ; + +/* PPP doesn't need any info now - supply length = 0 to ioctl */ + +struct hdlc_settings { +union { +raw_hdlc_proto raw_hdlc; +cisco_proto cisco; +fr_proto fr; +fr_proto_pvc fr_pvc; +sync_serial_settings sync; +te1_settings te1; + } hdlcs_hdlcu; +}; + +#define hdlcs_raw hdlcs_hdlcu.raw_hdlc +#define hdlcs_cisco hdlcs_hdlcu.cisco +#define hdlcs_fr hdlcs_hdlcu.fr +#define hdlcs_pvc hdlcs_hdlcu.fr_pvc +#define hdlcs_sync hdlcs_hdlcu.sync +#define hdlcs_te1 hdlcs_hdlcu.te1 + +#endif /* __HDLC_IOCTL_H__ */
include/linux/hdlc.h +1 -41
65 lines not on this page · raw message
include/linux/if.h +7 -3
@@ -21,6 +21,7 @@#include <linux/types.h> /* for "__kernel_caddr_t" et al */ #include <linux/socket.h> /* for "struct sockaddr" et al */ +#include <linux/hdlc/ioctl.h> /* Standard interface flags (netdevice->flags). */ #define IFF_UP 0x1/* interface is up */
@@ -95,10 +96,13 @@ struct ifmapstruct if_settings {unsigned int type;/* Type of physical device or protocol */ -unsigned int data_length;/* device/protocol data length */ -void * data;/* pointer to data, ignored if length = 0 */ +union { +/* {atm/eth/dsl}_settings anyone ? */ +struct hdlc_settings ifsu_hdlc; + } ifs_ifsu; }; +#define ifs_hdlc ifs_ifsu.ifsu_hdlc/* * Interface request structure used for socket
@@ -129,7 +133,7 @@ struct ifreqchar ifru_slave[IFNAMSIZ ];/* Just fits the size */ char ifru_newname[IFNAMSIZ ];char * ifru_data; -struct if_settings ifru_settings; +struct if_settings *ifru_settings; } ifr_ifru; };
Quoted 3 lines · Francois Romieu
[1/3]:
- structif_settingsin struct ifreq becomes structif_settings*
mostly ok... I'm wondering how this specific item (shown below in the patch portion quoted) affects binary compatibility... how does this affect userland if ifru_settings is suddenly a pointer?
Jeff
Quoted 26 lines
include/linux/if.h Sun Feb 17 17:42:10 > @@ -95,10 +96,13 @@ struct ifmap renamed from include/linux/if.h Sun Feb 17 17:39:24 2002 +6
-3struct if_settings { unsigned int type; /* Type of physical device or protocol */ - unsigned int data_length; /* device/protocol data length */ - void * data; /* pointer to data, ignored if length = 0 */ + union { + /* {atm/eth/dsl}_settings anyone ? */ + struct hdlc_settings ifsu_hdlc; + } ifs_ifsu; }; +#define ifs_hdlc ifs_ifsu.ifsu_hdlc /* * Interface request structure used for socket@@ -129,7 +133,7 @@ struct ifreq char ifru_slave[IFNAMSIZ]; /* Just fits the size */ char ifru_newname[IFNAMSIZ]; char * ifru_data; - struct if_settings ifru_settings; + struct if_settings *ifru_settings; } ifr_ifru; };
Jeff Garzik <[email protected]> :
Quoted 8 lines
Quoted 3 lines · Francois Romieu
[1/3]:
- structif_settingsin struct ifreq becomes structif_settings*mostly ok... I'm wondering how this specific item (shown below in the patch portion quoted) affects binary compatibility... how does this affect userland if
ifru_settingsis suddenly a pointer?
2.4.18-preX:include/linux/if.h
[...]
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
struct sockaddr ifru_netmask;
struct sockaddr ifru_hwaddr;
short ifru_flags;
int ifru_ivalue;
int ifru_mtu;
struct ifmap ifru_map;
char ifru_slave[IFNAMSIZ]; /* Just fits the size */
char ifru_newname[IFNAMSIZ];
char * ifru_data; <-- Nothing after this field.
} ifr_ifru;
};The member ifru_settings is added to the union by Krzysztof's patch. Existing userland (Krzysztof's new utility aside) shouldn't matter as
- it ignores this member;
- the member doesn't make the union bigger (Krzysztof noticed my previous patch choked on this).
If nobody does it before, the utility will be modified when I feel like it's time to test the code. Shouldn't be long (TM).
Signature · 1 line
Ueimor