36 #include <sys/types.h> 69 #define RX_PRIM priMAC[1] 71 #define RX_SEC secMAC[1] 123 InitializeCriticalSection(&(port->
tx_mutex));
124 InitializeCriticalSection(&(port->
rx_mutex));
144 printf(
"interface %s could not open with pcap\n", ifname);
169 DeleteCriticalSection(&(port->
tx_mutex));
170 DeleteCriticalSection(&(port->
rx_mutex));
192 bp->da0 = htons(0xffff);
193 bp->da1 = htons(0xffff);
194 bp->da2 = htons(0xffff);
195 bp->sa0 = htons(
priMAC[0]);
196 bp->sa1 = htons(
priMAC[1]);
197 bp->sa2 = htons(
priMAC[2]);
264 stack = &(port->
stack);
294 ehp->sa1 = htons(
priMAC[1]);
299 EnterCriticalSection( &(port->
tx_mutex) );
304 datagramP->index = idx;
306 ehp->sa1 = htons(
secMAC[1]);
313 LeaveCriticalSection( &(port->
tx_mutex) );
329 unsigned char const * pkt_data;
334 stack = &(port->
stack);
348 bytesrx = header->
len;
353 memcpy(*stack->
tempbuf, pkt_data, bytesrx);
355 return (bytesrx > 0);
386 stack = &(port->
stack);
393 rxbuf = &(*stack->
rxbuf)[idx];
397 l = (*rxbuf)[0] + ((
uint16)((*rxbuf)[1] & 0x0f) << 8);
399 rval = ((*rxbuf)[l] + ((
uint16)(*rxbuf)[l + 1] << 8));
405 EnterCriticalSection(&(port->
rx_mutex));
415 l =
etohs(ecp->elength) & 0x0fff;
423 rval = ((*rxbuf)[l] + ((
uint16)((*rxbuf)[l + 1]) << 8));
427 (*stack->
rxsa)[idx] = ntohs(ehp->sa1);
434 rxbuf = &(*stack->
rxbuf)[idxf];
439 (*stack->
rxsa)[idxf] = ntohs(ehp->sa1);
448 LeaveCriticalSection( &(port->
rx_mutex) );
512 if ( ((primrx == 0) && (secrx ==
RX_SEC)) ||
634 int ec_inframe(
int idx,
int stacknumber)
int ec_outframe(int idx, int sock)
int ecx_getindex(ecx_portt *port)
boolean osal_timer_is_expired(osal_timert *self)
void ec_setupheader(void *p)
int txbuflength[EC_MAXBUF]
int ec_setupnic(const char *ifname, int secondary)
static int ecx_recvpkt(ecx_portt *port, int stacknumber)
int ecx_outframe_red(ecx_portt *port, int idx)
static char errbuf[PCAP_ERRBUF_SIZE]
int(* txbuflength)[EC_MAXBUF]
PACKED_BEGIN struct PACKED ec_etherheadert
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary)
General typedefs and defines for EtherCAT.
static void ecx_clear_rxbufstat(int *rxbufstat)
ec_bufT(* rxbuf)[EC_MAXBUF]
int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **)
int ec_srconfirm(int idx, int timeout)
int ecx_outframe(ecx_portt *port, int idx, int stacknumber)
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
#define PCAP_OPENFLAG_PROMISCUOUS
Defines if the adapter has to go in promiscuous mode.
ec_bufT(* txbuf)[EC_MAXBUF]
void ec_setbufstat(int idx, int bufstat)
PACKED_BEGIN struct PACKED ec_comt
#define PCAP_OPENFLAG_MAX_RESPONSIVENESS
This flag configures the adapter for maximum responsiveness.
void pcap_close(pcap_t *)
static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
int pcap_sendpacket(pcap_t *, const u_char *, int)
pthread_mutex_t getindex_mutex
#define PCAP_OPENFLAG_NOCAPTURE_LOCAL
Defines if the local adapter will capture its own generated traffic.
int ec_outframe_red(int idx)
int ecx_closenic(ecx_portt *port)
uint8 ec_bufT[EC_BUFSIZE]
pcap_t * pcap_open(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf)
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
int ec_waitinframe(int idx, int timeout)
void osal_timer_start(osal_timert *self, uint32 timeout_usec)
int(* rxbufstat)[EC_MAXBUF]