-
Notifications
You must be signed in to change notification settings - Fork 18
/
slcand.c
53 lines (45 loc) · 1.06 KB
/
slcand.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* slcand.c - userspace daemon for serial line CAN interface driver SLCAN
* rewritten from it's original source in C to the OS X.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <syslog.h>
#include <errno.h>
#include <pwd.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <sys/tty.h>
#include <sys/sockio.h>
/* Daemon name */
#define DAEMON_NAME "slcandx"
/* Run under this specific user */
#define RUN_AS_USER "root"
/* The length of ttypath buffer */
#define TTYPATH_LENGTH 64
/* UART flow control types */
#define FLOW_NONE 0
#define FLOW_HW 1
#define FLOW_SW 2
void print_usage(char *prg)
{
fprintf(stderr, "\nUsage: %s <tty> <canif-name>\n\n", prg);
exit(EXIT_FAILURE);
}
static int slcand_running;
static int exit_code;
static char ttypath[TTYPATH_LENGTH];
int main(int argc, char *argv[])
{
char *tty = NULL;
char const *devprefix = "/dev";
char *name = NULL;
char buf[IFNAMSIZ+1];
}