-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 1988 b: refs/heads/master c: a3c77c6 h: refs/heads/master v: v3
- Loading branch information
Jeff Dike
authored and
Linus Torvalds
committed
Jun 14, 2005
1 parent
b56d282
commit 7cd53e4
Showing
10 changed files
with
182 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 98fdffccea6cc3fe9dba32c0fcc310bcb5d71529 | ||
refs/heads/master: a3c77c67a443e631febf708bb0c376caede31657 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,20 @@ | ||
#ifndef __UM_SLIP_H | ||
#define __UM_SLIP_H | ||
|
||
#define BUF_SIZE 1500 | ||
/* two bytes each for a (pathological) max packet of escaped chars + * | ||
* terminating END char + initial END char */ | ||
#define ENC_BUF_SIZE (2 * BUF_SIZE + 2) | ||
#include "slip_common.h" | ||
|
||
struct slip_data { | ||
void *dev; | ||
char name[sizeof("slnnnnn\0")]; | ||
char *addr; | ||
char *gate_addr; | ||
int slave; | ||
unsigned char ibuf[ENC_BUF_SIZE]; | ||
unsigned char obuf[ENC_BUF_SIZE]; | ||
int more; /* more data: do not read fd until ibuf has been drained */ | ||
int pos; | ||
int esc; | ||
struct slip_proto slip; | ||
}; | ||
|
||
extern struct net_user_info slip_user_info; | ||
|
||
extern int set_umn_addr(int fd, char *addr, char *ptp_addr); | ||
extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri); | ||
extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri); | ||
|
||
#endif | ||
|
||
/* | ||
* Overrides for Emacs so that we follow Linus's tabbing style. | ||
* Emacs will notice this stuff at the end of the file and automatically | ||
* adjust the settings for this buffer only. This must remain at the end | ||
* of the file. | ||
* --------------------------------------------------------------------------- | ||
* Local variables: | ||
* c-file-style: "linux" | ||
* End: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <string.h> | ||
#include "slip_common.h" | ||
#include "net_user.h" | ||
|
||
int slip_proto_read(int fd, void *buf, int len, struct slip_proto *slip) | ||
{ | ||
int i, n, size, start; | ||
|
||
if(slip->more > 0){ | ||
i = 0; | ||
while(i < slip->more){ | ||
size = slip_unesc(slip->ibuf[i++], slip->ibuf, | ||
&slip->pos, &slip->esc); | ||
if(size){ | ||
memcpy(buf, slip->ibuf, size); | ||
memmove(slip->ibuf, &slip->ibuf[i], | ||
slip->more - i); | ||
slip->more = slip->more - i; | ||
return size; | ||
} | ||
} | ||
slip->more = 0; | ||
} | ||
|
||
n = net_read(fd, &slip->ibuf[slip->pos], | ||
sizeof(slip->ibuf) - slip->pos); | ||
if(n <= 0) | ||
return n; | ||
|
||
start = slip->pos; | ||
for(i = 0; i < n; i++){ | ||
size = slip_unesc(slip->ibuf[start + i], slip->ibuf,&slip->pos, | ||
&slip->esc); | ||
if(size){ | ||
memcpy(buf, slip->ibuf, size); | ||
memmove(slip->ibuf, &slip->ibuf[start+i+1], | ||
n - (i + 1)); | ||
slip->more = n - (i + 1); | ||
return size; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
int slip_proto_write(int fd, void *buf, int len, struct slip_proto *slip) | ||
{ | ||
int actual, n; | ||
|
||
actual = slip_esc(buf, slip->obuf, len); | ||
n = net_write(fd, slip->obuf, actual); | ||
if(n < 0) | ||
return n; | ||
else return len; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.