Send the open flag sequence only when enough time elapsed since prior
closing flag sequence. See RFC1662 §4.4.2, last paragraph. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39628 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -46,6 +46,7 @@ struct dialup_device : net_device {
|
|||||||
int fd;
|
int fd;
|
||||||
struct termios line_config;
|
struct termios line_config;
|
||||||
dialup_state state;
|
dialup_state state;
|
||||||
|
bigtime_t last_closing_flag_sequence_time;
|
||||||
bool data_mode;
|
bool data_mode;
|
||||||
char init_string[64];
|
char init_string[64];
|
||||||
char dial_string[64];
|
char dial_string[64];
|
||||||
@@ -205,9 +206,11 @@ dialup_init(const char* name, net_device** _device)
|
|||||||
device->mtu = 1500;
|
device->mtu = 1500;
|
||||||
device->media = 0;
|
device->media = 0;
|
||||||
device->header_length = HDLC_HEADER_LENGTH;
|
device->header_length = HDLC_HEADER_LENGTH;
|
||||||
|
|
||||||
device->fd = -1;
|
device->fd = -1;
|
||||||
device->state = DOWN;
|
device->state = DOWN;
|
||||||
device->data_mode = false;
|
device->data_mode = false;
|
||||||
|
device->last_closing_flag_sequence_time = 0;
|
||||||
|
|
||||||
// default AT strings
|
// default AT strings
|
||||||
strncpy(device->init_string, "ATZ", sizeof(device->init_string));
|
strncpy(device->init_string, "ATZ", sizeof(device->init_string));
|
||||||
@@ -362,6 +365,7 @@ dialup_send_data(net_device* _device, net_buffer* buffer)
|
|||||||
int packetSize = 0;
|
int packetSize = 0;
|
||||||
status_t status;
|
status_t status;
|
||||||
ssize_t bytesWritten;
|
ssize_t bytesWritten;
|
||||||
|
bigtime_t now;
|
||||||
|
|
||||||
uint32 vectorCount = gBufferModule->count_iovecs(buffer);
|
uint32 vectorCount = gBufferModule->count_iovecs(buffer);
|
||||||
if (vectorCount < 1) {
|
if (vectorCount < 1) {
|
||||||
@@ -379,14 +383,19 @@ dialup_send_data(net_device* _device, net_buffer* buffer)
|
|||||||
// encode HDLC packet
|
// encode HDLC packet
|
||||||
|
|
||||||
// worst case: begin and end sequence flags and each byte needing escape
|
// worst case: begin and end sequence flags and each byte needing escape
|
||||||
packet = (uint8*) malloc(2 + 2 * buffer->size);
|
packet = (uint8*)malloc(2 + 2 * buffer->size);
|
||||||
if (packet == NULL) {
|
if (packet == NULL) {
|
||||||
status = B_NO_MEMORY;
|
status = B_NO_MEMORY;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark frame start
|
// Mark frame start if the prior frame closing flag was sent
|
||||||
packet[packetSize++] = HDLC_FLAG_SEQUENCE;
|
// more than a second ago.
|
||||||
|
// Otherwise, the prior closing flag sequence is the open flag of this
|
||||||
|
// frame
|
||||||
|
now = system_time();
|
||||||
|
if (now - device->last_closing_flag_sequence_time > 1000000)
|
||||||
|
packet[packetSize++] = HDLC_FLAG_SEQUENCE;
|
||||||
|
|
||||||
// encode frame data
|
// encode frame data
|
||||||
ioVector = ioVectors;
|
ioVector = ioVectors;
|
||||||
@@ -416,6 +425,7 @@ dialup_send_data(net_device* _device, net_buffer* buffer)
|
|||||||
status = errno;
|
status = errno;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
device->last_closing_flag_sequence_time = system_time();
|
||||||
|
|
||||||
device->stats.send.packets++;
|
device->stats.send.packets++;
|
||||||
device->stats.send.bytes += bytesWritten;
|
device->stats.send.bytes += bytesWritten;
|
||||||
|
|||||||
Reference in New Issue
Block a user