Commit 4220b51a authored by Alessandro Rubini's avatar Alessandro Rubini

arch-bare-*: unify common code

This unifies all bare-linux common code. It's an out-of-context commit
(as I'm not adding bare-arm today) but I prefer to avoid doing the same
change twice in things that are going to change these days.

BTW: this commit introduces no changes in the binary files generated,
with the exception of a small difference between i386 and x86-64 in
the receive buffer.  This keeps the x86-64 version but i386 was not
working anyways (and still doesn't work).  That bug fix is in my queue,
but I've other things to do first with ppsi.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 57ef61c3
......@@ -3,16 +3,19 @@
CFLAGS += -ffreestanding -Os -fno-stack-protector
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
# All files are under A (short for ARCH): I'm lazy
# All files are under A (short for ARCH) or L (short for lib): I'm lazy
A := arch-$(ARCH)
L := lib-bare
CFLAGS += -Ilib-bare
LIBARCH := $A/libarch.a
OBJ-libarch := $A/bare-startup.o \
$A/main-loop.o \
$A/bare-socket.o \
$A/bare-io.o \
$A/bare-time.o \
OBJ-libarch := $L/bare-startup.o \
$L/main-loop.o \
$L/bare-socket.o \
$L/bare-io.o \
$L/bare-time.o \
$A/syscalls.o \
lib/libc-functions.o \
lib/cmdline.o \
......
/*
* Alessandro Rubini for CERN, 2011 -- public domain
*/
/* Socket interface for bare Linux */
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-i386.h"
/* 14 is ppi->proto_ofst for ethernet mode */
Octet buffer_out[PP_PACKET_SIZE + 14];
/* FIXME: which socket we receive and send with? */
static int bare_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t)
{
if (t)
pp_t_ops.get(t);
return sys_recv(NP(ppi)->ch[PP_NP_GEN].fd,
pkt - NP(ppi)->proto_ofst, len, 0);
}
static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr)
{
struct bare_ethhdr *hdr;
hdr = PROTO_HDR(pkt);
hdr->h_proto = htons(ETH_P_1588);
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, 6);
/* raw socket implementation always uses gen socket */
memcpy(hdr->h_source, NP(ppi)->ch[PP_NP_GEN].addr, 6);
if (t)
pp_t_ops.get(t);
return sys_send(NP(ppi)->ch[chtype].fd, hdr,
len + NP(ppi)->proto_ofst, 0);
}
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
#define PF_PACKET 17
#define SOCK_RAW 3
/* To open a channel we must bind to an interface and so on */
static int bare_open_ch(struct pp_instance *ppi, char *ifname)
{
int sock = -1;
int temp, iindex;
struct bare_ifreq ifr;
struct bare_sockaddr_ll addr_ll;
struct bare_packet_mreq pmr;
if (OPTS(ppi)->ethernet_mode) {
/* open socket */
sock = sys_socket(PF_PACKET, SOCK_RAW, ETH_P_1588);
if (sock < 0) {
pp_diag_error(ppi, bare_errno);
pp_diag_fatal(ppi, "socket()", "");
sys_close(sock);
return -1;
}
/* hw interface information */
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_ifrn.ifrn_name, ifname);
if (sys_ioctl(sock, SIOCGIFINDEX, &ifr) < 0) {
pp_diag_error(ppi, bare_errno);
pp_diag_fatal(ppi, "ioctl(GIFINDEX)", "");
sys_close(sock);
return -1;
}
iindex = ifr.ifr_ifru.index;
if (sys_ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) {
pp_diag_error(ppi, bare_errno);
pp_diag_fatal(ppi, "ioctl(GIFHWADDR)", "");
sys_close(sock);
return -1;
}
memcpy(NP(ppi)->ch[PP_NP_GEN].addr,
ifr.ifr_ifru.ifru_hwaddr.sa_data, 6);
memcpy(NP(ppi)->ch[PP_NP_EVT].addr,
ifr.ifr_ifru.ifru_hwaddr.sa_data, 6);
/* bind */
memset(&addr_ll, 0, sizeof(addr_ll));
addr_ll.sll_family = PF_PACKET;
addr_ll.sll_protocol = htons(ETH_P_1588);
addr_ll.sll_ifindex = iindex;
if (sys_bind(sock, (struct bare_sockaddr *)&addr_ll,
sizeof(addr_ll)) < 0) {
pp_diag_error(ppi, bare_errno);
pp_diag_fatal(ppi, "bind", "");
sys_close(sock);
return -1;
}
/* accept the multicast address for raw-ethernet ptp */
memset(&pmr, 0, sizeof(pmr));
pmr.mr_ifindex = iindex;
pmr.mr_type = PACKET_MR_MULTICAST;
pmr.mr_alen = ETH_ALEN;
memcpy(pmr.mr_address, PP_MCAST_MACADDRESS, ETH_ALEN);
sys_setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
NP(ppi)->ch[PP_NP_GEN].fd = sock;
NP(ppi)->ch[PP_NP_EVT].fd = sock;
/* make timestamps available through recvmsg() -- FIXME: hw? */
sys_setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP,
&temp, sizeof(int));
return 0;
}
return -1;
}
static int bare_net_init(struct pp_instance *ppi)
{
ppi->buf_out = buffer_out;
ppi->buf_out = PROTO_PAYLOAD(ppi->buf_out);
if (OPTS(ppi)->ethernet_mode) {
PP_PRINTF("bare_net_init IEEE 802.3\n");
/* raw sockets implementation always use gen socket */
return bare_open_ch(ppi, OPTS(ppi)->iface_name);
}
/* else: UDP */
PP_PRINTF("bare_net_init UDP\n");
return 0;
}
static int bare_net_exit(struct pp_instance *ppi)
{
return sys_shutdown(NP(ppi)->ch[PP_NP_GEN].fd, SHUT_RDWR);
}
struct pp_network_operations pp_net_ops = {
.init = bare_net_init,
.exit = bare_net_exit,
.recv = bare_net_recv,
.send = bare_net_send,
};
/*
* Alessandro Rubini for CERN, 2011 -- GNU LGPL v2.1 or later
*/
/*
* This is the main loop for "freestanding" stuff under Linux.
*/
#include <ppsi/ppsi.h>
#include "bare-i386.h"
/* Define other hackish stuff */
struct bare_fd_set {
unsigned long bits[1024/32];
};
#define FD_ZERO(p) memset(p, 0, sizeof(p))
#define FD_SET(bit, p) ((p)->bits[0] |= (1 << (bit)))
void bare_main_loop(struct pp_instance *ppi)
{
int delay_ms;
clear_TimeInternal(&ppi->last_rcv_time);
NP(ppi)->proto_ofst = 14;
/*
* The main loop here is based on select. While we are not
* doing anything else but the protocol, this allows extra stuff
* to fit.
*/
delay_ms = pp_state_machine(ppi, NULL, 0);
while (1) {
struct bare_fd_set set;
int i, maxfd;
struct bare_timeval tv;
unsigned char packet[1500];
void *payload = packet + 16; /* aligned */
/* Wait for a packet or for the timeout */
tv.tv_sec = delay_ms / 1000;
tv.tv_usec = (delay_ms % 1000) * 1000;
again:
FD_ZERO(&set);
FD_SET(NP(ppi)->ch[PP_NP_GEN].fd, &set);
FD_SET(NP(ppi)->ch[PP_NP_EVT].fd, &set);
maxfd = NP(ppi)->ch[PP_NP_GEN].fd;
if (NP(ppi)->ch[PP_NP_EVT].fd > maxfd)
maxfd = NP(ppi)->ch[PP_NP_EVT].fd;
i = sys_select(maxfd + 1, &set, NULL, NULL, &tv);
if (i < 0 && bare_errno != 4 /* EINTR */)
sys_exit(__LINE__);
if (i < 0)
continue;
if (i == 0) {
delay_ms = pp_state_machine(ppi, NULL, 0);
continue;
}
/*
* We got a packet. If it's not ours, continue consuming
* the pending timeout.
*
* FIXME: we don't know which socket to receive from
*/
i = pp_net_ops.recv(ppi, payload, sizeof(packet),
&ppi->last_rcv_time);
ppi->last_rcv_time.seconds += DSPRO(ppi)->currentUtcOffset;
/* we passed payload but it filled the ether header too */
if (((struct bare_ethhdr *)(packet + 2))->h_proto
!= htons(PP_ETHERTYPE))
goto again;
delay_ms = pp_state_machine(ppi, packet, i);
}
}
......@@ -4,7 +4,7 @@
#include <linux/unistd.h>
#include <ppsi/ppsi.h>
#include "bare-i386.h"
#include "bare-linux.h"
#include "syscalls.h"
int bare_errno;
......
......@@ -3,16 +3,19 @@
CFLAGS += -ffreestanding -Os -fno-stack-protector
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
# All files are under A (short for ARCH): I'm lazy
# All files are under A (short for ARCH) or L (short for lib): I'm lazy
A := arch-$(ARCH)
L := lib-bare
CFLAGS += -Ilib-bare
LIBARCH := $A/libarch.a
OBJ-libarch := $A/bare-startup.o \
$A/main-loop.o \
$A/bare-socket.o \
$A/bare-io.o \
$A/bare-time.o \
OBJ-libarch := $L/bare-startup.o \
$L/main-loop.o \
$L/bare-socket.o \
$L/bare-io.o \
$L/bare-time.o \
$A/syscall.o \
$A/syscalls.o \
lib/libc-functions.o \
......
/*
* Alessandro Rubini for CERN, 2011 -- public domain
*/
#include <ppsi/ppsi.h>
#include "bare-x86-64.h"
void pp_puts(const char *s)
{
sys_write(0, s, strnlen(s, 300));
}
/*
* Alessandro Rubini for CERN, 2011 -- GNU LGPL v2.1 or later
*/
/*
* This is the startup thing for "freestanding" stuff under Linux.
* It must also clear the BSS as I'm too lazy to do that in asm
*/
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-x86-64.h"
void ppsi_clear_bss(void)
{
int *ptr;
extern int __bss_start, __bss_end;
for (ptr = &__bss_start; ptr < &__bss_end; ptr++)
*ptr = 0;
}
static struct pp_instance ppi_static;
static struct pp_net_path net_path_static;
CONST_VERBOSITY int pp_diag_verbosity = 0;
/* ppi fields */
static DSDefault defaultDS;
static DSCurrent currentDS;
static DSParent parentDS;
static DSPort portDS;
static DSTimeProperties timePropertiesDS;
static struct pp_servo servo;
static struct pp_frgn_master frgn_master;
int ppsi_main(int argc, char **argv)
{
struct pp_instance *ppi = &ppi_static; /* no malloc, one instance */
PP_PRINTF("bare: starting. Compiled on %s\n", __DATE__);
ppi->net_path = &net_path_static;
ppi->defaultDS = &defaultDS;
ppi->currentDS = &currentDS;
ppi->parentDS = &parentDS;
ppi->portDS = &portDS;
ppi->timePropertiesDS = &timePropertiesDS;
ppi->servo = &servo;
ppi->frgn_master = &frgn_master;
ppi->arch_data = NULL;
/* This just llocates the stuff */
pp_open_instance(ppi, NULL);
OPTS(ppi)->iface_name = "eth0";
if (pp_parse_cmdline(ppi, argc, argv) != 0)
return -1;
/* The actual sockets are opened in state-initializing */
bare_main_loop(ppi);
return 0;
}
/*
* Alessandro Rubini for CERN, 2013 -- LGPL 2.1 or later
*/
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-x86-64.h"
static int bare_time_get(TimeInternal *t)
{
struct bare_timeval tv;
if (sys_gettimeofday(&tv, NULL) < 0) {
PP_PRINTF("gettimeofday error");
sys_exit(1);
}
t->seconds = tv.tv_sec;
t->nanoseconds = tv.tv_usec * 1000;
if (pp_verbose_time && !(pp_global_flags & PP_FLAG_NOTIMELOG))
pp_printf("%s: %9li.%06li\n", __func__, tv.tv_sec, tv.tv_usec);
return 0;
}
static int bare_time_set(TimeInternal *t)
{
struct bare_timeval tv;
tv.tv_sec = t->seconds;
tv.tv_usec = t->nanoseconds / 1000;
if (sys_settimeofday(&tv, NULL) < 0) {
PP_PRINTF("settimeofday error");
sys_exit(1);
}
if (pp_verbose_time)
pp_printf("%s: %9li.%06li\n", __func__, tv.tv_sec, tv.tv_usec);
return 0;
}
static int bare_time_adjust(long offset_ns, long freq_ppm)
{
struct bare_timex t;
int ret;
if (freq_ppm > PP_ADJ_FREQ_MAX)
freq_ppm = PP_ADJ_FREQ_MAX;
if (freq_ppm < -PP_ADJ_FREQ_MAX)
freq_ppm = -PP_ADJ_FREQ_MAX;
t.offset = offset_ns / 1000;
t.freq = freq_ppm; /* was: "adj * ((1 << 16) / 1000)" */
t.modes = MOD_FREQUENCY | MOD_OFFSET;
ret = sys_adjtimex(&t);
if (pp_verbose_time)
pp_printf("%s: %li %li\n", __func__, offset_ns, freq_ppm);
return ret;
}
static unsigned long bare_calc_timeout(int millisec)
{
struct bare_timespec now;
uint64_t now_ms;
unsigned long result;
if (!millisec)
millisec = 1;
sys_clock_gettime(CLOCK_MONOTONIC, &now);
now_ms = 1000LL * now.tv_sec + now.tv_nsec / 1000 / 1000;
result = now_ms + millisec;
return result ? result : 1; /* cannot return 0 */
}
struct pp_time_operations pp_t_ops = {
.get = bare_time_get,
.set = bare_time_set,
.adjust = bare_time_adjust,
.calc_timeout = bare_calc_timeout,
};
/*
* Alessandro Rubini for CERN, 2011 -- GNU LGPL v2.1 or later
*/
#include <string.h>
/*
* These are the functions provided by the various bare files
*/
extern void bare_main_loop(struct pp_instance *ppi);
/* syscalls */
struct bare_sockaddr;
extern int sys_write(int fd, const void *buf, int count);
extern void sys_exit(int exitval);
extern int sys_time(int tz);
extern int sys_select(int max, void *in, void *out, void *exc, void *tout);
extern int sys_ioctl(int fd, int cmd, void *arg);
extern int sys_socket(int domain, int type, int proto);
extern int sys_bind(int fd, const struct bare_sockaddr *addr, int addrlen);
extern int sys_recv(int fd, void *pkt, int plen, int flags);
extern int sys_send(int fd, void *pkt, int plen, int flags);
extern int sys_shutdown(int fd, int flags);
extern int sys_close(int fd);
extern int sys_setsockopt(int fd, int level, int optname, const void *optval,
int optlen);
extern int sys_gettimeofday(void *tv, void *z);
extern int sys_settimeofday(void *tv, void *z);
extern int sys_adjtimex(void *tv);
extern int sys_clock_gettime(int clock, void *t);
extern int bare_errno;
/* structures passed to syscalls */
#define IFNAMSIZ 16
struct bare_sockaddr {
uint16_t sa_family; /* address family, AF_xxx */
char sa_data[14]; /* 14 bytes of protocol address */
};
struct bare_ifreq {
union {
char ifrn_name[IFNAMSIZ];
} ifr_ifrn;
union {
struct bare_sockaddr ifru_hwaddr;
int index;
} ifr_ifru;
};
struct bare_sockaddr_ll {
unsigned short int sll_family;
unsigned short int sll_protocol;
int sll_ifindex;
unsigned short int sll_hatype;
unsigned char sll_pkttype;
unsigned char sll_halen;
unsigned char sll_addr[8];
};
#define SIOCGIFINDEX 0x8933
#define SIOCGIFHWADDR 0x8927
#define SO_TIMESTAMP 29
#define SOL_SOCKET 1
/* from uapi/linux/if_ether.h */
#define ETH_ALEN 6 /* Octets in one ethernet addr */
/* start copy from linux/socket.h */
/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
#define SOL_IP 0
/* #define SOL_ICMP 1 No-no-no! We cannot use SOL_ICMP=1 */
#define SOL_TCP 6
#define SOL_UDP 17
#define SOL_IPV6 41
#define SOL_ICMPV6 58
#define SOL_SCTP 132
#define SOL_UDPLITE 136 /* UDP-Lite (RFC 3828) */
#define SOL_RAW 255
#define SOL_IPX 256
#define SOL_AX25 257
#define SOL_ATALK 258
#define SOL_NETROM 259
#define SOL_ROSE 260
#define SOL_DECNET 261
#define SOL_X25 262
#define SOL_PACKET 263
#define SOL_ATM 264 /* ATM layer (cell level) */
#define SOL_AAL 265 /* ATM Adaption Layer (packet level) */
#define SOL_IRDA 266
#define SOL_NETBEUI 267
#define SOL_LLC 268
#define SOL_DCCP 269
#define SOL_NETLINK 270
#define SOL_TIPC 271
#define SOL_RXRPC 272
#define SOL_PPPOL2TP 273
#define SOL_BLUETOOTH 274
#define SOL_PNPIPE 275
#define SOL_RDS 276
#define SOL_IUCV 277
#define SOL_CAIF 278
#define SOL_ALG 279
/* end copy from linux/socket.h */
/* start copy from uapi/linux/if_packet.h */
struct bare_packet_mreq {
int mr_ifindex;
unsigned short mr_type;
unsigned short mr_alen;
unsigned char mr_address[8];
};
#define PACKET_MR_MULTICAST 0
#define PACKET_MR_PROMISC 1
#define PACKET_MR_ALLMULTI 2
#define PACKET_MR_UNICAST 3
/* Packet types */
#define PACKET_HOST 0 /* To us */
#define PACKET_BROADCAST 1 /* To all */
#define PACKET_MULTICAST 2 /* To group */
#define PACKET_OTHERHOST 3 /* To someone else */
#define PACKET_OUTGOING 4 /* Outgoing of any type */
/* These ones are invisible by user level */
#define PACKET_LOOPBACK 5 /* MC/BRD frame looped back */
#define PACKET_FASTROUTE 6 /* Fastrouted frame */
/* Packet socket options */
#define PACKET_ADD_MEMBERSHIP 1
#define PACKET_DROP_MEMBERSHIP 2
#define PACKET_RECV_OUTPUT 3
/* Value 4 is still used by obsolete turbo-packet. */
#define PACKET_RX_RING 5
#define PACKET_STATISTICS 6
#define PACKET_COPY_THRESH 7
#define PACKET_AUXDATA 8
#define PACKET_ORIGDEV 9
#define PACKET_VERSION 10
#define PACKET_HDRLEN 11
#define PACKET_RESERVE 12
#define PACKET_TX_RING 13
#define PACKET_LOSS 14
#define PACKET_VNET_HDR 15
#define PACKET_TX_TIMESTAMP 16
#define PACKET_TIMESTAMP 17
#define PACKET_FANOUT 18
/* end copy from linux/if_packet.h */
/* other network stuff, bah.... */
struct bare_ethhdr {
unsigned char h_dest[6];
unsigned char h_source[6];
uint16_t h_proto;
} __attribute__((packed));
struct bare_timeval {
long tv_sec;
long tv_usec;
};
struct bare_timespec {
long tv_sec;
long tv_nsec;
};
#ifndef NULL
#define NULL 0
#endif
/* from linux/timex.h */
/*
* Mode codes (timex.mode)
*/
#define ADJ_OFFSET 0x0001 /* time offset */
#define ADJ_FREQUENCY 0x0002 /* frequency offset */
#define ADJ_MAXERROR 0x0004 /* maximum time error */
#define ADJ_ESTERROR 0x0008 /* estimated time error */
#define ADJ_STATUS 0x0010 /* clock status */
#define ADJ_TIMECONST 0x0020 /* pll time constant */
#define ADJ_TAI 0x0080 /* set TAI offset */
#define ADJ_MICRO 0x1000 /* select microsecond resolution */
#define ADJ_NANO 0x2000 /* select nanosecond resolution */
#define ADJ_TICK 0x4000 /* tick value */
#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
/* xntp 3.4 compatibility names */
#define MOD_OFFSET ADJ_OFFSET
#define MOD_FREQUENCY ADJ_FREQUENCY
#define MOD_MAXERROR ADJ_MAXERROR
#define MOD_ESTERROR ADJ_ESTERROR
#define MOD_STATUS ADJ_STATUS
#define MOD_TIMECONST ADJ_TIMECONST
struct bare_timex {
unsigned int modes; /* mode selector */
long offset; /* time offset (usec) */
long freq; /* frequency offset (scaled ppm) */
long maxerror; /* maximum error (usec) */
long esterror; /* estimated error (usec) */
int status; /* clock command/status */
long constant; /* pll time constant */
long precision; /* clock precision (usec) (read only) */
long tolerance; /* clock frequency tolerance (ppm)
* (read only)
*/
struct bare_timeval time; /* (RO, except for ADJ_SETOFFSET) */
long tick; /* (modified) usecs between clock ticks */
long ppsfreq; /* pps frequency (scaled ppm) (ro) */
long jitter; /* pps jitter (us) (ro) */
int shift; /* interval duration (s) (shift) (ro) */
long stabil; /* pps stability (scaled ppm) (ro) */
long jitcnt; /* jitter limit exceeded (ro) */
long calcnt; /* calibration intervals (ro) */
long errcnt; /* calibration errors (ro) */
long stbcnt; /* stability limit exceeded (ro) */
int tai; /* TAI offset (ro) */
int :32; int :32; int :32; int :32;
int :32; int :32; int :32; int :32;
int :32; int :32; int :32;
};
/*
* Copy from <linux/time.h>
*
* The IDs of the various system clocks (for POSIX.1b interval timers):
*/
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 1
#define CLOCK_PROCESS_CPUTIME_ID 2
#define CLOCK_THREAD_CPUTIME_ID 3
#define CLOCK_MONOTONIC_RAW 4
#define CLOCK_REALTIME_COARSE 5
#define CLOCK_MONOTONIC_COARSE 6
......@@ -32,7 +32,7 @@ int __syscall_error(void)
#include <linux/unistd.h>
#include <ppsi/ppsi.h>
#include "bare-x86-64.h"
#include "bare-linux.h"
/*
* We depends on syscall.S that does the register passing
......
......@@ -2,10 +2,9 @@
* Alessandro Rubini for CERN, 2011 -- public domain
*/
#include <ppsi/ppsi.h>
#include "bare-i386.h"
#include "bare-linux.h"
void pp_puts(const char *s)
{
sys_write(0, s, strnlen(s, 300));
}
......@@ -63,48 +63,48 @@ struct bare_sockaddr_ll {
#define SIOCGIFINDEX 0x8933
#define SIOCGIFHWADDR 0x8927
#define SO_TIMESTAMP 29
#define SOL_SOCKET 1
#define SO_TIMESTAMP 29
#define SOL_SOCKET 1
/* from uapi/linux/if_ether.h */
#define ETH_ALEN 6 /* Octets in one ethernet addr */
#define ETH_ALEN 6 /* Octets in one ethernet addr */
/* start copy from linux/socket.h */
/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
#define SOL_IP 0
/* #define SOL_ICMP 1 No-no-no! We cannot use SOL_ICMP=1 */
#define SOL_TCP 6
#define SOL_UDP 17
#define SOL_IPV6 41
#define SOL_ICMPV6 58
#define SOL_SCTP 132
#define SOL_UDPLITE 136 /* UDP-Lite (RFC 3828) */
#define SOL_RAW 255
#define SOL_IPX 256
#define SOL_AX25 257
#define SOL_ATALK 258
#define SOL_NETROM 259
#define SOL_ROSE 260
#define SOL_DECNET 261
#define SOL_X25 262
#define SOL_PACKET 263
#define SOL_ATM 264 /* ATM layer (cell level) */
#define SOL_AAL 265 /* ATM Adaption Layer (packet level) */
#define SOL_IRDA 266
#define SOL_NETBEUI 267
#define SOL_LLC 268
#define SOL_DCCP 269
#define SOL_NETLINK 270
#define SOL_TIPC 271
#define SOL_RXRPC 272
#define SOL_PPPOL2TP 273
#define SOL_BLUETOOTH 274
#define SOL_PNPIPE 275
#define SOL_RDS 276
#define SOL_IUCV 277
#define SOL_CAIF 278
#define SOL_ALG 279
#define SOL_IP 0
/* #define SOL_ICMP 1 No-no-no! We cannot use SOL_ICMP=1 */
#define SOL_TCP 6
#define SOL_UDP 17
#define SOL_IPV6 41
#define SOL_ICMPV6 58
#define SOL_SCTP 132
#define SOL_UDPLITE 136 /* UDP-Lite (RFC 3828) */
#define SOL_RAW 255
#define SOL_IPX 256
#define SOL_AX25 257
#define SOL_ATALK 258
#define SOL_NETROM 259
#define SOL_ROSE 260
#define SOL_DECNET 261
#define SOL_X25 262
#define SOL_PACKET 263
#define SOL_ATM 264 /* ATM layer (cell level) */
#define SOL_AAL 265 /* ATM Adaption Layer (packet level) */
#define SOL_IRDA 266
#define SOL_NETBEUI 267
#define SOL_LLC 268
#define SOL_DCCP 269
#define SOL_NETLINK 270
#define SOL_TIPC 271
#define SOL_RXRPC 272
#define SOL_PPPOL2TP 273
#define SOL_BLUETOOTH 274
#define SOL_PNPIPE 275
#define SOL_RDS 276
#define SOL_IUCV 277
#define SOL_CAIF 278
#define SOL_ALG 279
/* end copy from linux/socket.h */
......@@ -117,40 +117,40 @@ struct bare_packet_mreq {
unsigned char mr_address[8];
};
#define PACKET_MR_MULTICAST 0
#define PACKET_MR_PROMISC 1
#define PACKET_MR_ALLMULTI 2
#define PACKET_MR_UNICAST 3
#define PACKET_MR_MULTICAST 0
#define PACKET_MR_PROMISC 1
#define PACKET_MR_ALLMULTI 2
#define PACKET_MR_UNICAST 3
/* Packet types */
#define PACKET_HOST 0 /* To us */
#define PACKET_BROADCAST 1 /* To all */
#define PACKET_MULTICAST 2 /* To group */
#define PACKET_OTHERHOST 3 /* To someone else */
#define PACKET_OUTGOING 4 /* Outgoing of any type */
#define PACKET_HOST 0 /* To us */
#define PACKET_BROADCAST 1 /* To all */
#define PACKET_MULTICAST 2 /* To group */
#define PACKET_OTHERHOST 3 /* To someone else */
#define PACKET_OUTGOING 4 /* Outgoing of any type */
/* These ones are invisible by user level */
#define PACKET_LOOPBACK 5 /* MC/BRD frame looped back */
#define PACKET_FASTROUTE 6 /* Fastrouted frame */
#define PACKET_LOOPBACK 5 /* MC/BRD frame looped back */
#define PACKET_FASTROUTE 6 /* Fastrouted frame */
/* Packet socket options */
#define PACKET_ADD_MEMBERSHIP 1
#define PACKET_DROP_MEMBERSHIP 2
#define PACKET_RECV_OUTPUT 3
#define PACKET_ADD_MEMBERSHIP 1
#define PACKET_DROP_MEMBERSHIP 2
#define PACKET_RECV_OUTPUT 3
/* Value 4 is still used by obsolete turbo-packet. */
#define PACKET_RX_RING 5
#define PACKET_STATISTICS 6
#define PACKET_COPY_THRESH 7
#define PACKET_AUXDATA 8
#define PACKET_ORIGDEV 9
#define PACKET_VERSION 10
#define PACKET_HDRLEN 11
#define PACKET_RESERVE 12
#define PACKET_TX_RING 13
#define PACKET_LOSS 14
#define PACKET_VNET_HDR 15
#define PACKET_TX_TIMESTAMP 16
#define PACKET_TIMESTAMP 17
#define PACKET_FANOUT 18
#define PACKET_RX_RING 5
#define PACKET_STATISTICS 6
#define PACKET_COPY_THRESH 7
#define PACKET_AUXDATA 8
#define PACKET_ORIGDEV 9
#define PACKET_VERSION 10
#define PACKET_HDRLEN 11
#define PACKET_RESERVE 12
#define PACKET_TX_RING 13
#define PACKET_LOSS 14
#define PACKET_VNET_HDR 15
#define PACKET_TX_TIMESTAMP 16
#define PACKET_TIMESTAMP 17
#define PACKET_FANOUT 18
/* end copy from linux/if_packet.h */
......@@ -221,14 +221,14 @@ struct bare_timex {
struct bare_timeval time; /* (RO, except for ADJ_SETOFFSET) */
long tick; /* (modified) usecs between clock ticks */
long ppsfreq; /* pps frequency (scaled ppm) (ro) */
long jitter; /* pps jitter (us) (ro) */
int shift; /* interval duration (s) (shift) (ro) */
long stabil; /* pps stability (scaled ppm) (ro) */
long jitcnt; /* jitter limit exceeded (ro) */
long calcnt; /* calibration intervals (ro) */
long errcnt; /* calibration errors (ro) */
long stbcnt; /* stability limit exceeded (ro) */
long ppsfreq; /* pps frequency (scaled ppm) (ro) */
long jitter; /* pps jitter (us) (ro) */
int shift; /* interval duration (s) (shift) (ro) */
long stabil; /* pps stability (scaled ppm) (ro) */
long jitcnt; /* jitter limit exceeded (ro) */
long calcnt; /* calibration intervals (ro) */
long errcnt; /* calibration errors (ro) */
long stbcnt; /* stability limit exceeded (ro) */
int tai; /* TAI offset (ro) */
......
......@@ -5,7 +5,7 @@
/* Socket interface for bare Linux */
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-x86-64.h"
#include "bare-linux.h"
/* 14 is ppi->proto_ofst for ethernet mode */
Octet buffer_out[PP_PACKET_SIZE + 14];
......
......@@ -8,7 +8,7 @@
*/
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-i386.h"
#include "bare-linux.h"
void ppsi_clear_bss(void)
......
......@@ -3,7 +3,7 @@
*/
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-i386.h"
#include "bare-linux.h"
static int bare_time_get(TimeInternal *t)
{
......
......@@ -7,7 +7,7 @@
* This is the main loop for "freestanding" stuff under Linux.
*/
#include <ppsi/ppsi.h>
#include "bare-x86-64.h"
#include "bare-linux.h"
/* Define other hackish stuff */
struct bare_fd_set {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment