Commit ef11b762 authored by Alessandro Rubini's avatar Alessandro Rubini

overall: use network operations

Instead of having several external functions for networking, only
have one symbol: the structure of network operations. This simplifies
stuff a while, and allows more static symbols and better encapsulation.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 40eb407a
...@@ -5,12 +5,6 @@ ...@@ -5,12 +5,6 @@
/* /*
* These are the functions provided by the various bare files * These are the functions provided by the various bare files
*/ */
extern int bare_open_ch(struct pp_instance *ppi, char *name);
extern int bare_recv_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t);
extern int bare_send_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr);
extern void bare_main_loop(struct pp_instance *ppi); extern void bare_main_loop(struct pp_instance *ppi);
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
Octet buffer_out[PP_PACKET_SIZE + 14]; Octet buffer_out[PP_PACKET_SIZE + 14];
/* FIXME: which socket we receive and send with? */ /* FIXME: which socket we receive and send with? */
int bare_recv_packet(struct pp_instance *ppi, void *pkt, int len, static int bare_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t) TimeInternal *t)
{ {
if (t) if (t)
pp_get_tstamp(t); pp_get_tstamp(t);
...@@ -21,8 +21,8 @@ int bare_recv_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -21,8 +21,8 @@ int bare_recv_packet(struct pp_instance *ppi, void *pkt, int len,
pkt - NP(ppi)->proto_ofst, len, 0); pkt - NP(ppi)->proto_ofst, len, 0);
} }
int bare_send_packet(struct pp_instance *ppi, void *pkt, int len, static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr) TimeInternal *t, int chtype, int use_pdelay_addr)
{ {
struct bare_ethhdr *hdr; struct bare_ethhdr *hdr;
hdr = PROTO_HDR(pkt); hdr = PROTO_HDR(pkt);
...@@ -43,12 +43,6 @@ int bare_send_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -43,12 +43,6 @@ int bare_send_packet(struct pp_instance *ppi, void *pkt, int len,
len + NP(ppi)->proto_ofst, 0); len + NP(ppi)->proto_ofst, 0);
} }
int pp_recv_packet(struct pp_instance *ppi, void *pkt, int len, TimeInternal *t)
__attribute__((alias("bare_recv_packet")));
int pp_send_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr)
__attribute__((alias("bare_send_packet")));
#define SHUT_RD 0 #define SHUT_RD 0
#define SHUT_WR 1 #define SHUT_WR 1
#define SHUT_RDWR 2 #define SHUT_RDWR 2
...@@ -57,7 +51,7 @@ int pp_send_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -57,7 +51,7 @@ int pp_send_packet(struct pp_instance *ppi, void *pkt, int len,
#define SOCK_RAW 3 #define SOCK_RAW 3
/* To open a channel we must bind to an interface and so on */ /* To open a channel we must bind to an interface and so on */
int bare_open_ch(struct pp_instance *ppi, char *ifname) static int bare_open_ch(struct pp_instance *ppi, char *ifname)
{ {
int sock = -1; int sock = -1;
int temp, iindex; int temp, iindex;
...@@ -137,7 +131,7 @@ int bare_open_ch(struct pp_instance *ppi, char *ifname) ...@@ -137,7 +131,7 @@ int bare_open_ch(struct pp_instance *ppi, char *ifname)
return -1; return -1;
} }
int bare_net_init(struct pp_instance *ppi) static int bare_net_init(struct pp_instance *ppi)
{ {
ppi->buf_out = buffer_out; ppi->buf_out = buffer_out;
ppi->buf_out = PROTO_PAYLOAD(ppi->buf_out); ppi->buf_out = PROTO_PAYLOAD(ppi->buf_out);
...@@ -154,12 +148,16 @@ int bare_net_init(struct pp_instance *ppi) ...@@ -154,12 +148,16 @@ int bare_net_init(struct pp_instance *ppi)
return 0; return 0;
} }
int pp_net_init(struct pp_instance *ppi)
__attribute__((alias("bare_net_init")));
int bare_net_shutdown(struct pp_instance *ppi)
static int bare_net_exit(struct pp_instance *ppi)
{ {
return sys_shutdown(NP(ppi)->ch[PP_NP_GEN].fd, SHUT_RDWR); return sys_shutdown(NP(ppi)->ch[PP_NP_GEN].fd, SHUT_RDWR);
} }
int pp_net_shutdown(struct pp_instance *ppi)
__attribute__((alias("bare_net_shutdown"))); struct pp_network_operations pp_net_ops = {
.init = bare_net_init,
.exit = bare_net_exit,
.recv = bare_net_recv,
.send = bare_net_send,
};
...@@ -51,15 +51,11 @@ void ppsi_main(void) ...@@ -51,15 +51,11 @@ void ppsi_main(void)
ppi->frgn_master = &frgn_master; ppi->frgn_master = &frgn_master;
ppi->arch_data = NULL; ppi->arch_data = NULL;
#if 0 /* This just llocates the stuff */
if (bare_open_ch(ppi, "eth0")) {
pp_diag_error(ppi, bare_errno);
pp_diag_fatal(ppi, "open_ch", "");
}
#endif
pp_open_instance(ppi, NULL); pp_open_instance(ppi, NULL);
OPTS(ppi)->iface_name = "eth0"; OPTS(ppi)->iface_name = "eth0";
/* The actual sockets are opened in state-initializing */
bare_main_loop(ppi); bare_main_loop(ppi);
} }
...@@ -66,8 +66,8 @@ void bare_main_loop(struct pp_instance *ppi) ...@@ -66,8 +66,8 @@ void bare_main_loop(struct pp_instance *ppi)
* *
* FIXME: we don't know which socket to receive from * FIXME: we don't know which socket to receive from
*/ */
i = bare_recv_packet(ppi, payload, sizeof(packet), i = pp_net_ops.recv(ppi, payload, sizeof(packet),
&ppi->last_rcv_time); &ppi->last_rcv_time);
ppi->last_rcv_time.seconds += DSPRO(ppi)->currentUtcOffset; ppi->last_rcv_time.seconds += DSPRO(ppi)->currentUtcOffset;
/* we passed payload but it filled the ether header too */ /* we passed payload but it filled the ether header too */
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
Octet buffer_out[PP_PACKET_SIZE + 14]; Octet buffer_out[PP_PACKET_SIZE + 14];
/* FIXME: which socket we receive and send with? */ /* FIXME: which socket we receive and send with? */
int bare_recv_packet(struct pp_instance *ppi, void *pkt, int len, static int bare_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t) TimeInternal *t)
{ {
if (t) if (t)
pp_get_tstamp(t); pp_get_tstamp(t);
...@@ -21,8 +21,8 @@ int bare_recv_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -21,8 +21,8 @@ int bare_recv_packet(struct pp_instance *ppi, void *pkt, int len,
pkt - NP(ppi)->proto_ofst, len, 0); pkt - NP(ppi)->proto_ofst, len, 0);
} }
int bare_send_packet(struct pp_instance *ppi, void *pkt, int len, static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr) TimeInternal *t, int chtype, int use_pdelay_addr)
{ {
struct bare_ethhdr *hdr; struct bare_ethhdr *hdr;
hdr = PROTO_HDR(pkt); hdr = PROTO_HDR(pkt);
...@@ -43,12 +43,6 @@ int bare_send_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -43,12 +43,6 @@ int bare_send_packet(struct pp_instance *ppi, void *pkt, int len,
len + NP(ppi)->proto_ofst, 0); len + NP(ppi)->proto_ofst, 0);
} }
int pp_recv_packet(struct pp_instance *ppi, void *pkt, int len, TimeInternal *t)
__attribute__((alias("bare_recv_packet")));
int pp_send_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr)
__attribute__((alias("bare_send_packet")));
#define SHUT_RD 0 #define SHUT_RD 0
#define SHUT_WR 1 #define SHUT_WR 1
#define SHUT_RDWR 2 #define SHUT_RDWR 2
...@@ -57,7 +51,7 @@ int pp_send_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -57,7 +51,7 @@ int pp_send_packet(struct pp_instance *ppi, void *pkt, int len,
#define SOCK_RAW 3 #define SOCK_RAW 3
/* To open a channel we must bind to an interface and so on */ /* To open a channel we must bind to an interface and so on */
int bare_open_ch(struct pp_instance *ppi, char *ifname) static int bare_open_ch(struct pp_instance *ppi, char *ifname)
{ {
int sock = -1; int sock = -1;
int temp, iindex; int temp, iindex;
...@@ -137,7 +131,7 @@ int bare_open_ch(struct pp_instance *ppi, char *ifname) ...@@ -137,7 +131,7 @@ int bare_open_ch(struct pp_instance *ppi, char *ifname)
return -1; return -1;
} }
int bare_net_init(struct pp_instance *ppi) static int bare_net_init(struct pp_instance *ppi)
{ {
ppi->buf_out = buffer_out; ppi->buf_out = buffer_out;
ppi->buf_out = PROTO_PAYLOAD(ppi->buf_out); ppi->buf_out = PROTO_PAYLOAD(ppi->buf_out);
...@@ -154,12 +148,15 @@ int bare_net_init(struct pp_instance *ppi) ...@@ -154,12 +148,15 @@ int bare_net_init(struct pp_instance *ppi)
return 0; return 0;
} }
int pp_net_init(struct pp_instance *ppi)
__attribute__((alias("bare_net_init")));
int bare_net_shutdown(struct pp_instance *ppi) static int bare_net_exit(struct pp_instance *ppi)
{ {
return sys_shutdown(NP(ppi)->ch[PP_NP_GEN].fd, SHUT_RDWR); return sys_shutdown(NP(ppi)->ch[PP_NP_GEN].fd, SHUT_RDWR);
} }
int pp_net_shutdown(struct pp_instance *ppi)
__attribute__((alias("bare_net_shutdown"))); struct pp_network_operations pp_net_ops = {
.init = bare_net_init,
.exit = bare_net_exit,
.recv = bare_net_recv,
.send = bare_net_send,
};
...@@ -50,15 +50,12 @@ void ppsi_main(void) ...@@ -50,15 +50,12 @@ void ppsi_main(void)
ppi->servo = &servo; ppi->servo = &servo;
ppi->frgn_master = &frgn_master; ppi->frgn_master = &frgn_master;
ppi->arch_data = NULL; ppi->arch_data = NULL;
#if 0
if (bare_open_ch(ppi, "eth0")) { /* This just llocates the stuff */
pp_diag_error(ppi, bare_errno);
pp_diag_fatal(ppi, "open_ch", "");
}
#endif
pp_open_instance(ppi, NULL); pp_open_instance(ppi, NULL);
OPTS(ppi)->iface_name = "eth0"; OPTS(ppi)->iface_name = "eth0";
/* The actual sockets are opened in state-initializing */
bare_main_loop(ppi); bare_main_loop(ppi);
} }
...@@ -6,13 +6,6 @@ ...@@ -6,13 +6,6 @@
/* /*
* These are the functions provided by the various bare files * These are the functions provided by the various bare files
*/ */
extern int bare_open_ch(struct pp_instance *ppi, char *name);
extern int bare_recv_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t);
extern int bare_send_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr);
extern void bare_main_loop(struct pp_instance *ppi); extern void bare_main_loop(struct pp_instance *ppi);
/* syscalls */ /* syscalls */
......
...@@ -66,8 +66,8 @@ void bare_main_loop(struct pp_instance *ppi) ...@@ -66,8 +66,8 @@ void bare_main_loop(struct pp_instance *ppi)
* *
* FIXME: we don't know which socket to receive from * FIXME: we don't know which socket to receive from
*/ */
i = bare_recv_packet(ppi, payload, sizeof(packet) - 16, i = pp_net_ops.recv(ppi, payload, sizeof(packet) - 16,
&ppi->last_rcv_time); &ppi->last_rcv_time);
ppi->last_rcv_time.seconds += DSPRO(ppi)->currentUtcOffset; ppi->last_rcv_time.seconds += DSPRO(ppi)->currentUtcOffset;
/* we passed payload but it filled the ether header too */ /* we passed payload but it filled the ether header too */
......
...@@ -50,7 +50,7 @@ void posix_main_loop(struct pp_instance *ppi) ...@@ -50,7 +50,7 @@ void posix_main_loop(struct pp_instance *ppi)
* We got a packet. If it's not ours, continue consuming * We got a packet. If it's not ours, continue consuming
* the pending timeout * the pending timeout
*/ */
i = posix_recv_packet(ppi, payload, sizeof(packet) - 16, i = pp_net_ops.recv(ppi, payload, sizeof(packet) - 16,
&ppi->last_rcv_time); &ppi->last_rcv_time);
ppi->last_rcv_time.seconds += DSPRO(ppi)->currentUtcOffset; ppi->last_rcv_time.seconds += DSPRO(ppi)->currentUtcOffset;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "posix.h" #include "posix.h"
/* posix_recv_msg uses recvmsg for timestamp query */ /* posix_recv_msg uses recvmsg for timestamp query */
int posix_recv_msg(int fd, void *pkt, int len, TimeInternal *t) static int posix_recv_msg(int fd, void *pkt, int len, TimeInternal *t)
{ {
ssize_t ret; ssize_t ret;
struct msghdr msg; struct msghdr msg;
...@@ -89,8 +89,8 @@ int posix_recv_msg(int fd, void *pkt, int len, TimeInternal *t) ...@@ -89,8 +89,8 @@ int posix_recv_msg(int fd, void *pkt, int len, TimeInternal *t)
} }
/* Receive and send is *not* so trivial */ /* Receive and send is *not* so trivial */
int posix_recv_packet(struct pp_instance *ppi, void *pkt, int len, static int posix_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t) TimeInternal *t)
{ {
struct pp_channel *ch1 = NULL, *ch2 = NULL; struct pp_channel *ch1 = NULL, *ch2 = NULL;
void *hdr; void *hdr;
...@@ -124,8 +124,8 @@ int posix_recv_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -124,8 +124,8 @@ int posix_recv_packet(struct pp_instance *ppi, void *pkt, int len,
return -1; return -1;
} }
int posix_send_packet(struct pp_instance *ppi, void *pkt, int len, static int posix_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr) TimeInternal *t, int chtype, int use_pdelay_addr)
{ {
struct sockaddr_in addr; struct sockaddr_in addr;
struct ethhdr *hdr; struct ethhdr *hdr;
...@@ -163,14 +163,8 @@ int posix_send_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -163,14 +163,8 @@ int posix_send_packet(struct pp_instance *ppi, void *pkt, int len,
return -1; return -1;
} }
int pp_recv_packet(struct pp_instance *ppi, void *pkt, int len, TimeInternal *t)
__attribute__((alias("posix_recv_packet")));
int pp_send_packet(struct pp_instance *ppi, void *pkt, int len, TimeInternal *t,
int chtype, int use_pdelay_addr)
__attribute__((alias("posix_send_packet")));
/* To open a channel we must bind to an interface and so on */ /* To open a channel we must bind to an interface and so on */
int posix_open_ch(struct pp_instance *ppi, char *ifname, int chtype) static int posix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
{ {
int sock = -1; int sock = -1;
...@@ -409,14 +403,10 @@ int posix_net_init(struct pp_instance *ppi) ...@@ -409,14 +403,10 @@ int posix_net_init(struct pp_instance *ppi)
return 0; return 0;
} }
int pp_net_init(struct pp_instance *ppi)
__attribute__((alias("posix_net_init")));
/* /*
* Shutdown all the network stuff * Shutdown all the network stuff
*/ */
int posix_net_shutdown(struct pp_instance *ppi) static int posix_net_exit(struct pp_instance *ppi)
{ {
struct ip_mreq imr; struct ip_mreq imr;
int fd; int fd;
...@@ -527,5 +517,9 @@ int posix_net_check_pkt(struct pp_instance *ppi, int delay_ms) ...@@ -527,5 +517,9 @@ int posix_net_check_pkt(struct pp_instance *ppi, int delay_ms)
return ret; return ret;
} }
int pp_net_shutdown(struct pp_instance *ppi) struct pp_network_operations pp_net_ops = {
__attribute__((alias("posix_net_shutdown"))); .init = posix_net_init,
.exit = posix_net_exit,
.recv = posix_net_recv,
.send = posix_net_send,
};
...@@ -12,14 +12,6 @@ struct posix_arch_data { ...@@ -12,14 +12,6 @@ struct posix_arch_data {
int rcv_switch; /* flag for event / general receive order */ int rcv_switch; /* flag for event / general receive order */
}; };
extern int posix_net_init(struct pp_instance *ppi);
extern int posix_net_check_pkt(struct pp_instance *ppi, int delay_ms); extern int posix_net_check_pkt(struct pp_instance *ppi, int delay_ms);
extern int posix_open_ch(struct pp_instance *ppi, char *name, int chtype);
extern int posix_recv_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t);
extern int posix_send_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr);
extern void posix_main_loop(struct pp_instance *ppi); extern void posix_main_loop(struct pp_instance *ppi);
...@@ -15,7 +15,7 @@ int wrpc_errno; ...@@ -15,7 +15,7 @@ int wrpc_errno;
Octet buffer_out[PP_PACKET_SIZE + 14]; /* 14 == ppi->proto_ofst for eth mode */ Octet buffer_out[PP_PACKET_SIZE + 14]; /* 14 == ppi->proto_ofst for eth mode */
/* This function should init the minic and get the mac address */ /* This function should init the minic and get the mac address */
int wrpc_open_ch(struct pp_instance *ppi) static int wrpc_open_ch(struct pp_instance *ppi)
{ {
wr_socket_t *sock; wr_socket_t *sock;
mac_addr_t mac; mac_addr_t mac;
...@@ -39,8 +39,8 @@ int wrpc_open_ch(struct pp_instance *ppi) ...@@ -39,8 +39,8 @@ int wrpc_open_ch(struct pp_instance *ppi)
} }
/* To receive and send packets, we call the minic low-level stuff */ /* To receive and send packets, we call the minic low-level stuff */
int wrpc_recv_packet(struct pp_instance *ppi, void *pkt, int len, static int wrpc_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t) TimeInternal *t)
{ {
int got; int got;
wr_socket_t *sock; wr_socket_t *sock;
...@@ -63,8 +63,8 @@ int wrpc_recv_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -63,8 +63,8 @@ int wrpc_recv_packet(struct pp_instance *ppi, void *pkt, int len,
return got; return got;
} }
int wrpc_send_packet(struct pp_instance *ppi, void *pkt, int len, static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr) TimeInternal *t, int chtype, int use_pdelay_addr)
{ {
int snt; int snt;
wr_socket_t *sock; wr_socket_t *sock;
...@@ -101,7 +101,7 @@ int wrpc_send_packet(struct pp_instance *ppi, void *pkt, int len, ...@@ -101,7 +101,7 @@ int wrpc_send_packet(struct pp_instance *ppi, void *pkt, int len,
return snt; return snt;
} }
int wrpc_net_init(struct pp_instance *ppi) static int wrpc_net_init(struct pp_instance *ppi)
{ {
ppi->buf_out = buffer_out; ppi->buf_out = buffer_out;
ppi->buf_out = PROTO_PAYLOAD(ppi->buf_out); ppi->buf_out = PROTO_PAYLOAD(ppi->buf_out);
...@@ -113,19 +113,16 @@ int wrpc_net_init(struct pp_instance *ppi) ...@@ -113,19 +113,16 @@ int wrpc_net_init(struct pp_instance *ppi)
} }
int wrpc_net_shutdown(struct pp_instance *ppi) static int wrpc_net_exit(struct pp_instance *ppi)
{ {
ptpd_netif_close_socket( ptpd_netif_close_socket(
(wr_socket_t *)NP(ppi)->ch[PP_NP_EVT].custom); (wr_socket_t *)NP(ppi)->ch[PP_NP_EVT].custom);
return 0; return 0;
} }
int pp_net_init(struct pp_instance *ppi) struct pp_network_operations pp_net_ops = {
__attribute__((alias("wrpc_net_init"))); .init = wrpc_net_init,
int pp_net_shutdown(struct pp_instance *ppi) .exit = wrpc_net_exit,
__attribute__((alias("wrpc_net_shutdown"))); .recv = wrpc_net_recv,
int pp_recv_packet(struct pp_instance *ppi, void *pkt, int len, TimeInternal *t) .send = wrpc_net_send,
__attribute__((alias("wrpc_recv_packet"))); };
int pp_send_packet(struct pp_instance *ppi, void *pkt, int len, TimeInternal *t,
int chtype, int use_pdelay_addr)
__attribute__((alias("wrpc_send_packet")));
...@@ -11,13 +11,6 @@ ...@@ -11,13 +11,6 @@
/* /*
* These are the functions provided by the various bare files * These are the functions provided by the various bare files
*/ */
extern int wrpc_open_ch(struct pp_instance *ppi);
extern int wrpc_recv_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t);
extern int wrpc_send_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr);
extern void wrpc_main_loop(struct pp_instance *ppi); extern void wrpc_main_loop(struct pp_instance *ppi);
extern void _irq_entry(void); /* unused, to make crt0.S happy */ extern void _irq_entry(void); /* unused, to make crt0.S happy */
extern int main(void); /* alias to ppsi_main, so crt0.S is happy */ extern int main(void); /* alias to ppsi_main, so crt0.S is happy */
......
...@@ -327,6 +327,23 @@ struct pp_ext_hooks { ...@@ -327,6 +327,23 @@ struct pp_ext_hooks {
extern struct pp_ext_hooks pp_hooks; /* The one for the extension we build */ extern struct pp_ext_hooks pp_hooks; /* The one for the extension we build */
/*
* Network methods are encapsulated in a structure, so each arch only needs
* to provide that structure. This should simplify management overall.
*/
struct pp_network_operations {
int (*init)(struct pp_instance *ppi);
int (*exit)(struct pp_instance *ppi);
int (*recv)(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t);
/* chtype here is PP_NP_GEN or PP_NP_EVT */
int (*send)(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr);
};
extern struct pp_network_operations pp_net_ops;
/* The channel for an instance must be created and possibly destroyed. */ /* The channel for an instance must be created and possibly destroyed. */
extern int pp_open_instance(struct pp_instance *ppi, extern int pp_open_instance(struct pp_instance *ppi,
struct pp_runtime_opts *rt_opts); struct pp_runtime_opts *rt_opts);
...@@ -335,15 +352,6 @@ extern int pp_close_instance(struct pp_instance *ppi); ...@@ -335,15 +352,6 @@ extern int pp_close_instance(struct pp_instance *ppi);
extern int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv); extern int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv);
/* Network stuff */
extern int pp_net_init(struct pp_instance *ppi);
extern int pp_net_shutdown(struct pp_instance *ppi);
extern int pp_recv_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t);
extern int pp_send_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr);
/* chtype: PP_NP_GEN || PP_NP_EVT */
/* Timers */ /* Timers */
extern int pp_timer_init(struct pp_instance *ppi); /* initializes timer common extern int pp_timer_init(struct pp_instance *ppi); /* initializes timer common
structure */ structure */
......
...@@ -41,7 +41,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf, ...@@ -41,7 +41,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf,
#ifdef VERB_LOG_MSGS #ifdef VERB_LOG_MSGS
#define MSG_SEND_AND_RET_VARLEN(x, y, z, w) \ #define MSG_SEND_AND_RET_VARLEN(x, y, z, w) \
if (pp_send_packet(ppi, ppi->buf_out, w,\ if (pp_net_ops.send(ppi, ppi->buf_out, w,\
&ppi->last_snt_time, PP_NP_##y , z) < w) { \ &ppi->last_snt_time, PP_NP_##y , z) < w) { \
PP_PRINTF("%s(%d) Message can't be sent -> FAULTY state!\n", \ PP_PRINTF("%s(%d) Message can't be sent -> FAULTY state!\n", \
pp_msg_names[PPM_##x], PPM_##x); \ pp_msg_names[PPM_##x], PPM_##x); \
...@@ -54,7 +54,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf, ...@@ -54,7 +54,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf,
return 0; return 0;
#else #else
#define MSG_SEND_AND_RET_VARLEN(x, y, z, w) \ #define MSG_SEND_AND_RET_VARLEN(x, y, z, w) \
if (pp_send_packet(ppi, ppi->buf_out, w, \ if (pp_net_ops.send(ppi, ppi->buf_out, w, \
&ppi->last_snt_time, PP_NP_##y , z) < w) { \ &ppi->last_snt_time, PP_NP_##y , z) < w) { \
return -1; \ return -1; \
} \ } \
......
...@@ -19,9 +19,9 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -19,9 +19,9 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
int ret = 0; int ret = 0;
if (NP(ppi)->inited) if (NP(ppi)->inited)
pp_net_shutdown(ppi); pp_net_ops.exit(ppi);
if (pp_net_init(ppi) < 0) if (pp_net_ops.init(ppi) < 0)
goto failure; goto failure;
NP(ppi)->inited = 1; NP(ppi)->inited = 1;
......
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