Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking merge from David Miller: "1) Move ixgbe driver over to purely page based buffering on receive. From Alexander Duyck. 2) Add receive packet steering support to e1000e, from Bruce Allan. 3) Convert TCP MD5 support over to RCU, from Eric Dumazet. 4) Reduce cpu usage in handling out-of-order TCP packets on modern systems, also from Eric Dumazet. 5) Support the IP{,V6}_UNICAST_IF socket options, making the wine folks happy, from Erich Hoover. 6) Support VLAN trunking from guests in hyperv driver, from Haiyang Zhang. 7) Support byte-queue-limtis in r8169, from Igor Maravic. 8) Outline code intended for IP_RECVTOS in IP_PKTOPTIONS existed but was never properly implemented, Jiri Benc fixed that. 9) 64-bit statistics support in r8169 and 8139too, from Junchang Wang. 10) Support kernel side dump filtering by ctmark in netfilter ctnetlink, from Pablo Neira Ayuso. 11) Support byte-queue-limits in gianfar driver, from Paul Gortmaker. 12) Add new peek socket options to assist with socket migration, from Pavel Emelyanov. 13) Add sch_plug packet scheduler whose queue is controlled by userland daemons using explicit freeze and release commands. From Shriram Rajagopalan. 14) Fix FCOE checksum offload handling on transmit, from Yi Zou." * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1846 commits) Fix pppol2tp getsockname() Remove printk from rds_sendmsg ipv6: fix incorrent ipv6 ipsec packet fragment cpsw: Hook up default ndo_change_mtu. net: qmi_wwan: fix build error due to cdc-wdm dependecy netdev: driver: ethernet: Add TI CPSW driver netdev: driver: ethernet: add cpsw address lookup engine support phy: add am79c874 PHY support mlx4_core: fix race on comm channel bonding: send igmp report for its master fs_enet: Add MPC5125 FEC support and PHY interface selection net: bpf_jit: fix BPF_S_LDX_B_MSH compilation net: update the usage of CHECKSUM_UNNECESSARY fcoe: use CHECKSUM_UNNECESSARY instead of CHECKSUM_PARTIAL on tx net: do not do gso for CHECKSUM_UNNECESSARY in netif_needs_gso ixgbe: Fix issues with SR-IOV loopback when flow control is disabled net/hyperv: Fix the code handling tx busy ixgbe: fix namespace issues when FCoE/DCB is not enabled rtlwifi: Remove unused ETH_ADDR_LEN defines igbvf: Use ETH_ALEN ... Fix up fairly trivial conflicts in drivers/isdn/gigaset/interface.c and drivers/net/usb/{Kconfig,qmi_wwan.c} as per David.
Cette révision appartient à :
@@ -204,9 +204,9 @@ isdn_audio_tlookup(const u_char *table, u_char *buff, unsigned long n)
|
||||
"xlatb\n\t"
|
||||
"stosb\n\t"
|
||||
"loop 1b\n\t"
|
||||
: "=&b"(d0), "=&c"(d1), "=&D"(d2), "=&S"(d3)
|
||||
: "0"((long) table), "1"(n), "2"((long) buff), "3"((long) buff)
|
||||
: "memory", "ax");
|
||||
: "=&b"(d0), "=&c"(d1), "=&D"(d2), "=&S"(d3)
|
||||
: "0"((long) table), "1"(n), "2"((long) buff), "3"((long) buff)
|
||||
: "memory", "ax");
|
||||
#else
|
||||
while (n--)
|
||||
*buff = table[*(unsigned char *)buff], buff++;
|
||||
@@ -242,27 +242,27 @@ static unsigned char
|
||||
isdn_audio_linear2ulaw(int sample)
|
||||
{
|
||||
static int exp_lut[256] =
|
||||
{
|
||||
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
|
||||
};
|
||||
{
|
||||
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
|
||||
};
|
||||
int sign,
|
||||
exponent,
|
||||
mantissa;
|
||||
exponent,
|
||||
mantissa;
|
||||
unsigned char ulawbyte;
|
||||
|
||||
/* Get the sample into sign-magnitude. */
|
||||
@@ -299,7 +299,7 @@ static int bitmask[9] =
|
||||
};
|
||||
|
||||
static int
|
||||
isdn_audio_get_bits(adpcm_state * s, unsigned char **in, int *len)
|
||||
isdn_audio_get_bits(adpcm_state *s, unsigned char **in, int *len)
|
||||
{
|
||||
while (s->nleft < s->nbits) {
|
||||
int d = *((*in)++);
|
||||
@@ -312,7 +312,7 @@ isdn_audio_get_bits(adpcm_state * s, unsigned char **in, int *len)
|
||||
}
|
||||
|
||||
static void
|
||||
isdn_audio_put_bits(int data, int nbits, adpcm_state * s,
|
||||
isdn_audio_put_bits(int data, int nbits, adpcm_state *s,
|
||||
unsigned char **out, int *len)
|
||||
{
|
||||
s->word = (s->word << nbits) | (data & bitmask[nbits]);
|
||||
@@ -326,7 +326,7 @@ isdn_audio_put_bits(int data, int nbits, adpcm_state * s,
|
||||
}
|
||||
|
||||
adpcm_state *
|
||||
isdn_audio_adpcm_init(adpcm_state * s, int nbits)
|
||||
isdn_audio_adpcm_init(adpcm_state *s, int nbits)
|
||||
{
|
||||
if (!s)
|
||||
s = kmalloc(sizeof(adpcm_state), GFP_ATOMIC);
|
||||
@@ -341,7 +341,7 @@ isdn_audio_adpcm_init(adpcm_state * s, int nbits)
|
||||
}
|
||||
|
||||
dtmf_state *
|
||||
isdn_audio_dtmf_init(dtmf_state * s)
|
||||
isdn_audio_dtmf_init(dtmf_state *s)
|
||||
{
|
||||
if (!s)
|
||||
s = kmalloc(sizeof(dtmf_state), GFP_ATOMIC);
|
||||
@@ -358,7 +358,7 @@ isdn_audio_dtmf_init(dtmf_state * s)
|
||||
*/
|
||||
|
||||
int
|
||||
isdn_audio_adpcm2xlaw(adpcm_state * s, int fmt, unsigned char *in,
|
||||
isdn_audio_adpcm2xlaw(adpcm_state *s, int fmt, unsigned char *in,
|
||||
unsigned char *out, int len)
|
||||
{
|
||||
int a = s->a;
|
||||
@@ -379,7 +379,7 @@ isdn_audio_adpcm2xlaw(adpcm_state * s, int fmt, unsigned char *in,
|
||||
a++;
|
||||
if (fmt)
|
||||
*out++ = isdn_audio_ulaw_to_alaw[
|
||||
isdn_audio_linear2ulaw(a << 2)];
|
||||
isdn_audio_linear2ulaw(a << 2)];
|
||||
else
|
||||
*out++ = isdn_audio_linear2ulaw(a << 2);
|
||||
olen++;
|
||||
@@ -393,7 +393,7 @@ isdn_audio_adpcm2xlaw(adpcm_state * s, int fmt, unsigned char *in,
|
||||
}
|
||||
|
||||
int
|
||||
isdn_audio_xlaw2adpcm(adpcm_state * s, int fmt, unsigned char *in,
|
||||
isdn_audio_xlaw2adpcm(adpcm_state *s, int fmt, unsigned char *in,
|
||||
unsigned char *out, int len)
|
||||
{
|
||||
int a = s->a;
|
||||
@@ -403,9 +403,9 @@ isdn_audio_xlaw2adpcm(adpcm_state * s, int fmt, unsigned char *in,
|
||||
|
||||
while (len--) {
|
||||
int e = 0,
|
||||
nmax = 1 << (nbits - 1);
|
||||
nmax = 1 << (nbits - 1);
|
||||
int sign,
|
||||
delta;
|
||||
delta;
|
||||
|
||||
if (fmt)
|
||||
delta = (isdn_audio_alaw_to_s16[*in++] >> 2) - a;
|
||||
@@ -439,26 +439,26 @@ isdn_audio_xlaw2adpcm(adpcm_state * s, int fmt, unsigned char *in,
|
||||
|
||||
/*
|
||||
* Goertzel algorithm.
|
||||
* See http://ptolemy.eecs.berkeley.edu/papers/96/dtmf_ict/
|
||||
* See http://ptolemy.eecs.berkeley.edu/papers/96/dtmf_ict/
|
||||
* for more info.
|
||||
* Result is stored into an sk_buff and queued up for later
|
||||
* evaluation.
|
||||
*/
|
||||
static void
|
||||
isdn_audio_goertzel(int *sample, modem_info * info)
|
||||
isdn_audio_goertzel(int *sample, modem_info *info)
|
||||
{
|
||||
int sk,
|
||||
sk1,
|
||||
sk2;
|
||||
sk1,
|
||||
sk2;
|
||||
int k,
|
||||
n;
|
||||
n;
|
||||
struct sk_buff *skb;
|
||||
int *result;
|
||||
|
||||
skb = dev_alloc_skb(sizeof(int) * NCOEFF);
|
||||
if (!skb) {
|
||||
printk(KERN_WARNING
|
||||
"isdn_audio: Could not alloc DTMF result for ttyI%d\n",
|
||||
"isdn_audio: Could not alloc DTMF result for ttyI%d\n",
|
||||
info->line);
|
||||
return;
|
||||
}
|
||||
@@ -483,16 +483,16 @@ isdn_audio_goertzel(int *sample, modem_info * info)
|
||||
printk(KERN_DEBUG
|
||||
"isdn_audio: dtmf goertzel overflow, sk2=%d\n", sk2);
|
||||
result[k] =
|
||||
((sk * sk) >> AMP_BITS) -
|
||||
((((cos2pik[k] * sk) >> 15) * sk2) >> AMP_BITS) +
|
||||
((sk2 * sk2) >> AMP_BITS);
|
||||
((sk * sk) >> AMP_BITS) -
|
||||
((((cos2pik[k] * sk) >> 15) * sk2) >> AMP_BITS) +
|
||||
((sk2 * sk2) >> AMP_BITS);
|
||||
}
|
||||
skb_queue_tail(&info->dtmf_queue, skb);
|
||||
isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1);
|
||||
}
|
||||
|
||||
void
|
||||
isdn_audio_eval_dtmf(modem_info * info)
|
||||
isdn_audio_eval_dtmf(modem_info *info)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
int *result;
|
||||
@@ -590,7 +590,7 @@ isdn_audio_eval_dtmf(modem_info * info)
|
||||
* fmt = audio data format (0 = ulaw, 1 = alaw)
|
||||
*/
|
||||
void
|
||||
isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt)
|
||||
isdn_audio_calc_dtmf(modem_info *info, unsigned char *buf, int len, int fmt)
|
||||
{
|
||||
dtmf_state *s = info->dtmf_state;
|
||||
int i;
|
||||
@@ -605,10 +605,10 @@ isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt)
|
||||
for (i = 0; i < c; i++) {
|
||||
if (fmt)
|
||||
s->buf[s->idx++] =
|
||||
isdn_audio_alaw_to_s16[*buf++] >> (15 - AMP_BITS);
|
||||
isdn_audio_alaw_to_s16[*buf++] >> (15 - AMP_BITS);
|
||||
else
|
||||
s->buf[s->idx++] =
|
||||
isdn_audio_ulaw_to_s16[*buf++] >> (15 - AMP_BITS);
|
||||
isdn_audio_ulaw_to_s16[*buf++] >> (15 - AMP_BITS);
|
||||
}
|
||||
if (s->idx == DTMF_NPOINTS) {
|
||||
isdn_audio_goertzel(s->buf, info);
|
||||
@@ -619,7 +619,7 @@ isdn_audio_calc_dtmf(modem_info * info, unsigned char *buf, int len, int fmt)
|
||||
}
|
||||
|
||||
silence_state *
|
||||
isdn_audio_silence_init(silence_state * s)
|
||||
isdn_audio_silence_init(silence_state *s)
|
||||
{
|
||||
if (!s)
|
||||
s = kmalloc(sizeof(silence_state), GFP_ATOMIC);
|
||||
@@ -631,7 +631,7 @@ isdn_audio_silence_init(silence_state * s)
|
||||
}
|
||||
|
||||
void
|
||||
isdn_audio_calc_silence(modem_info * info, unsigned char *buf, int len, int fmt)
|
||||
isdn_audio_calc_silence(modem_info *info, unsigned char *buf, int len, int fmt)
|
||||
{
|
||||
silence_state *s = info->silence_state;
|
||||
int i;
|
||||
@@ -641,24 +641,24 @@ isdn_audio_calc_silence(modem_info * info, unsigned char *buf, int len, int fmt)
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (fmt)
|
||||
c = isdn_audio_alaw_to_ulaw[*buf++];
|
||||
else
|
||||
c = *buf++;
|
||||
c = isdn_audio_alaw_to_ulaw[*buf++];
|
||||
else
|
||||
c = *buf++;
|
||||
|
||||
if (c > 0) c -= 128;
|
||||
c = abs(c);
|
||||
|
||||
if (c > (info->emu.vpar[1] * 4)) {
|
||||
if (c > (info->emu.vpar[1] * 4)) {
|
||||
s->idx = 0;
|
||||
s->state = 1;
|
||||
s->state = 1;
|
||||
} else {
|
||||
if (s->idx < 210000) s->idx++;
|
||||
if (s->idx < 210000) s->idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
isdn_audio_put_dle_code(modem_info * info, u_char code)
|
||||
isdn_audio_put_dle_code(modem_info *info, u_char code)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
int di;
|
||||
@@ -668,7 +668,7 @@ isdn_audio_put_dle_code(modem_info * info, u_char code)
|
||||
skb = dev_alloc_skb(2);
|
||||
if (!skb) {
|
||||
printk(KERN_WARNING
|
||||
"isdn_audio: Could not alloc skb for ttyI%d\n",
|
||||
"isdn_audio: Could not alloc skb for ttyI%d\n",
|
||||
info->line);
|
||||
return;
|
||||
}
|
||||
@@ -688,24 +688,24 @@ isdn_audio_put_dle_code(modem_info * info, u_char code)
|
||||
}
|
||||
|
||||
void
|
||||
isdn_audio_eval_silence(modem_info * info)
|
||||
isdn_audio_eval_silence(modem_info *info)
|
||||
{
|
||||
silence_state *s = info->silence_state;
|
||||
char what;
|
||||
|
||||
what = ' ';
|
||||
|
||||
if (s->idx > (info->emu.vpar[2] * 800)) {
|
||||
if (s->idx > (info->emu.vpar[2] * 800)) {
|
||||
s->idx = 0;
|
||||
if (!s->state) { /* silence from beginning of rec */
|
||||
if (!s->state) { /* silence from beginning of rec */
|
||||
what = 's';
|
||||
} else {
|
||||
what = 'q';
|
||||
}
|
||||
}
|
||||
if ((what == 's') || (what == 'q')) {
|
||||
printk(KERN_DEBUG "ttyI%d: %s\n", info->line,
|
||||
(what=='s') ? "silence":"quiet");
|
||||
isdn_audio_put_dle_code(info, what);
|
||||
}
|
||||
if ((what == 's') || (what == 'q')) {
|
||||
printk(KERN_DEBUG "ttyI%d: %s\n", info->line,
|
||||
(what == 's') ? "silence" : "quiet");
|
||||
isdn_audio_put_dle_code(info, what);
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Update: The Berkeley copyright was changed, and the change
|
||||
* Update: The Berkeley copyright was changed, and the change
|
||||
* is retroactive to all "true" BSD software (ie everything
|
||||
* from UCB as opposed to other peoples code that just carried
|
||||
* the same license). The new copyright doesn't clash with the
|
||||
@@ -121,7 +121,7 @@ struct bsd_db {
|
||||
unsigned char maxbits; /* maximum bits/code */
|
||||
unsigned char debug; /* non-zero if debug desired */
|
||||
unsigned char unit; /* ppp unit number */
|
||||
u16 seqno; /* sequence # of next packet */
|
||||
u16 seqno; /* sequence # of next packet */
|
||||
unsigned int mru; /* size of receive (decompress) bufr */
|
||||
unsigned int maxmaxcode; /* largest valid code */
|
||||
unsigned int max_ent; /* largest code in use */
|
||||
@@ -157,16 +157,16 @@ struct bsd_db {
|
||||
#define MAXCODE(b) ((1 << (b)) - 1)
|
||||
#define BADCODEM1 MAXCODE(MAX_BSD_BITS)
|
||||
|
||||
#define BSD_HASH(prefix,suffix,hshift) ((((unsigned long)(suffix))<<(hshift)) \
|
||||
^ (unsigned long)(prefix))
|
||||
#define BSD_KEY(prefix,suffix) ((((unsigned long)(suffix)) << 16) \
|
||||
#define BSD_HASH(prefix, suffix, hshift) ((((unsigned long)(suffix)) << (hshift)) \
|
||||
^ (unsigned long)(prefix))
|
||||
#define BSD_KEY(prefix, suffix) ((((unsigned long)(suffix)) << 16) \
|
||||
+ (unsigned long)(prefix))
|
||||
|
||||
#define CHECK_GAP 10000 /* Ratio check interval */
|
||||
|
||||
#define RATIO_SCALE_LOG 8
|
||||
#define RATIO_SCALE (1<<RATIO_SCALE_LOG)
|
||||
#define RATIO_MAX (0x7fffffff>>RATIO_SCALE_LOG)
|
||||
#define RATIO_SCALE (1 << RATIO_SCALE_LOG)
|
||||
#define RATIO_MAX (0x7fffffff >> RATIO_SCALE_LOG)
|
||||
|
||||
/*
|
||||
* clear the dictionary
|
||||
@@ -175,7 +175,7 @@ struct bsd_db {
|
||||
static void bsd_clear(struct bsd_db *db)
|
||||
{
|
||||
db->clear_count++;
|
||||
db->max_ent = FIRST-1;
|
||||
db->max_ent = FIRST - 1;
|
||||
db->n_bits = BSD_INIT_BITS;
|
||||
db->bytes_out = 0;
|
||||
db->in_count = 0;
|
||||
@@ -197,56 +197,56 @@ static void bsd_clear(struct bsd_db *db)
|
||||
* the absence of CLEAR codes (while packets are incompressible), they
|
||||
* must compute the same ratio.
|
||||
*/
|
||||
static int bsd_check (struct bsd_db *db) /* 1=output CLEAR */
|
||||
static int bsd_check(struct bsd_db *db) /* 1=output CLEAR */
|
||||
{
|
||||
unsigned int new_ratio;
|
||||
unsigned int new_ratio;
|
||||
|
||||
if (db->in_count >= db->checkpoint)
|
||||
{
|
||||
/* age the ratio by limiting the size of the counts */
|
||||
if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX)
|
||||
{
|
||||
db->in_count -= (db->in_count >> 2);
|
||||
db->bytes_out -= (db->bytes_out >> 2);
|
||||
}
|
||||
|
||||
db->checkpoint = db->in_count + CHECK_GAP;
|
||||
|
||||
if (db->max_ent >= db->maxmaxcode)
|
||||
{
|
||||
/* Reset the dictionary only if the ratio is worse,
|
||||
* or if it looks as if it has been poisoned
|
||||
* by incompressible data.
|
||||
*
|
||||
* This does not overflow, because
|
||||
* db->in_count <= RATIO_MAX.
|
||||
*/
|
||||
if (db->in_count >= db->checkpoint)
|
||||
{
|
||||
/* age the ratio by limiting the size of the counts */
|
||||
if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX)
|
||||
{
|
||||
db->in_count -= (db->in_count >> 2);
|
||||
db->bytes_out -= (db->bytes_out >> 2);
|
||||
}
|
||||
|
||||
new_ratio = db->in_count << RATIO_SCALE_LOG;
|
||||
if (db->bytes_out != 0)
|
||||
{
|
||||
new_ratio /= db->bytes_out;
|
||||
}
|
||||
|
||||
if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE)
|
||||
{
|
||||
bsd_clear (db);
|
||||
return 1;
|
||||
}
|
||||
db->ratio = new_ratio;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
db->checkpoint = db->in_count + CHECK_GAP;
|
||||
|
||||
if (db->max_ent >= db->maxmaxcode)
|
||||
{
|
||||
/* Reset the dictionary only if the ratio is worse,
|
||||
* or if it looks as if it has been poisoned
|
||||
* by incompressible data.
|
||||
*
|
||||
* This does not overflow, because
|
||||
* db->in_count <= RATIO_MAX.
|
||||
*/
|
||||
|
||||
new_ratio = db->in_count << RATIO_SCALE_LOG;
|
||||
if (db->bytes_out != 0)
|
||||
{
|
||||
new_ratio /= db->bytes_out;
|
||||
}
|
||||
|
||||
if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE)
|
||||
{
|
||||
bsd_clear(db);
|
||||
return 1;
|
||||
}
|
||||
db->ratio = new_ratio;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return statistics.
|
||||
*/
|
||||
|
||||
static void bsd_stats (void *state, struct compstat *stats)
|
||||
static void bsd_stats(void *state, struct compstat *stats)
|
||||
{
|
||||
struct bsd_db *db = (struct bsd_db *) state;
|
||||
|
||||
|
||||
stats->unc_bytes = db->uncomp_bytes;
|
||||
stats->unc_packets = db->uncomp_count;
|
||||
stats->comp_bytes = db->comp_bytes;
|
||||
@@ -260,9 +260,9 @@ static void bsd_stats (void *state, struct compstat *stats)
|
||||
/*
|
||||
* Reset state, as on a CCP ResetReq.
|
||||
*/
|
||||
static void bsd_reset (void *state,unsigned char code, unsigned char id,
|
||||
unsigned char *data, unsigned len,
|
||||
struct isdn_ppp_resetparams *rsparm)
|
||||
static void bsd_reset(void *state, unsigned char code, unsigned char id,
|
||||
unsigned char *data, unsigned len,
|
||||
struct isdn_ppp_resetparams *rsparm)
|
||||
{
|
||||
struct bsd_db *db = (struct bsd_db *) state;
|
||||
|
||||
@@ -274,7 +274,7 @@ static void bsd_reset (void *state,unsigned char code, unsigned char id,
|
||||
/*
|
||||
* Release the compression structure
|
||||
*/
|
||||
static void bsd_free (void *state)
|
||||
static void bsd_free(void *state)
|
||||
{
|
||||
struct bsd_db *db = (struct bsd_db *) state;
|
||||
|
||||
@@ -302,7 +302,7 @@ static void bsd_free (void *state)
|
||||
/*
|
||||
* Allocate space for a (de) compressor.
|
||||
*/
|
||||
static void *bsd_alloc (struct isdn_ppp_comp_data *data)
|
||||
static void *bsd_alloc(struct isdn_ppp_comp_data *data)
|
||||
{
|
||||
int bits;
|
||||
unsigned int hsize, hshift, maxmaxcode;
|
||||
@@ -310,27 +310,27 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
|
||||
int decomp;
|
||||
|
||||
static unsigned int htab[][2] = {
|
||||
{ 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } ,
|
||||
{ 9001 , 5 } , { 18013 , 6 } , { 35023 , 7 } , { 69001 , 8 }
|
||||
{ 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } , { 5003 , 4 } ,
|
||||
{ 9001 , 5 } , { 18013 , 6 } , { 35023 , 7 } , { 69001 , 8 }
|
||||
};
|
||||
|
||||
|
||||
if (data->optlen != 1 || data->num != CI_BSD_COMPRESS
|
||||
|| BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION)
|
||||
|| BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION)
|
||||
return NULL;
|
||||
|
||||
bits = BSD_NBITS(data->options[0]);
|
||||
|
||||
if(bits < 9 || bits > 15)
|
||||
if (bits < 9 || bits > 15)
|
||||
return NULL;
|
||||
|
||||
hsize = htab[bits-9][0];
|
||||
hshift = htab[bits-9][1];
|
||||
|
||||
hsize = htab[bits - 9][0];
|
||||
hshift = htab[bits - 9][1];
|
||||
|
||||
/*
|
||||
* Allocate the main control structure for this instance.
|
||||
*/
|
||||
maxmaxcode = MAXCODE(bits);
|
||||
db = kzalloc (sizeof (struct bsd_db),GFP_KERNEL);
|
||||
db = kzalloc(sizeof(struct bsd_db), GFP_KERNEL);
|
||||
if (!db)
|
||||
return NULL;
|
||||
|
||||
@@ -343,7 +343,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
|
||||
*/
|
||||
db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
|
||||
if (!db->dict) {
|
||||
bsd_free (db);
|
||||
bsd_free(db);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
|
||||
else {
|
||||
db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
|
||||
if (!db->lens) {
|
||||
bsd_free (db);
|
||||
bsd_free(db);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
@@ -364,41 +364,41 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
|
||||
/*
|
||||
* Initialize the data information for the compression code
|
||||
*/
|
||||
db->totlen = sizeof (struct bsd_db) + (sizeof (struct bsd_dict) * hsize);
|
||||
db->hsize = hsize;
|
||||
db->hshift = hshift;
|
||||
db->totlen = sizeof(struct bsd_db) + (sizeof(struct bsd_dict) * hsize);
|
||||
db->hsize = hsize;
|
||||
db->hshift = hshift;
|
||||
db->maxmaxcode = maxmaxcode;
|
||||
db->maxbits = bits;
|
||||
db->maxbits = bits;
|
||||
|
||||
return (void *) db;
|
||||
return (void *)db;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the database.
|
||||
*/
|
||||
static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int debug)
|
||||
static int bsd_init(void *state, struct isdn_ppp_comp_data *data, int unit, int debug)
|
||||
{
|
||||
struct bsd_db *db = state;
|
||||
int indx;
|
||||
int decomp;
|
||||
|
||||
if(!state || !data) {
|
||||
printk(KERN_ERR "isdn_bsd_init: [%d] ERR, state %lx data %lx\n",unit,(long)state,(long)data);
|
||||
if (!state || !data) {
|
||||
printk(KERN_ERR "isdn_bsd_init: [%d] ERR, state %lx data %lx\n", unit, (long)state, (long)data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
decomp = db->xmit ? 0 : 1;
|
||||
|
||||
|
||||
if (data->optlen != 1 || data->num != CI_BSD_COMPRESS
|
||||
|| (BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION)
|
||||
|| (BSD_NBITS(data->options[0]) != db->maxbits)
|
||||
|| (decomp && db->lens == NULL)) {
|
||||
printk(KERN_ERR "isdn_bsd: %d %d %d %d %lx\n",data->optlen,data->num,data->options[0],decomp,(unsigned long)db->lens);
|
||||
|| (BSD_VERSION(data->options[0]) != BSD_CURRENT_VERSION)
|
||||
|| (BSD_NBITS(data->options[0]) != db->maxbits)
|
||||
|| (decomp && db->lens == NULL)) {
|
||||
printk(KERN_ERR "isdn_bsd: %d %d %d %d %lx\n", data->optlen, data->num, data->options[0], decomp, (unsigned long)db->lens);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (decomp)
|
||||
for(indx=LAST;indx>=0;indx--)
|
||||
for (indx = LAST; indx >= 0; indx--)
|
||||
db->lens[indx] = 1;
|
||||
|
||||
indx = db->hsize;
|
||||
@@ -411,9 +411,9 @@ static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int
|
||||
db->mru = 0;
|
||||
|
||||
db->debug = 1;
|
||||
|
||||
bsd_reset(db,0,0,NULL,0,NULL);
|
||||
|
||||
|
||||
bsd_reset(db, 0, 0, NULL, 0, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -421,37 +421,37 @@ static int bsd_init (void *state, struct isdn_ppp_comp_data *data, int unit, int
|
||||
* Obtain pointers to the various structures in the compression tables
|
||||
*/
|
||||
|
||||
#define dict_ptrx(p,idx) &(p->dict[idx])
|
||||
#define lens_ptrx(p,idx) &(p->lens[idx])
|
||||
#define dict_ptrx(p, idx) &(p->dict[idx])
|
||||
#define lens_ptrx(p, idx) &(p->lens[idx])
|
||||
|
||||
#ifdef DEBUG
|
||||
static unsigned short *lens_ptr(struct bsd_db *db, int idx)
|
||||
{
|
||||
if ((unsigned int) idx > (unsigned int) db->maxmaxcode) {
|
||||
printk (KERN_DEBUG "<9>ppp: lens_ptr(%d) > max\n", idx);
|
||||
printk(KERN_DEBUG "<9>ppp: lens_ptr(%d) > max\n", idx);
|
||||
idx = 0;
|
||||
}
|
||||
return lens_ptrx (db, idx);
|
||||
return lens_ptrx(db, idx);
|
||||
}
|
||||
|
||||
static struct bsd_dict *dict_ptr(struct bsd_db *db, int idx)
|
||||
{
|
||||
if ((unsigned int) idx >= (unsigned int) db->hsize) {
|
||||
printk (KERN_DEBUG "<9>ppp: dict_ptr(%d) > max\n", idx);
|
||||
printk(KERN_DEBUG "<9>ppp: dict_ptr(%d) > max\n", idx);
|
||||
idx = 0;
|
||||
}
|
||||
return dict_ptrx (db, idx);
|
||||
return dict_ptrx(db, idx);
|
||||
}
|
||||
|
||||
#else
|
||||
#define lens_ptr(db,idx) lens_ptrx(db,idx)
|
||||
#define dict_ptr(db,idx) dict_ptrx(db,idx)
|
||||
#define lens_ptr(db, idx) lens_ptrx(db, idx)
|
||||
#define dict_ptr(db, idx) dict_ptrx(db, idx)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* compress a packet
|
||||
*/
|
||||
static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *skb_out,int proto)
|
||||
static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb_out, int proto)
|
||||
{
|
||||
struct bsd_db *db;
|
||||
int hshift;
|
||||
@@ -463,31 +463,31 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk
|
||||
unsigned long fcode;
|
||||
struct bsd_dict *dictp;
|
||||
unsigned char c;
|
||||
int hval,disp,ilen,mxcode;
|
||||
int hval, disp, ilen, mxcode;
|
||||
unsigned char *rptr = skb_in->data;
|
||||
int isize = skb_in->len;
|
||||
|
||||
#define OUTPUT(ent) \
|
||||
{ \
|
||||
bitno -= n_bits; \
|
||||
accm |= ((ent) << bitno); \
|
||||
do { \
|
||||
if(skb_out && skb_tailroom(skb_out) > 0) \
|
||||
*(skb_put(skb_out,1)) = (unsigned char) (accm>>24); \
|
||||
accm <<= 8; \
|
||||
bitno += 8; \
|
||||
} while (bitno <= 24); \
|
||||
}
|
||||
#define OUTPUT(ent) \
|
||||
{ \
|
||||
bitno -= n_bits; \
|
||||
accm |= ((ent) << bitno); \
|
||||
do { \
|
||||
if (skb_out && skb_tailroom(skb_out) > 0) \
|
||||
*(skb_put(skb_out, 1)) = (unsigned char)(accm >> 24); \
|
||||
accm <<= 8; \
|
||||
bitno += 8; \
|
||||
} while (bitno <= 24); \
|
||||
}
|
||||
|
||||
/*
|
||||
* If the protocol is not in the range we're interested in,
|
||||
* just return without compressing the packet. If it is,
|
||||
* the protocol becomes the first byte to compress.
|
||||
*/
|
||||
printk(KERN_DEBUG "bsd_compress called with %x\n",proto);
|
||||
|
||||
printk(KERN_DEBUG "bsd_compress called with %x\n", proto);
|
||||
|
||||
ent = proto;
|
||||
if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1) )
|
||||
if (proto < 0x21 || proto > 0xf9 || !(proto & 0x1))
|
||||
return 0;
|
||||
|
||||
db = (struct bsd_db *) state;
|
||||
@@ -496,25 +496,25 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk
|
||||
n_bits = db->n_bits;
|
||||
bitno = 32;
|
||||
accm = 0;
|
||||
mxcode = MAXCODE (n_bits);
|
||||
|
||||
mxcode = MAXCODE(n_bits);
|
||||
|
||||
/* This is the PPP header information */
|
||||
if(skb_out && skb_tailroom(skb_out) >= 2) {
|
||||
char *v = skb_put(skb_out,2);
|
||||
if (skb_out && skb_tailroom(skb_out) >= 2) {
|
||||
char *v = skb_put(skb_out, 2);
|
||||
/* we only push our own data on the header,
|
||||
AC,PC and protos is pushed by caller */
|
||||
AC,PC and protos is pushed by caller */
|
||||
v[0] = db->seqno >> 8;
|
||||
v[1] = db->seqno;
|
||||
}
|
||||
|
||||
ilen = ++isize; /* This is off by one, but that is what is in draft! */
|
||||
ilen = ++isize; /* This is off by one, but that is what is in draft! */
|
||||
|
||||
while (--ilen > 0) {
|
||||
c = *rptr++;
|
||||
fcode = BSD_KEY (ent, c);
|
||||
hval = BSD_HASH (ent, c, hshift);
|
||||
dictp = dict_ptr (db, hval);
|
||||
|
||||
c = *rptr++;
|
||||
fcode = BSD_KEY(ent, c);
|
||||
hval = BSD_HASH(ent, c, hshift);
|
||||
dictp = dict_ptr(db, hval);
|
||||
|
||||
/* Validate and then check the entry. */
|
||||
if (dictp->codem1 >= max_ent)
|
||||
goto nomatch;
|
||||
@@ -523,7 +523,7 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk
|
||||
ent = dictp->codem1 + 1;
|
||||
continue; /* found (prefix,suffix) */
|
||||
}
|
||||
|
||||
|
||||
/* continue probing until a match or invalid entry */
|
||||
disp = (hval == 0) ? 1 : hval;
|
||||
|
||||
@@ -531,17 +531,17 @@ static int bsd_compress (void *state, struct sk_buff *skb_in, struct sk_buff *sk
|
||||
hval += disp;
|
||||
if (hval >= db->hsize)
|
||||
hval -= db->hsize;
|
||||
dictp = dict_ptr (db, hval);
|
||||
dictp = dict_ptr(db, hval);
|
||||
if (dictp->codem1 >= max_ent)
|
||||
goto nomatch;
|
||||
} while (dictp->fcode != fcode);
|
||||
|
||||
ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */
|
||||
continue;
|
||||
|
||||
nomatch:
|
||||
|
||||
nomatch:
|
||||
OUTPUT(ent); /* output the prefix */
|
||||
|
||||
|
||||
/* code -> hashtable */
|
||||
if (max_ent < db->maxmaxcode) {
|
||||
struct bsd_dict *dictp2;
|
||||
@@ -551,16 +551,16 @@ nomatch:
|
||||
/* expand code size if needed */
|
||||
if (max_ent >= mxcode) {
|
||||
db->n_bits = ++n_bits;
|
||||
mxcode = MAXCODE (n_bits);
|
||||
mxcode = MAXCODE(n_bits);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Invalidate old hash table entry using
|
||||
* this code, and then take it over.
|
||||
*/
|
||||
dictp2 = dict_ptr (db, max_ent + 1);
|
||||
dictp2 = dict_ptr(db, max_ent + 1);
|
||||
indx = dictp2->cptr;
|
||||
dictp3 = dict_ptr (db, indx);
|
||||
dictp3 = dict_ptr(db, indx);
|
||||
|
||||
if (dictp3->codem1 == max_ent)
|
||||
dictp3->codem1 = BADCODEM1;
|
||||
@@ -571,17 +571,17 @@ nomatch:
|
||||
db->max_ent = ++max_ent;
|
||||
|
||||
if (db->lens) {
|
||||
unsigned short *len1 = lens_ptr (db, max_ent);
|
||||
unsigned short *len2 = lens_ptr (db, ent);
|
||||
unsigned short *len1 = lens_ptr(db, max_ent);
|
||||
unsigned short *len2 = lens_ptr(db, ent);
|
||||
*len1 = *len2 + 1;
|
||||
}
|
||||
}
|
||||
ent = c;
|
||||
}
|
||||
|
||||
|
||||
OUTPUT(ent); /* output the last code */
|
||||
|
||||
if(skb_out)
|
||||
if (skb_out)
|
||||
db->bytes_out += skb_out->len; /* Do not count bytes from here */
|
||||
db->uncomp_bytes += isize;
|
||||
db->in_count += isize;
|
||||
@@ -596,15 +596,15 @@ nomatch:
|
||||
*/
|
||||
|
||||
if (bsd_check(db))
|
||||
OUTPUT (CLEAR);
|
||||
OUTPUT(CLEAR);
|
||||
|
||||
/*
|
||||
* Pad dribble bits of last code with ones.
|
||||
* Do not emit a completely useless byte of ones.
|
||||
*/
|
||||
if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0)
|
||||
*(skb_put(skb_out,1)) = (unsigned char) ((accm | (0xff << (bitno-8))) >> 24);
|
||||
|
||||
if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0)
|
||||
*(skb_put(skb_out, 1)) = (unsigned char)((accm | (0xff << (bitno - 8))) >> 24);
|
||||
|
||||
/*
|
||||
* Increase code size if we would have without the packet
|
||||
* boundary because the decompressor will do so.
|
||||
@@ -613,7 +613,7 @@ nomatch:
|
||||
db->n_bits++;
|
||||
|
||||
/* If output length is too large then this is an incompressible frame. */
|
||||
if (!skb_out || (skb_out && skb_out->len >= skb_in->len) ) {
|
||||
if (!skb_out || (skb_out && skb_out->len >= skb_in->len)) {
|
||||
++db->incomp_count;
|
||||
db->incomp_bytes += isize;
|
||||
return 0;
|
||||
@@ -631,16 +631,16 @@ nomatch:
|
||||
* Update the "BSD Compress" dictionary on the receiver for
|
||||
* incompressible data by pretending to compress the incoming data.
|
||||
*/
|
||||
static void bsd_incomp (void *state, struct sk_buff *skb_in,int proto)
|
||||
static void bsd_incomp(void *state, struct sk_buff *skb_in, int proto)
|
||||
{
|
||||
bsd_compress (state, skb_in, NULL, proto);
|
||||
bsd_compress(state, skb_in, NULL, proto);
|
||||
}
|
||||
|
||||
/*
|
||||
* Decompress "BSD Compress".
|
||||
*/
|
||||
static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *skb_out,
|
||||
struct isdn_ppp_resetparams *rsparm)
|
||||
static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *skb_out,
|
||||
struct isdn_ppp_resetparams *rsparm)
|
||||
{
|
||||
struct bsd_db *db;
|
||||
unsigned int max_ent;
|
||||
@@ -653,7 +653,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
unsigned int incode;
|
||||
unsigned int oldcode;
|
||||
unsigned int finchar;
|
||||
unsigned char *p,*ibuf;
|
||||
unsigned char *p, *ibuf;
|
||||
int ilen;
|
||||
int codelen;
|
||||
int extra;
|
||||
@@ -667,20 +667,20 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
|
||||
printk(KERN_DEBUG "bsd_decompress called\n");
|
||||
|
||||
if(!skb_in || !skb_out) {
|
||||
if (!skb_in || !skb_out) {
|
||||
printk(KERN_ERR "bsd_decompress called with NULL parameter\n");
|
||||
return DECOMP_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the sequence number.
|
||||
*/
|
||||
if( (p = skb_pull(skb_in,2)) == NULL) {
|
||||
if ((p = skb_pull(skb_in, 2)) == NULL) {
|
||||
return DECOMP_ERROR;
|
||||
}
|
||||
p-=2;
|
||||
seq = (p[0] << 8) + p[1];
|
||||
ilen = skb_in->len;
|
||||
p -= 2;
|
||||
seq = (p[0] << 8) + p[1];
|
||||
ilen = skb_in->len;
|
||||
ibuf = skb_in->data;
|
||||
|
||||
/*
|
||||
@@ -690,7 +690,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
if (seq != db->seqno) {
|
||||
if (db->debug) {
|
||||
printk(KERN_DEBUG "bsd_decomp%d: bad sequence # %d, expected %d\n",
|
||||
db->unit, seq, db->seqno - 1);
|
||||
db->unit, seq, db->seqno - 1);
|
||||
}
|
||||
return DECOMP_ERROR;
|
||||
}
|
||||
@@ -698,11 +698,11 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
++db->seqno;
|
||||
db->bytes_out += ilen;
|
||||
|
||||
if(skb_tailroom(skb_out) > 0)
|
||||
*(skb_put(skb_out,1)) = 0;
|
||||
if (skb_tailroom(skb_out) > 0)
|
||||
*(skb_put(skb_out, 1)) = 0;
|
||||
else
|
||||
return DECOMP_ERR_NOMEM;
|
||||
|
||||
|
||||
oldcode = CLEAR;
|
||||
|
||||
/*
|
||||
@@ -734,7 +734,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
/*
|
||||
* The dictionary must only be cleared at the end of a packet.
|
||||
*/
|
||||
|
||||
|
||||
if (incode == CLEAR) {
|
||||
if (ilen > 0) {
|
||||
if (db->debug)
|
||||
@@ -746,16 +746,16 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
}
|
||||
|
||||
if ((incode > max_ent + 2) || (incode > db->maxmaxcode)
|
||||
|| (incode > max_ent && oldcode == CLEAR)) {
|
||||
|| (incode > max_ent && oldcode == CLEAR)) {
|
||||
if (db->debug) {
|
||||
printk(KERN_DEBUG "bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
|
||||
db->unit, incode, oldcode);
|
||||
db->unit, incode, oldcode);
|
||||
printk(KERN_DEBUG "max_ent=0x%x skb->Len=%d seqno=%d\n",
|
||||
max_ent, skb_out->len, db->seqno);
|
||||
max_ent, skb_out->len, db->seqno);
|
||||
}
|
||||
return DECOMP_FATALERROR; /* probably a bug */
|
||||
}
|
||||
|
||||
|
||||
/* Special case for KwKwK string. */
|
||||
if (incode > max_ent) {
|
||||
finchar = oldcode;
|
||||
@@ -765,13 +765,13 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
extra = 0;
|
||||
}
|
||||
|
||||
codelen = *(lens_ptr (db, finchar));
|
||||
if( skb_tailroom(skb_out) < codelen + extra) {
|
||||
codelen = *(lens_ptr(db, finchar));
|
||||
if (skb_tailroom(skb_out) < codelen + extra) {
|
||||
if (db->debug) {
|
||||
printk(KERN_DEBUG "bsd_decomp%d: ran out of mru\n", db->unit);
|
||||
#ifdef DEBUG
|
||||
printk(KERN_DEBUG " len=%d, finchar=0x%x, codelen=%d,skblen=%d\n",
|
||||
ilen, finchar, codelen, skb_out->len);
|
||||
ilen, finchar, codelen, skb_out->len);
|
||||
#endif
|
||||
}
|
||||
return DECOMP_FATALERROR;
|
||||
@@ -781,21 +781,21 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
* Decode this code and install it in the decompressed buffer.
|
||||
*/
|
||||
|
||||
p = skb_put(skb_out,codelen);
|
||||
p = skb_put(skb_out, codelen);
|
||||
p += codelen;
|
||||
while (finchar > LAST) {
|
||||
struct bsd_dict *dictp2 = dict_ptr (db, finchar);
|
||||
|
||||
dictp = dict_ptr (db, dictp2->cptr);
|
||||
struct bsd_dict *dictp2 = dict_ptr(db, finchar);
|
||||
|
||||
dictp = dict_ptr(db, dictp2->cptr);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (--codelen <= 0 || dictp->codem1 != finchar-1) {
|
||||
if (--codelen <= 0 || dictp->codem1 != finchar - 1) {
|
||||
if (codelen <= 0) {
|
||||
printk(KERN_ERR "bsd_decomp%d: fell off end of chain ", db->unit);
|
||||
printk(KERN_ERR "0x%x at 0x%x by 0x%x, max_ent=0x%x\n", incode, finchar, dictp2->cptr, max_ent);
|
||||
} else {
|
||||
if (dictp->codem1 != finchar-1) {
|
||||
printk(KERN_ERR "bsd_decomp%d: bad code chain 0x%x finchar=0x%x ",db->unit, incode, finchar);
|
||||
if (dictp->codem1 != finchar - 1) {
|
||||
printk(KERN_ERR "bsd_decomp%d: bad code chain 0x%x finchar=0x%x ", db->unit, incode, finchar);
|
||||
printk(KERN_ERR "oldcode=0x%x cptr=0x%x codem1=0x%x\n", oldcode, dictp2->cptr, dictp->codem1);
|
||||
}
|
||||
}
|
||||
@@ -810,15 +810,15 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
}
|
||||
}
|
||||
*--p = finchar;
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
if (--codelen != 0)
|
||||
printk(KERN_ERR "bsd_decomp%d: short by %d after code 0x%x, max_ent=0x%x\n", db->unit, codelen, incode, max_ent);
|
||||
#endif
|
||||
|
||||
|
||||
if (extra) /* the KwKwK case again */
|
||||
*(skb_put(skb_out,1)) = finchar;
|
||||
|
||||
*(skb_put(skb_out, 1)) = finchar;
|
||||
|
||||
/*
|
||||
* If not first code in a packet, and
|
||||
* if not out of code space, then allocate a new code.
|
||||
@@ -828,14 +828,14 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
*/
|
||||
if (oldcode != CLEAR && max_ent < db->maxmaxcode) {
|
||||
struct bsd_dict *dictp2, *dictp3;
|
||||
u16 *lens1, *lens2;
|
||||
u16 *lens1, *lens2;
|
||||
unsigned long fcode;
|
||||
int hval, disp, indx;
|
||||
|
||||
fcode = BSD_KEY(oldcode,finchar);
|
||||
hval = BSD_HASH(oldcode,finchar,db->hshift);
|
||||
dictp = dict_ptr (db, hval);
|
||||
|
||||
|
||||
fcode = BSD_KEY(oldcode, finchar);
|
||||
hval = BSD_HASH(oldcode, finchar, db->hshift);
|
||||
dictp = dict_ptr(db, hval);
|
||||
|
||||
/* look for a free hash table entry */
|
||||
if (dictp->codem1 < max_ent) {
|
||||
disp = (hval == 0) ? 1 : hval;
|
||||
@@ -843,18 +843,18 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
hval += disp;
|
||||
if (hval >= db->hsize)
|
||||
hval -= db->hsize;
|
||||
dictp = dict_ptr (db, hval);
|
||||
dictp = dict_ptr(db, hval);
|
||||
} while (dictp->codem1 < max_ent);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Invalidate previous hash table entry
|
||||
* assigned this code, and then take it over
|
||||
*/
|
||||
|
||||
dictp2 = dict_ptr (db, max_ent + 1);
|
||||
dictp2 = dict_ptr(db, max_ent + 1);
|
||||
indx = dictp2->cptr;
|
||||
dictp3 = dict_ptr (db, indx);
|
||||
dictp3 = dict_ptr(db, indx);
|
||||
|
||||
if (dictp3->codem1 == max_ent)
|
||||
dictp3->codem1 = BADCODEM1;
|
||||
@@ -865,10 +865,10 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
db->max_ent = ++max_ent;
|
||||
|
||||
/* Update the length of this string. */
|
||||
lens1 = lens_ptr (db, max_ent);
|
||||
lens2 = lens_ptr (db, oldcode);
|
||||
lens1 = lens_ptr(db, max_ent);
|
||||
lens2 = lens_ptr(db, oldcode);
|
||||
*lens1 = *lens2 + 1;
|
||||
|
||||
|
||||
/* Expand code size if needed. */
|
||||
if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) {
|
||||
db->n_bits = ++n_bits;
|
||||
@@ -886,7 +886,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
|
||||
if (bsd_check(db)) {
|
||||
if (db->debug)
|
||||
printk(KERN_DEBUG "bsd_decomp%d: peer should have cleared dictionary on %d\n",
|
||||
db->unit, db->seqno - 1);
|
||||
db->unit, db->seqno - 1);
|
||||
}
|
||||
return skb_out->len;
|
||||
}
|
||||
@@ -914,15 +914,15 @@ static struct isdn_ppp_compressor ippp_bsd_compress = {
|
||||
|
||||
static int __init isdn_bsdcomp_init(void)
|
||||
{
|
||||
int answer = isdn_ppp_register_compressor (&ippp_bsd_compress);
|
||||
int answer = isdn_ppp_register_compressor(&ippp_bsd_compress);
|
||||
if (answer == 0)
|
||||
printk (KERN_INFO "PPP BSD Compression module registered\n");
|
||||
printk(KERN_INFO "PPP BSD Compression module registered\n");
|
||||
return answer;
|
||||
}
|
||||
|
||||
static void __exit isdn_bsdcomp_exit(void)
|
||||
{
|
||||
isdn_ppp_unregister_compressor (&ippp_bsd_compress);
|
||||
isdn_ppp_unregister_compressor(&ippp_bsd_compress);
|
||||
}
|
||||
|
||||
module_init(isdn_bsdcomp_init);
|
||||
|
Fichier diff supprimé car celui-ci est trop grand
Voir la Diff
@@ -29,19 +29,19 @@ extern void isdn_lock_drivers(void);
|
||||
extern void isdn_unlock_drivers(void);
|
||||
extern void isdn_free_channel(int di, int ch, int usage);
|
||||
extern void isdn_all_eaz(int di, int ch);
|
||||
extern int isdn_command(isdn_ctrl *);
|
||||
extern int isdn_dc2minor(int di, int ch);
|
||||
extern int isdn_command(isdn_ctrl *);
|
||||
extern int isdn_dc2minor(int di, int ch);
|
||||
extern void isdn_info_update(void);
|
||||
extern char *isdn_map_eaz2msn(char *msn, int di);
|
||||
extern void isdn_timer_ctrl(int tf, int onoff);
|
||||
extern void isdn_unexclusive_channel(int di, int ch);
|
||||
extern int isdn_getnum(char **);
|
||||
extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *);
|
||||
extern int isdn_readbchan_tty(int, int, struct tty_struct *, int);
|
||||
extern int isdn_get_free_channel(int, int, int, int, int, char *);
|
||||
extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *);
|
||||
extern int register_isdn(isdn_if * i);
|
||||
extern int isdn_msncmp( const char *, const char *);
|
||||
extern int isdn_getnum(char **);
|
||||
extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *);
|
||||
extern int isdn_readbchan_tty(int, int, struct tty_struct *, int);
|
||||
extern int isdn_get_free_channel(int, int, int, int, int, char *);
|
||||
extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *);
|
||||
extern int register_isdn(isdn_if *i);
|
||||
extern int isdn_msncmp(const char *, const char *);
|
||||
#if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP)
|
||||
extern void isdn_dumppkt(char *, u_char *, int, int);
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* $Id: isdn_concap.c,v 1.1.2.2 2004/01/12 22:37:19 keil Exp $
|
||||
*
|
||||
*
|
||||
* Linux ISDN subsystem, protocol encapsulation
|
||||
*
|
||||
* This software may be used and distributed according to the terms
|
||||
@@ -25,57 +25,57 @@
|
||||
protocols that require for reliable datalink semantics. That means:
|
||||
|
||||
- before any data is to be submitted the connection must explicitly
|
||||
be set up.
|
||||
be set up.
|
||||
- after the successful set up of the connection is signalled the
|
||||
connection is considered to be reliably up.
|
||||
connection is considered to be reliably up.
|
||||
|
||||
Auto-dialing ist not compatible with this requirements. Thus, auto-dialing
|
||||
Auto-dialing ist not compatible with this requirements. Thus, auto-dialing
|
||||
is completely bypassed.
|
||||
|
||||
It might be possible to implement a (non standardized) datalink protocol
|
||||
that provides a reliable data link service while using some auto dialing
|
||||
mechanism. Such a protocol would need an auxiliary channel (i.e. user-user-
|
||||
signaling on the D-channel) while the B-channel is down.
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
static int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb)
|
||||
{
|
||||
struct net_device *ndev = concap -> net_dev;
|
||||
struct net_device *ndev = concap->net_dev;
|
||||
isdn_net_dev *nd = ((isdn_net_local *) netdev_priv(ndev))->netdev;
|
||||
isdn_net_local *lp = isdn_net_get_locked_lp(nd);
|
||||
|
||||
IX25DEBUG( "isdn_concap_dl_data_req: %s \n", concap->net_dev->name);
|
||||
IX25DEBUG("isdn_concap_dl_data_req: %s \n", concap->net_dev->name);
|
||||
if (!lp) {
|
||||
IX25DEBUG( "isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap -> net_dev -> name, 1);
|
||||
IX25DEBUG("isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap->net_dev->name, 1);
|
||||
return 1;
|
||||
}
|
||||
lp->huptimer = 0;
|
||||
isdn_net_writebuf_skb(lp, skb);
|
||||
spin_unlock_bh(&lp->xmit_lock);
|
||||
IX25DEBUG( "isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap -> net_dev -> name, 0);
|
||||
IX25DEBUG("isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap->net_dev->name, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int isdn_concap_dl_connect_req(struct concap_proto *concap)
|
||||
{
|
||||
struct net_device *ndev = concap -> net_dev;
|
||||
struct net_device *ndev = concap->net_dev;
|
||||
isdn_net_local *lp = netdev_priv(ndev);
|
||||
int ret;
|
||||
IX25DEBUG( "isdn_concap_dl_connect_req: %s \n", ndev -> name);
|
||||
IX25DEBUG("isdn_concap_dl_connect_req: %s \n", ndev->name);
|
||||
|
||||
/* dial ... */
|
||||
ret = isdn_net_dial_req( lp );
|
||||
if ( ret ) IX25DEBUG("dialing failed\n");
|
||||
ret = isdn_net_dial_req(lp);
|
||||
if (ret) IX25DEBUG("dialing failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
|
||||
{
|
||||
IX25DEBUG( "isdn_concap_dl_disconn_req: %s \n", concap -> net_dev -> name);
|
||||
IX25DEBUG("isdn_concap_dl_disconn_req: %s \n", concap->net_dev->name);
|
||||
|
||||
isdn_net_hangup( concap -> net_dev );
|
||||
isdn_net_hangup(concap->net_dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ struct concap_device_ops isdn_concap_reliable_dl_dops = {
|
||||
/* The following should better go into a dedicated source file such that
|
||||
this sourcefile does not need to include any protocol specific header
|
||||
files. For now:
|
||||
*/
|
||||
struct concap_proto * isdn_concap_new( int encap )
|
||||
*/
|
||||
struct concap_proto *isdn_concap_new(int encap)
|
||||
{
|
||||
switch ( encap ) {
|
||||
switch (encap) {
|
||||
case ISDN_NET_ENCAP_X25IFACE:
|
||||
return isdn_x25iface_proto_new();
|
||||
}
|
||||
|
@@ -8,6 +8,4 @@
|
||||
*/
|
||||
|
||||
extern struct concap_device_ops isdn_concap_reliable_dl_dops;
|
||||
extern struct concap_proto * isdn_concap_new( int );
|
||||
|
||||
|
||||
extern struct concap_proto *isdn_concap_new(int);
|
||||
|
Fichier diff supprimé car celui-ci est trop grand
Voir la Diff
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* Definitions for hupflags: */
|
||||
/* Definitions for hupflags: */
|
||||
#define ISDN_WAITCHARGE 1 /* did not get a charge info yet */
|
||||
#define ISDN_HAVECHARGE 2 /* We know a charge info */
|
||||
#define ISDN_CHARGEHUP 4 /* We want to use the charge mechanism */
|
||||
@@ -58,8 +58,8 @@ extern void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb);
|
||||
|
||||
#define ISDN_MASTER_PRIV(lp) ((isdn_net_local *) netdev_priv(lp->master))
|
||||
#define ISDN_SLAVE_PRIV(lp) ((isdn_net_local *) netdev_priv(lp->slave))
|
||||
#define MASTER_TO_SLAVE(master) \
|
||||
(((isdn_net_local *) netdev_priv(master))->slave)
|
||||
#define MASTER_TO_SLAVE(master) \
|
||||
(((isdn_net_local *) netdev_priv(master))->slave)
|
||||
|
||||
/*
|
||||
* is this particular channel busy?
|
||||
@@ -68,7 +68,7 @@ static __inline__ int isdn_net_lp_busy(isdn_net_local *lp)
|
||||
{
|
||||
if (atomic_read(&lp->frame_cnt) < ISDN_NET_MAX_QUEUE_LENGTH)
|
||||
return 0;
|
||||
else
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ static __inline__ int isdn_net_lp_busy(isdn_net_local *lp)
|
||||
* For the given net device, this will get a non-busy channel out of the
|
||||
* corresponding bundle. The returned channel is locked.
|
||||
*/
|
||||
static __inline__ isdn_net_local * isdn_net_get_locked_lp(isdn_net_dev *nd)
|
||||
static __inline__ isdn_net_local *isdn_net_get_locked_lp(isdn_net_dev *nd)
|
||||
{
|
||||
unsigned long flags;
|
||||
isdn_net_local *lp;
|
||||
@@ -149,4 +149,3 @@ static __inline__ void isdn_net_rm_from_bundle(isdn_net_local *lp)
|
||||
// __func__, master_lp->netdev->queue);
|
||||
spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags);
|
||||
}
|
||||
|
||||
|
Fichier diff supprimé car celui-ci est trop grand
Voir la Diff
@@ -39,5 +39,3 @@ extern int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *ipc);
|
||||
#define IPPP_ASSIGNED 0x10
|
||||
|
||||
#define IPPP_MAX_HEADER 10
|
||||
|
||||
|
||||
|
Fichier diff supprimé car celui-ci est trop grand
Voir la Diff
@@ -93,11 +93,11 @@
|
||||
#define RESULT_VCON 11
|
||||
#define RESULT_RUNG 12
|
||||
|
||||
#define TTY_IS_FCLASS1(info) \
|
||||
((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \
|
||||
#define TTY_IS_FCLASS1(info) \
|
||||
((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \
|
||||
(info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS1))
|
||||
#define TTY_IS_FCLASS2(info) \
|
||||
((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \
|
||||
#define TTY_IS_FCLASS2(info) \
|
||||
((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \
|
||||
(info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2))
|
||||
|
||||
extern void isdn_tty_modem_escape(void);
|
||||
@@ -110,7 +110,7 @@ extern void isdn_tty_readmodem(void);
|
||||
extern int isdn_tty_find_icall(int, int, setup_parm *);
|
||||
extern int isdn_tty_stat_callback(int, isdn_ctrl *);
|
||||
extern int isdn_tty_rcv_skb(int, int, int, struct sk_buff *);
|
||||
extern int isdn_tty_capi_facility(capi_msg *cm);
|
||||
extern int isdn_tty_capi_facility(capi_msg *cm);
|
||||
extern void isdn_tty_at_cout(char *, modem_info *);
|
||||
extern void isdn_tty_modem_hup(modem_info *, int);
|
||||
#ifdef CONFIG_ISDN_TTY_FAX
|
||||
|
Fichier diff supprimé car celui-ci est trop grand
Voir la Diff
@@ -15,4 +15,3 @@
|
||||
#define XON 0x11
|
||||
#define XOFF 0x13
|
||||
#define DC2 0x12
|
||||
|
||||
|
@@ -26,8 +26,8 @@ char *isdn_v110_revision = "$Revision: 1.1.2.2 $";
|
||||
#define V110_19200 15
|
||||
#define V110_9600 3
|
||||
|
||||
/*
|
||||
* The following data are precoded matrices, online and offline matrix
|
||||
/*
|
||||
* The following data are precoded matrices, online and offline matrix
|
||||
* for 9600, 19200 und 38400, respectively
|
||||
*/
|
||||
static unsigned char V110_OnMatrix_9600[] =
|
||||
@@ -56,7 +56,7 @@ static unsigned char V110_OnMatrix_38400[] =
|
||||
static unsigned char V110_OffMatrix_38400[] =
|
||||
{0x00, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff};
|
||||
|
||||
/*
|
||||
/*
|
||||
* FlipBits reorders sequences of keylen bits in one byte.
|
||||
* E.g. source order 7654321 will be converted to 45670123 when keylen = 4,
|
||||
* and to 67452301 when keylen = 2. This is necessary because ordering on
|
||||
@@ -103,18 +103,18 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
|
||||
v->decodelen = 0;
|
||||
|
||||
switch (key) {
|
||||
case V110_38400:
|
||||
v->OnlineFrame = V110_OnMatrix_38400;
|
||||
v->OfflineFrame = V110_OffMatrix_38400;
|
||||
break;
|
||||
case V110_19200:
|
||||
v->OnlineFrame = V110_OnMatrix_19200;
|
||||
v->OfflineFrame = V110_OffMatrix_19200;
|
||||
break;
|
||||
default:
|
||||
v->OnlineFrame = V110_OnMatrix_9600;
|
||||
v->OfflineFrame = V110_OffMatrix_9600;
|
||||
break;
|
||||
case V110_38400:
|
||||
v->OnlineFrame = V110_OnMatrix_38400;
|
||||
v->OfflineFrame = V110_OffMatrix_38400;
|
||||
break;
|
||||
case V110_19200:
|
||||
v->OnlineFrame = V110_OnMatrix_19200;
|
||||
v->OfflineFrame = V110_OffMatrix_19200;
|
||||
break;
|
||||
default:
|
||||
v->OnlineFrame = V110_OnMatrix_9600;
|
||||
v->OfflineFrame = V110_OffMatrix_9600;
|
||||
break;
|
||||
}
|
||||
v->framelen = v->nbytes * 10;
|
||||
v->SyncInit = 5;
|
||||
@@ -132,7 +132,7 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
|
||||
|
||||
/* isdn_v110_close frees private V.110 data structures */
|
||||
void
|
||||
isdn_v110_close(isdn_v110_stream * v)
|
||||
isdn_v110_close(isdn_v110_stream *v)
|
||||
{
|
||||
if (v == NULL)
|
||||
return;
|
||||
@@ -144,11 +144,11 @@ isdn_v110_close(isdn_v110_stream * v)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ValidHeaderBytes return the number of valid bytes in v->decodebuf
|
||||
/*
|
||||
* ValidHeaderBytes return the number of valid bytes in v->decodebuf
|
||||
*/
|
||||
static int
|
||||
ValidHeaderBytes(isdn_v110_stream * v)
|
||||
ValidHeaderBytes(isdn_v110_stream *v)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; (i < v->decodelen) && (i < v->nbytes); i++)
|
||||
@@ -157,11 +157,11 @@ ValidHeaderBytes(isdn_v110_stream * v)
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* SyncHeader moves the decodebuf ptr to the next valid header
|
||||
/*
|
||||
* SyncHeader moves the decodebuf ptr to the next valid header
|
||||
*/
|
||||
static void
|
||||
SyncHeader(isdn_v110_stream * v)
|
||||
SyncHeader(isdn_v110_stream *v)
|
||||
{
|
||||
unsigned char *rbuf = v->decodebuf;
|
||||
int len = v->decodelen;
|
||||
@@ -185,9 +185,9 @@ SyncHeader(isdn_v110_stream * v)
|
||||
only complete matices must be given.
|
||||
From these, netto data is extracted and returned in buf. The return-value
|
||||
is the bytecount of the decoded data.
|
||||
*/
|
||||
*/
|
||||
static int
|
||||
DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf)
|
||||
DecodeMatrix(isdn_v110_stream *v, unsigned char *m, int len, unsigned char *buf)
|
||||
{
|
||||
int line = 0;
|
||||
int buflen = 0;
|
||||
@@ -203,7 +203,7 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf
|
||||
printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad Header\n");
|
||||
/* returning now is not the right thing, though :-( */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
line++; /* next line of matrix */
|
||||
continue;
|
||||
} else if ((line % 10) == 5) { /* in line 5 there's only e-bits ! */
|
||||
@@ -217,7 +217,7 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf
|
||||
continue;
|
||||
} else if (!introducer) { /* every byte starts with 10 (stopbit, startbit) */
|
||||
introducer = (m[line] & mbit) ? 0 : 1; /* current bit of the matrix */
|
||||
next_byte:
|
||||
next_byte:
|
||||
if (mbit > 2) { /* was it the last bit in this line ? */
|
||||
mbit >>= 1; /* no -> take next */
|
||||
continue;
|
||||
@@ -246,13 +246,13 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf
|
||||
return buflen; /* return number of bytes in the output buffer */
|
||||
}
|
||||
|
||||
/*
|
||||
* DecodeStream receives V.110 coded data from the input stream. It recovers the
|
||||
/*
|
||||
* DecodeStream receives V.110 coded data from the input stream. It recovers the
|
||||
* original frames.
|
||||
* The input stream doesn't need to be framed
|
||||
*/
|
||||
struct sk_buff *
|
||||
isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb)
|
||||
isdn_v110_decode(isdn_v110_stream *v, struct sk_buff *skb)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
@@ -283,7 +283,7 @@ isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb)
|
||||
/* copy new data to decode-buffer */
|
||||
memcpy(&(v->decodebuf[v->decodelen]), rbuf, len);
|
||||
v->decodelen += len;
|
||||
ReSync:
|
||||
ReSync:
|
||||
if (v->decodelen < v->nbytes) { /* got a new header ? */
|
||||
dev_kfree_skb(skb);
|
||||
return NULL; /* no, try later */
|
||||
@@ -320,7 +320,7 @@ isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb)
|
||||
/* EncodeMatrix takes input data in buf, len is the bytecount.
|
||||
Data is encoded into v110 frames in m. Return value is the number of
|
||||
matrix-lines generated.
|
||||
*/
|
||||
*/
|
||||
static int
|
||||
EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
|
||||
{
|
||||
@@ -333,14 +333,14 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
|
||||
|
||||
while ((i < len) && (line < mlen)) { /* while we still have input data */
|
||||
switch (line % 10) { /* in which line of the matrix are we? */
|
||||
case 0:
|
||||
m[line++] = 0x00; /* line 0 is always 0 */
|
||||
mbit = 128; /* go on with the 7th bit */
|
||||
break;
|
||||
case 5:
|
||||
m[line++] = 0xbf; /* line 5 is always 10111111 */
|
||||
mbit = 128; /* go on with the 7th bit */
|
||||
break;
|
||||
case 0:
|
||||
m[line++] = 0x00; /* line 0 is always 0 */
|
||||
mbit = 128; /* go on with the 7th bit */
|
||||
break;
|
||||
case 5:
|
||||
m[line++] = 0xbf; /* line 5 is always 10111111 */
|
||||
mbit = 128; /* go on with the 7th bit */
|
||||
break;
|
||||
}
|
||||
if (line >= mlen) {
|
||||
printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
|
||||
@@ -348,16 +348,16 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
|
||||
}
|
||||
next_bit:
|
||||
switch (mbit) { /* leftmost or rightmost bit ? */
|
||||
case 1:
|
||||
line++; /* rightmost -> go to next line */
|
||||
if (line >= mlen) {
|
||||
printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
|
||||
return line;
|
||||
}
|
||||
case 128:
|
||||
m[line] = 128; /* leftmost -> set byte to 1000000 */
|
||||
mbit = 64; /* current bit in the matrix line */
|
||||
continue;
|
||||
case 1:
|
||||
line++; /* rightmost -> go to next line */
|
||||
if (line >= mlen) {
|
||||
printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
|
||||
return line;
|
||||
}
|
||||
case 128:
|
||||
m[line] = 128; /* leftmost -> set byte to 1000000 */
|
||||
mbit = 64; /* current bit in the matrix line */
|
||||
continue;
|
||||
}
|
||||
if (introducer) { /* set 110 sequence ? */
|
||||
introducer--; /* set on digit less */
|
||||
@@ -384,24 +384,24 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
|
||||
/* if necessary, generate remaining lines of the matrix... */
|
||||
if ((line) && ((line + 10) < mlen))
|
||||
switch (++line % 10) {
|
||||
case 1:
|
||||
m[line++] = 0xfe;
|
||||
case 2:
|
||||
m[line++] = 0xfe;
|
||||
case 3:
|
||||
m[line++] = 0xfe;
|
||||
case 4:
|
||||
m[line++] = 0xfe;
|
||||
case 5:
|
||||
m[line++] = 0xbf;
|
||||
case 6:
|
||||
m[line++] = 0xfe;
|
||||
case 7:
|
||||
m[line++] = 0xfe;
|
||||
case 8:
|
||||
m[line++] = 0xfe;
|
||||
case 9:
|
||||
m[line++] = 0xfe;
|
||||
case 1:
|
||||
m[line++] = 0xfe;
|
||||
case 2:
|
||||
m[line++] = 0xfe;
|
||||
case 3:
|
||||
m[line++] = 0xfe;
|
||||
case 4:
|
||||
m[line++] = 0xfe;
|
||||
case 5:
|
||||
m[line++] = 0xbf;
|
||||
case 6:
|
||||
m[line++] = 0xfe;
|
||||
case 7:
|
||||
m[line++] = 0xfe;
|
||||
case 8:
|
||||
m[line++] = 0xfe;
|
||||
case 9:
|
||||
m[line++] = 0xfe;
|
||||
}
|
||||
return line; /* that's how many lines we have */
|
||||
}
|
||||
@@ -447,7 +447,7 @@ isdn_v110_idle(isdn_v110_stream *v)
|
||||
}
|
||||
|
||||
struct sk_buff *
|
||||
isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb)
|
||||
isdn_v110_encode(isdn_v110_stream *v, struct sk_buff *skb)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
@@ -524,93 +524,93 @@ isdn_v110_stat_callback(int idx, isdn_ctrl *c)
|
||||
if (idx < 0)
|
||||
return 0;
|
||||
switch (c->command) {
|
||||
case ISDN_STAT_BSENT:
|
||||
/* Keep the send-queue of the driver filled
|
||||
* with frames:
|
||||
* If number of outstanding frames < 3,
|
||||
* send down an Idle-Frame (or an Sync-Frame, if
|
||||
* v->SyncInit != 0).
|
||||
*/
|
||||
if (!(v = dev->v110[idx]))
|
||||
return 0;
|
||||
atomic_inc(&dev->v110use[idx]);
|
||||
for (i=0; i * v->framelen < c->parm.length; i++) {
|
||||
if (v->skbidle > 0) {
|
||||
v->skbidle--;
|
||||
ret = 1;
|
||||
} else {
|
||||
if (v->skbuser > 0)
|
||||
v->skbuser--;
|
||||
ret = 0;
|
||||
}
|
||||
case ISDN_STAT_BSENT:
|
||||
/* Keep the send-queue of the driver filled
|
||||
* with frames:
|
||||
* If number of outstanding frames < 3,
|
||||
* send down an Idle-Frame (or an Sync-Frame, if
|
||||
* v->SyncInit != 0).
|
||||
*/
|
||||
if (!(v = dev->v110[idx]))
|
||||
return 0;
|
||||
atomic_inc(&dev->v110use[idx]);
|
||||
for (i = 0; i * v->framelen < c->parm.length; i++) {
|
||||
if (v->skbidle > 0) {
|
||||
v->skbidle--;
|
||||
ret = 1;
|
||||
} else {
|
||||
if (v->skbuser > 0)
|
||||
v->skbuser--;
|
||||
ret = 0;
|
||||
}
|
||||
for (i = v->skbuser + v->skbidle; i < 2; i++) {
|
||||
struct sk_buff *skb;
|
||||
if (v->SyncInit > 0)
|
||||
skb = isdn_v110_sync(v);
|
||||
else
|
||||
skb = isdn_v110_idle(v);
|
||||
if (skb) {
|
||||
}
|
||||
for (i = v->skbuser + v->skbidle; i < 2; i++) {
|
||||
struct sk_buff *skb;
|
||||
if (v->SyncInit > 0)
|
||||
skb = isdn_v110_sync(v);
|
||||
else
|
||||
skb = isdn_v110_idle(v);
|
||||
if (skb) {
|
||||
if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
|
||||
dev_kfree_skb(skb);
|
||||
break;
|
||||
} else {
|
||||
if (v->SyncInit)
|
||||
v->SyncInit--;
|
||||
v->skbidle++;
|
||||
}
|
||||
} else
|
||||
break;
|
||||
}
|
||||
atomic_dec(&dev->v110use[idx]);
|
||||
return ret;
|
||||
case ISDN_STAT_DHUP:
|
||||
case ISDN_STAT_BHUP:
|
||||
while (1) {
|
||||
atomic_inc(&dev->v110use[idx]);
|
||||
if (atomic_dec_and_test(&dev->v110use[idx])) {
|
||||
isdn_v110_close(dev->v110[idx]);
|
||||
dev->v110[idx] = NULL;
|
||||
break;
|
||||
}
|
||||
mdelay(1);
|
||||
}
|
||||
break;
|
||||
case ISDN_STAT_BCONN:
|
||||
if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) {
|
||||
int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
|
||||
int maxsize = dev->drv[c->driver]->interface->maxbufsize;
|
||||
atomic_inc(&dev->v110use[idx]);
|
||||
switch (dev->v110emu[idx]) {
|
||||
case ISDN_PROTO_L2_V11096:
|
||||
dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
|
||||
break;
|
||||
case ISDN_PROTO_L2_V11019:
|
||||
dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
|
||||
break;
|
||||
case ISDN_PROTO_L2_V11038:
|
||||
dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
if ((v = dev->v110[idx])) {
|
||||
while (v->SyncInit) {
|
||||
struct sk_buff *skb = isdn_v110_sync(v);
|
||||
if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
|
||||
dev_kfree_skb(skb);
|
||||
/* Unable to send, try later */
|
||||
break;
|
||||
} else {
|
||||
if (v->SyncInit)
|
||||
v->SyncInit--;
|
||||
v->skbidle++;
|
||||
}
|
||||
} else
|
||||
break;
|
||||
}
|
||||
v->SyncInit--;
|
||||
v->skbidle++;
|
||||
}
|
||||
} else
|
||||
printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
|
||||
atomic_dec(&dev->v110use[idx]);
|
||||
return ret;
|
||||
case ISDN_STAT_DHUP:
|
||||
case ISDN_STAT_BHUP:
|
||||
while (1) {
|
||||
atomic_inc(&dev->v110use[idx]);
|
||||
if (atomic_dec_and_test(&dev->v110use[idx])) {
|
||||
isdn_v110_close(dev->v110[idx]);
|
||||
dev->v110[idx] = NULL;
|
||||
break;
|
||||
}
|
||||
mdelay(1);
|
||||
}
|
||||
break;
|
||||
case ISDN_STAT_BCONN:
|
||||
if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) {
|
||||
int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
|
||||
int maxsize = dev->drv[c->driver]->interface->maxbufsize;
|
||||
atomic_inc(&dev->v110use[idx]);
|
||||
switch (dev->v110emu[idx]) {
|
||||
case ISDN_PROTO_L2_V11096:
|
||||
dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
|
||||
break;
|
||||
case ISDN_PROTO_L2_V11019:
|
||||
dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
|
||||
break;
|
||||
case ISDN_PROTO_L2_V11038:
|
||||
dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
if ((v = dev->v110[idx])) {
|
||||
while (v->SyncInit) {
|
||||
struct sk_buff *skb = isdn_v110_sync(v);
|
||||
if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
|
||||
dev_kfree_skb(skb);
|
||||
/* Unable to send, try later */
|
||||
break;
|
||||
}
|
||||
v->SyncInit--;
|
||||
v->skbidle++;
|
||||
}
|
||||
} else
|
||||
printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
|
||||
atomic_dec(&dev->v110use[idx]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -12,18 +12,18 @@
|
||||
#ifndef _isdn_v110_h_
|
||||
#define _isdn_v110_h_
|
||||
|
||||
/*
|
||||
* isdn_v110_encode will take raw data and encode it using V.110
|
||||
/*
|
||||
* isdn_v110_encode will take raw data and encode it using V.110
|
||||
*/
|
||||
extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *);
|
||||
|
||||
/*
|
||||
/*
|
||||
* isdn_v110_decode receives V.110 coded data from the stream and rebuilds
|
||||
* frames from them. The source stream doesn't need to be framed.
|
||||
*/
|
||||
extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *);
|
||||
|
||||
extern int isdn_v110_stat_callback(int, isdn_ctrl *);
|
||||
extern void isdn_v110_close(isdn_v110_stream * v);
|
||||
extern void isdn_v110_close(isdn_v110_stream *v);
|
||||
|
||||
#endif
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include "isdn_x25iface.h"
|
||||
|
||||
/* for debugging messages not to cause an oops when device pointer is NULL*/
|
||||
#define MY_DEVNAME(dev) ( (dev) ? (dev)->name : "DEVICE UNSPECIFIED" )
|
||||
#define MY_DEVNAME(dev) ((dev) ? (dev)->name : "DEVICE UNSPECIFIED")
|
||||
|
||||
|
||||
typedef struct isdn_x25iface_proto_data {
|
||||
@@ -34,22 +34,22 @@ typedef struct isdn_x25iface_proto_data {
|
||||
enum wan_states state;
|
||||
/* Private stuff, not to be accessed via proto_data. We provide the
|
||||
other storage for the concap_proto instance here as well,
|
||||
enabling us to allocate both with just one kmalloc(): */
|
||||
enabling us to allocate both with just one kmalloc(): */
|
||||
struct concap_proto priv;
|
||||
} ix25_pdata_t;
|
||||
|
||||
|
||||
|
||||
/* is now in header file (extern): struct concap_proto * isdn_x25iface_proto_new(void); */
|
||||
static void isdn_x25iface_proto_del( struct concap_proto * );
|
||||
static int isdn_x25iface_proto_close( struct concap_proto * );
|
||||
static int isdn_x25iface_proto_restart( struct concap_proto *,
|
||||
struct net_device *,
|
||||
struct concap_device_ops *);
|
||||
static int isdn_x25iface_xmit( struct concap_proto *, struct sk_buff * );
|
||||
static int isdn_x25iface_receive( struct concap_proto *, struct sk_buff * );
|
||||
static int isdn_x25iface_connect_ind( struct concap_proto * );
|
||||
static int isdn_x25iface_disconn_ind( struct concap_proto * );
|
||||
static void isdn_x25iface_proto_del(struct concap_proto *);
|
||||
static int isdn_x25iface_proto_close(struct concap_proto *);
|
||||
static int isdn_x25iface_proto_restart(struct concap_proto *,
|
||||
struct net_device *,
|
||||
struct concap_device_ops *);
|
||||
static int isdn_x25iface_xmit(struct concap_proto *, struct sk_buff *);
|
||||
static int isdn_x25iface_receive(struct concap_proto *, struct sk_buff *);
|
||||
static int isdn_x25iface_connect_ind(struct concap_proto *);
|
||||
static int isdn_x25iface_disconn_ind(struct concap_proto *);
|
||||
|
||||
|
||||
static struct concap_proto_ops ix25_pops = {
|
||||
@@ -64,65 +64,65 @@ static struct concap_proto_ops ix25_pops = {
|
||||
};
|
||||
|
||||
/* error message helper function */
|
||||
static void illegal_state_warn( unsigned state, unsigned char firstbyte)
|
||||
static void illegal_state_warn(unsigned state, unsigned char firstbyte)
|
||||
{
|
||||
printk( KERN_WARNING "isdn_x25iface: firstbyte %x illegal in"
|
||||
"current state %d\n",firstbyte, state );
|
||||
printk(KERN_WARNING "isdn_x25iface: firstbyte %x illegal in"
|
||||
"current state %d\n", firstbyte, state);
|
||||
}
|
||||
|
||||
/* check protocol data field for consistency */
|
||||
static int pdata_is_bad( ix25_pdata_t * pda ){
|
||||
static int pdata_is_bad(ix25_pdata_t *pda) {
|
||||
|
||||
if( pda && pda -> magic == ISDN_X25IFACE_MAGIC ) return 0;
|
||||
printk( KERN_WARNING
|
||||
"isdn_x25iface_xxx: illegal pointer to proto data\n" );
|
||||
if (pda && pda->magic == ISDN_X25IFACE_MAGIC) return 0;
|
||||
printk(KERN_WARNING
|
||||
"isdn_x25iface_xxx: illegal pointer to proto data\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* create a new x25 interface protocol instance
|
||||
*/
|
||||
struct concap_proto * isdn_x25iface_proto_new(void)
|
||||
struct concap_proto *isdn_x25iface_proto_new(void)
|
||||
{
|
||||
ix25_pdata_t * tmp = kmalloc(sizeof(ix25_pdata_t),GFP_KERNEL);
|
||||
ix25_pdata_t *tmp = kmalloc(sizeof(ix25_pdata_t), GFP_KERNEL);
|
||||
IX25DEBUG("isdn_x25iface_proto_new\n");
|
||||
if( tmp ){
|
||||
tmp -> magic = ISDN_X25IFACE_MAGIC;
|
||||
tmp -> state = WAN_UNCONFIGURED;
|
||||
if (tmp) {
|
||||
tmp->magic = ISDN_X25IFACE_MAGIC;
|
||||
tmp->state = WAN_UNCONFIGURED;
|
||||
/* private data space used to hold the concap_proto data.
|
||||
Only to be accessed via the returned pointer */
|
||||
spin_lock_init(&tmp->priv.lock);
|
||||
tmp -> priv.dops = NULL;
|
||||
tmp -> priv.net_dev = NULL;
|
||||
tmp -> priv.pops = &ix25_pops;
|
||||
tmp -> priv.flags = 0;
|
||||
tmp -> priv.proto_data = tmp;
|
||||
return( &(tmp -> priv) );
|
||||
tmp->priv.dops = NULL;
|
||||
tmp->priv.net_dev = NULL;
|
||||
tmp->priv.pops = &ix25_pops;
|
||||
tmp->priv.flags = 0;
|
||||
tmp->priv.proto_data = tmp;
|
||||
return (&(tmp->priv));
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
/* close the x25iface encapsulation protocol
|
||||
/* close the x25iface encapsulation protocol
|
||||
*/
|
||||
static int isdn_x25iface_proto_close(struct concap_proto *cprot){
|
||||
static int isdn_x25iface_proto_close(struct concap_proto *cprot) {
|
||||
|
||||
ix25_pdata_t *tmp;
|
||||
int ret = 0;
|
||||
int ret = 0;
|
||||
ulong flags;
|
||||
|
||||
if( ! cprot ){
|
||||
printk( KERN_ERR "isdn_x25iface_proto_close: "
|
||||
"invalid concap_proto pointer\n" );
|
||||
if (!cprot) {
|
||||
printk(KERN_ERR "isdn_x25iface_proto_close: "
|
||||
"invalid concap_proto pointer\n");
|
||||
return -1;
|
||||
}
|
||||
IX25DEBUG( "isdn_x25iface_proto_close %s \n", MY_DEVNAME(cprot -> net_dev) );
|
||||
IX25DEBUG("isdn_x25iface_proto_close %s \n", MY_DEVNAME(cprot->net_dev));
|
||||
spin_lock_irqsave(&cprot->lock, flags);
|
||||
cprot -> dops = NULL;
|
||||
cprot -> net_dev = NULL;
|
||||
tmp = cprot -> proto_data;
|
||||
if( pdata_is_bad( tmp ) ){
|
||||
cprot->dops = NULL;
|
||||
cprot->net_dev = NULL;
|
||||
tmp = cprot->proto_data;
|
||||
if (pdata_is_bad(tmp)) {
|
||||
ret = -1;
|
||||
} else {
|
||||
tmp -> state = WAN_UNCONFIGURED;
|
||||
tmp->state = WAN_UNCONFIGURED;
|
||||
}
|
||||
spin_unlock_irqrestore(&cprot->lock, flags);
|
||||
return ret;
|
||||
@@ -130,100 +130,100 @@ static int isdn_x25iface_proto_close(struct concap_proto *cprot){
|
||||
|
||||
/* Delete the x25iface encapsulation protocol instance
|
||||
*/
|
||||
static void isdn_x25iface_proto_del(struct concap_proto *cprot){
|
||||
static void isdn_x25iface_proto_del(struct concap_proto *cprot) {
|
||||
|
||||
ix25_pdata_t * tmp;
|
||||
|
||||
IX25DEBUG( "isdn_x25iface_proto_del \n" );
|
||||
if( ! cprot ){
|
||||
printk( KERN_ERR "isdn_x25iface_proto_del: "
|
||||
"concap_proto pointer is NULL\n" );
|
||||
ix25_pdata_t *tmp;
|
||||
|
||||
IX25DEBUG("isdn_x25iface_proto_del \n");
|
||||
if (!cprot) {
|
||||
printk(KERN_ERR "isdn_x25iface_proto_del: "
|
||||
"concap_proto pointer is NULL\n");
|
||||
return;
|
||||
}
|
||||
tmp = cprot -> proto_data;
|
||||
if( tmp == NULL ){
|
||||
printk( KERN_ERR "isdn_x25iface_proto_del: inconsistent "
|
||||
"proto_data pointer (maybe already deleted?)\n");
|
||||
tmp = cprot->proto_data;
|
||||
if (tmp == NULL) {
|
||||
printk(KERN_ERR "isdn_x25iface_proto_del: inconsistent "
|
||||
"proto_data pointer (maybe already deleted?)\n");
|
||||
return;
|
||||
}
|
||||
/* close if the protocol is still open */
|
||||
if( cprot -> dops ) isdn_x25iface_proto_close(cprot);
|
||||
if (cprot->dops) isdn_x25iface_proto_close(cprot);
|
||||
/* freeing the storage should be sufficient now. But some additional
|
||||
settings might help to catch wild pointer bugs */
|
||||
tmp -> magic = 0;
|
||||
cprot -> proto_data = NULL;
|
||||
tmp->magic = 0;
|
||||
cprot->proto_data = NULL;
|
||||
|
||||
kfree( tmp );
|
||||
kfree(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
/* (re-)initialize the data structures for x25iface encapsulation
|
||||
*/
|
||||
static int isdn_x25iface_proto_restart(struct concap_proto *cprot,
|
||||
struct net_device *ndev,
|
||||
struct concap_device_ops *dops)
|
||||
struct net_device *ndev,
|
||||
struct concap_device_ops *dops)
|
||||
{
|
||||
ix25_pdata_t * pda = cprot -> proto_data ;
|
||||
ix25_pdata_t *pda = cprot->proto_data;
|
||||
ulong flags;
|
||||
|
||||
IX25DEBUG( "isdn_x25iface_proto_restart %s \n", MY_DEVNAME(ndev) );
|
||||
IX25DEBUG("isdn_x25iface_proto_restart %s \n", MY_DEVNAME(ndev));
|
||||
|
||||
if ( pdata_is_bad( pda ) ) return -1;
|
||||
if (pdata_is_bad(pda)) return -1;
|
||||
|
||||
if( !( dops && dops -> data_req && dops -> connect_req
|
||||
&& dops -> disconn_req ) ){
|
||||
printk( KERN_WARNING "isdn_x25iface_restart: required dops"
|
||||
" missing\n" );
|
||||
if (!(dops && dops->data_req && dops->connect_req
|
||||
&& dops->disconn_req)) {
|
||||
printk(KERN_WARNING "isdn_x25iface_restart: required dops"
|
||||
" missing\n");
|
||||
isdn_x25iface_proto_close(cprot);
|
||||
return -1;
|
||||
}
|
||||
spin_lock_irqsave(&cprot->lock, flags);
|
||||
cprot -> net_dev = ndev;
|
||||
cprot -> pops = &ix25_pops;
|
||||
cprot -> dops = dops;
|
||||
pda -> state = WAN_DISCONNECTED;
|
||||
cprot->net_dev = ndev;
|
||||
cprot->pops = &ix25_pops;
|
||||
cprot->dops = dops;
|
||||
pda->state = WAN_DISCONNECTED;
|
||||
spin_unlock_irqrestore(&cprot->lock, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* deliver a dl_data frame received from i4l HL driver to the network layer
|
||||
/* deliver a dl_data frame received from i4l HL driver to the network layer
|
||||
*/
|
||||
static int isdn_x25iface_receive(struct concap_proto *cprot, struct sk_buff *skb)
|
||||
{
|
||||
IX25DEBUG( "isdn_x25iface_receive %s \n", MY_DEVNAME(cprot->net_dev) );
|
||||
if ( ( (ix25_pdata_t*) (cprot->proto_data) )
|
||||
-> state == WAN_CONNECTED ){
|
||||
if( skb_push(skb, 1)){
|
||||
IX25DEBUG("isdn_x25iface_receive %s \n", MY_DEVNAME(cprot->net_dev));
|
||||
if (((ix25_pdata_t *)(cprot->proto_data))
|
||||
->state == WAN_CONNECTED) {
|
||||
if (skb_push(skb, 1)) {
|
||||
skb->data[0] = X25_IFACE_DATA;
|
||||
skb->protocol = x25_type_trans(skb, cprot->net_dev);
|
||||
netif_rx(skb);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
printk(KERN_WARNING "isdn_x25iface_receive %s: not connected, skb dropped\n", MY_DEVNAME(cprot->net_dev) );
|
||||
printk(KERN_WARNING "isdn_x25iface_receive %s: not connected, skb dropped\n", MY_DEVNAME(cprot->net_dev));
|
||||
dev_kfree_skb(skb);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* a connection set up is indicated by lower layer
|
||||
/* a connection set up is indicated by lower layer
|
||||
*/
|
||||
static int isdn_x25iface_connect_ind(struct concap_proto *cprot)
|
||||
{
|
||||
struct sk_buff * skb;
|
||||
enum wan_states *state_p
|
||||
= &( ( (ix25_pdata_t*) (cprot->proto_data) ) -> state);
|
||||
IX25DEBUG( "isdn_x25iface_connect_ind %s \n"
|
||||
, MY_DEVNAME(cprot->net_dev) );
|
||||
if( *state_p == WAN_UNCONFIGURED ){
|
||||
printk(KERN_WARNING
|
||||
struct sk_buff *skb;
|
||||
enum wan_states *state_p
|
||||
= &(((ix25_pdata_t *)(cprot->proto_data))->state);
|
||||
IX25DEBUG("isdn_x25iface_connect_ind %s \n"
|
||||
, MY_DEVNAME(cprot->net_dev));
|
||||
if (*state_p == WAN_UNCONFIGURED) {
|
||||
printk(KERN_WARNING
|
||||
"isdn_x25iface_connect_ind while unconfigured %s\n"
|
||||
, MY_DEVNAME(cprot->net_dev) );
|
||||
, MY_DEVNAME(cprot->net_dev));
|
||||
return -1;
|
||||
}
|
||||
*state_p = WAN_CONNECTED;
|
||||
|
||||
skb = dev_alloc_skb(1);
|
||||
if( skb ){
|
||||
if (skb) {
|
||||
*(skb_put(skb, 1)) = X25_IFACE_CONNECT;
|
||||
skb->protocol = x25_type_trans(skb, cprot->net_dev);
|
||||
netif_rx(skb);
|
||||
@@ -231,28 +231,28 @@ static int isdn_x25iface_connect_ind(struct concap_proto *cprot)
|
||||
} else {
|
||||
printk(KERN_WARNING "isdn_x25iface_connect_ind: "
|
||||
" out of memory -- disconnecting\n");
|
||||
cprot -> dops -> disconn_req(cprot);
|
||||
cprot->dops->disconn_req(cprot);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* a disconnect is indicated by lower layer
|
||||
|
||||
/* a disconnect is indicated by lower layer
|
||||
*/
|
||||
static int isdn_x25iface_disconn_ind(struct concap_proto *cprot)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
enum wan_states *state_p
|
||||
= &( ( (ix25_pdata_t*) (cprot->proto_data) ) -> state);
|
||||
IX25DEBUG( "isdn_x25iface_disconn_ind %s \n", MY_DEVNAME(cprot -> net_dev) );
|
||||
if( *state_p == WAN_UNCONFIGURED ){
|
||||
printk(KERN_WARNING
|
||||
enum wan_states *state_p
|
||||
= &(((ix25_pdata_t *)(cprot->proto_data))->state);
|
||||
IX25DEBUG("isdn_x25iface_disconn_ind %s \n", MY_DEVNAME(cprot->net_dev));
|
||||
if (*state_p == WAN_UNCONFIGURED) {
|
||||
printk(KERN_WARNING
|
||||
"isdn_x25iface_disconn_ind while unconfigured\n");
|
||||
return -1;
|
||||
}
|
||||
if(! cprot -> net_dev) return -1;
|
||||
if (!cprot->net_dev) return -1;
|
||||
*state_p = WAN_DISCONNECTED;
|
||||
skb = dev_alloc_skb(1);
|
||||
if( skb ){
|
||||
if (skb) {
|
||||
*(skb_put(skb, 1)) = X25_IFACE_DISCONNECT;
|
||||
skb->protocol = x25_type_trans(skb, cprot->net_dev);
|
||||
netif_rx(skb);
|
||||
@@ -266,57 +266,57 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *cprot)
|
||||
|
||||
/* process a frame handed over to us from linux network layer. First byte
|
||||
semantics as defined in Documentation/networking/x25-iface.txt
|
||||
*/
|
||||
*/
|
||||
static int isdn_x25iface_xmit(struct concap_proto *cprot, struct sk_buff *skb)
|
||||
{
|
||||
unsigned char firstbyte = skb->data[0];
|
||||
enum wan_states *state = &((ix25_pdata_t*)cprot->proto_data)->state;
|
||||
enum wan_states *state = &((ix25_pdata_t *)cprot->proto_data)->state;
|
||||
int ret = 0;
|
||||
IX25DEBUG("isdn_x25iface_xmit: %s first=%x state=%d\n",
|
||||
MY_DEVNAME(cprot->net_dev), firstbyte, *state);
|
||||
switch ( firstbyte ){
|
||||
MY_DEVNAME(cprot->net_dev), firstbyte, *state);
|
||||
switch (firstbyte) {
|
||||
case X25_IFACE_DATA:
|
||||
if( *state == WAN_CONNECTED ){
|
||||
if (*state == WAN_CONNECTED) {
|
||||
skb_pull(skb, 1);
|
||||
cprot -> net_dev -> trans_start = jiffies;
|
||||
ret = ( cprot -> dops -> data_req(cprot, skb) );
|
||||
cprot->net_dev->trans_start = jiffies;
|
||||
ret = (cprot->dops->data_req(cprot, skb));
|
||||
/* prepare for future retransmissions */
|
||||
if( ret ) skb_push(skb,1);
|
||||
if (ret) skb_push(skb, 1);
|
||||
return ret;
|
||||
}
|
||||
illegal_state_warn( *state, firstbyte );
|
||||
illegal_state_warn(*state, firstbyte);
|
||||
break;
|
||||
case X25_IFACE_CONNECT:
|
||||
if( *state == WAN_DISCONNECTED ){
|
||||
if (*state == WAN_DISCONNECTED) {
|
||||
*state = WAN_CONNECTING;
|
||||
ret = cprot -> dops -> connect_req(cprot);
|
||||
if(ret){
|
||||
ret = cprot->dops->connect_req(cprot);
|
||||
if (ret) {
|
||||
/* reset state and notify upper layer about
|
||||
* immidiatly failed attempts */
|
||||
isdn_x25iface_disconn_ind(cprot);
|
||||
}
|
||||
} else {
|
||||
illegal_state_warn( *state, firstbyte );
|
||||
illegal_state_warn(*state, firstbyte);
|
||||
}
|
||||
break;
|
||||
case X25_IFACE_DISCONNECT:
|
||||
switch ( *state ){
|
||||
case WAN_DISCONNECTED:
|
||||
switch (*state) {
|
||||
case WAN_DISCONNECTED:
|
||||
/* Should not happen. However, give upper layer a
|
||||
chance to recover from inconstistency but don't
|
||||
trust the lower layer sending the disconn_confirm
|
||||
when already disconnected */
|
||||
printk(KERN_WARNING "isdn_x25iface_xmit: disconnect "
|
||||
" requested while disconnected\n" );
|
||||
" requested while disconnected\n");
|
||||
isdn_x25iface_disconn_ind(cprot);
|
||||
break; /* prevent infinite loops */
|
||||
case WAN_CONNECTING:
|
||||
case WAN_CONNECTED:
|
||||
*state = WAN_DISCONNECTED;
|
||||
cprot -> dops -> disconn_req(cprot);
|
||||
cprot->dops->disconn_req(cprot);
|
||||
break;
|
||||
default:
|
||||
illegal_state_warn( *state, firstbyte );
|
||||
illegal_state_warn(*state, firstbyte);
|
||||
}
|
||||
break;
|
||||
case X25_IFACE_PARAMS:
|
||||
|
@@ -13,9 +13,9 @@
|
||||
#define ISDN_X25IFACE_MAGIC 0x1e75a2b9
|
||||
/* #define DEBUG_ISDN_X25 if you want isdn_x25 debugging messages */
|
||||
#ifdef DEBUG_ISDN_X25
|
||||
# define IX25DEBUG(fmt,args...) printk(KERN_DEBUG fmt , ## args)
|
||||
# define IX25DEBUG(fmt, args...) printk(KERN_DEBUG fmt, ##args)
|
||||
#else
|
||||
# define IX25DEBUG(fmt,args...)
|
||||
# define IX25DEBUG(fmt, args...)
|
||||
#endif
|
||||
|
||||
#include <linux/skbuff.h>
|
||||
@@ -23,17 +23,9 @@
|
||||
#include <linux/isdn.h>
|
||||
#include <linux/concap.h>
|
||||
|
||||
extern struct concap_proto_ops * isdn_x25iface_concap_proto_ops_pt;
|
||||
extern struct concap_proto * isdn_x25iface_proto_new(void);
|
||||
extern struct concap_proto_ops *isdn_x25iface_concap_proto_ops_pt;
|
||||
extern struct concap_proto *isdn_x25iface_proto_new(void);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -88,7 +88,7 @@ check_frame(struct isdnhdlc_vars *hdlc)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (hdlc->dstpos < 2) /* too small - framing error */
|
||||
if (hdlc->dstpos < 2) /* too small - framing error */
|
||||
status = -HDLC_FRAMING_ERROR;
|
||||
else if (hdlc->crc != 0xf0b8) /* crc error */
|
||||
status = -HDLC_CRC_ERROR;
|
||||
@@ -127,9 +127,9 @@ check_frame(struct isdnhdlc_vars *hdlc)
|
||||
dsize - destination buffer size
|
||||
returns - number of decoded bytes in the destination buffer and status
|
||||
flag.
|
||||
*/
|
||||
*/
|
||||
int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
|
||||
int *count, u8 *dst, int dsize)
|
||||
int *count, u8 *dst, int dsize)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
@@ -145,28 +145,28 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
|
||||
0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff
|
||||
};
|
||||
|
||||
#define handle_fast_flag(h) \
|
||||
do {\
|
||||
if (h->cbin == fast_flag[h->bit_shift]) {\
|
||||
h->ffvalue = fast_flag_value[h->bit_shift];\
|
||||
h->state = HDLC_FAST_FLAG;\
|
||||
h->ffbit_shift = h->bit_shift;\
|
||||
h->bit_shift = 1;\
|
||||
} else {\
|
||||
h->state = HDLC_GET_DATA;\
|
||||
h->data_received = 0;\
|
||||
} \
|
||||
#define handle_fast_flag(h) \
|
||||
do { \
|
||||
if (h->cbin == fast_flag[h->bit_shift]) { \
|
||||
h->ffvalue = fast_flag_value[h->bit_shift]; \
|
||||
h->state = HDLC_FAST_FLAG; \
|
||||
h->ffbit_shift = h->bit_shift; \
|
||||
h->bit_shift = 1; \
|
||||
} else { \
|
||||
h->state = HDLC_GET_DATA; \
|
||||
h->data_received = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define handle_abort(h) \
|
||||
do {\
|
||||
h->shift_reg = fast_abort[h->ffbit_shift - 1];\
|
||||
h->hdlc_bits1 = h->ffbit_shift - 2;\
|
||||
if (h->hdlc_bits1 < 0)\
|
||||
h->hdlc_bits1 = 0;\
|
||||
h->data_bits = h->ffbit_shift - 1;\
|
||||
h->state = HDLC_GET_DATA;\
|
||||
h->data_received = 0;\
|
||||
#define handle_abort(h) \
|
||||
do { \
|
||||
h->shift_reg = fast_abort[h->ffbit_shift - 1]; \
|
||||
h->hdlc_bits1 = h->ffbit_shift - 2; \
|
||||
if (h->hdlc_bits1 < 0) \
|
||||
h->hdlc_bits1 = 0; \
|
||||
h->data_bits = h->ffbit_shift - 1; \
|
||||
h->state = HDLC_GET_DATA; \
|
||||
h->data_received = 0; \
|
||||
} while (0)
|
||||
|
||||
*count = slen;
|
||||
@@ -204,7 +204,7 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
|
||||
if ((!hdlc->do_adapt56) &&
|
||||
(++hdlc->hdlc_bits1 >= 8) &&
|
||||
(hdlc->bit_shift == 1))
|
||||
hdlc->state = HDLC_FAST_IDLE;
|
||||
hdlc->state = HDLC_FAST_IDLE;
|
||||
}
|
||||
hdlc->cbin <<= 1;
|
||||
hdlc->bit_shift--;
|
||||
@@ -295,7 +295,7 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
|
||||
hdlc->data_bits = 0;
|
||||
hdlc->data_received = 1;
|
||||
hdlc->crc = crc_ccitt_byte(hdlc->crc,
|
||||
hdlc->shift_reg);
|
||||
hdlc->shift_reg);
|
||||
|
||||
/* good byte received */
|
||||
if (hdlc->dstpos < dsize)
|
||||
@@ -352,7 +352,7 @@ EXPORT_SYMBOL(isdnhdlc_decode);
|
||||
returns - number of encoded bytes in the destination buffer
|
||||
*/
|
||||
int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen,
|
||||
int *count, u8 *dst, int dsize)
|
||||
int *count, u8 *dst, int dsize)
|
||||
{
|
||||
static const unsigned char xfast_flag_value[] = {
|
||||
0x7e, 0x3f, 0x9f, 0xcf, 0xe7, 0xf3, 0xf9, 0xfc, 0x7e
|
||||
@@ -478,7 +478,7 @@ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen,
|
||||
}
|
||||
if (hdlc->bit_shift == 8)
|
||||
hdlc->crc = crc_ccitt_byte(hdlc->crc,
|
||||
hdlc->shift_reg);
|
||||
hdlc->shift_reg);
|
||||
if (hdlc->shift_reg & 0x01) {
|
||||
hdlc->hdlc_bits1++;
|
||||
hdlc->cbin++;
|
||||
|
Référencer dans un nouveau ticket
Bloquer un utilisateur