123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #ifndef ANTIPHON_SOURCE
- #define ANTIPHON_SOURCE
- #include <memory.h>
- #include <errno.h>
- #include "../tools/error.h"
- #include "../tools/flags.h"
- #include "../plc/plc.h"
- signed Antiphon (struct plc * plc, byte source [], byte target [])
- {
- struct channel * channel = (struct channel *)(plc->channel);
- struct message * message = (struct message *)(plc->message);
- #ifndef __GNUC__
- #pragma pack (push,1)
- #endif
- struct __packed vs_fr_lbk_request
- {
- struct ethernet_hdr ethernet;
- struct qualcomm_hdr qualcomm;
- uint8_t DURATION;
- uint8_t RESERVED;
- uint16_t LENGTH;
- uint8_t PACKET [1038];
- }
- * request = (struct vs_fr_lbk_request *) (message);
- #ifndef __GNUC__
- #pragma pack (pop)
- #endif
- if (_allclr (plc->flags, PLC_SILENCE))
- {
- char sourcename [ETHER_ADDR_LEN * 3];
- char targetname [ETHER_ADDR_LEN * 3];
- hexdecode (source, ETHER_ADDR_LEN, sourcename, sizeof (sourcename));
- hexdecode (target, ETHER_ADDR_LEN, targetname, sizeof (targetname));
- fprintf (stderr, "%s %s %s\n", channel->ifname, sourcename, targetname);
- }
- memset (message, 0, sizeof (* message));
- EthernetHeader (&request->ethernet, source, target, channel->type);
- QualcommHeader (&request->qualcomm, 0, 41036);
- request->DURATION = plc->timer;
- request->LENGTH = HTOLE16 (sizeof (request->PACKET));
- memset (request->PACKET, 0xA5, sizeof (request->PACKET));
- EthernetHeader (request->PACKET, target, source, ETHERTYPE_IP);
- plc->packetsize = sizeof (* request);
- if (SendMME (plc) <= 0)
- {
- error (1, errno, CHANNEL_CANTSEND);
- }
- #if 0
- if (ReadMME (plc, 0, 41037) <= 0)
- {
- error (1, errno, CHANNEL_CANTREAD);
- }
- #endif
- sleep (plc->timer);
- return (0);
- }
- #endif
|