Skip to content

Commit

Permalink
Remove MAC address parameter and read from interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
drmpeg committed Apr 21, 2021
1 parent f974bc8 commit a75faa6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
5 changes: 1 addition & 4 deletions grc/dvbgse_bbheader_source.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ parameters:
dtype: int
default: '4000000'
hide: ${ inband.hide_rate }
- id: mac_address
label: MAC Address
dtype: string
- id: ping_reply
label: Ping Reply
dtype: enum
Expand Down Expand Up @@ -169,7 +166,7 @@ templates:
\ \n% else:\n${rate2.val}, \n% endif\n% else:\n% if str(framesize2) == 'FECFRAME_NORMAL':\n\
${rate3.val}, \n% elif str(framesize2) == 'FECFRAME_MEDIUM':\n${rate4.val},\
\ \n% else:\n${rate5.val}, \n% endif\n% endif\n${rolloff.val}, ${inband.val},\
\ ${fecblocks}, ${tsrate}, ${mac_address}, ${ping_reply.val}, ${ipaddr_spoof.val},\
\ ${fecblocks}, ${tsrate}, ${ping_reply.val}, ${ipaddr_spoof.val},\
\ ${src_address}, ${dst_address})"

file_format: 1
2 changes: 1 addition & 1 deletion include/dvbgse/bbheader_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace gr {
* class. dvbgse::bbheader_source::make is the public interface for
* creating new instances.
*/
static sptr make(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, dvbs2_rolloff_factor_t rolloff, dvbt2_inband_t inband, int fecblocks, int tsrate, char *mac_address, dvbt2_ping_reply_t ping_reply, dvbt2_ipaddr_spoof_t ipaddr_spoof, char *src_address, char *dst_address);
static sptr make(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, dvbs2_rolloff_factor_t rolloff, dvbt2_inband_t inband, int fecblocks, int tsrate, dvbt2_ping_reply_t ping_reply, dvbt2_ipaddr_spoof_t ipaddr_spoof, char *src_address, char *dst_address);
};

} // namespace dvbgse
Expand Down
19 changes: 16 additions & 3 deletions lib/bbheader_source_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ namespace gr {
namespace dvbgse {

bbheader_source::sptr
bbheader_source::make(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, dvbs2_rolloff_factor_t rolloff, dvbt2_inband_t inband, int fecblocks, int tsrate, char *mac_address, dvbt2_ping_reply_t ping_reply, dvbt2_ipaddr_spoof_t ipaddr_spoof, char *src_address, char *dst_address)
bbheader_source::make(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, dvbs2_rolloff_factor_t rolloff, dvbt2_inband_t inband, int fecblocks, int tsrate, dvbt2_ping_reply_t ping_reply, dvbt2_ipaddr_spoof_t ipaddr_spoof, char *src_address, char *dst_address)
{
return gnuradio::get_initial_sptr
(new bbheader_source_impl(standard, framesize, rate, rolloff, inband, fecblocks, tsrate, mac_address, ping_reply, ipaddr_spoof, src_address, dst_address));
(new bbheader_source_impl(standard, framesize, rate, rolloff, inband, fecblocks, tsrate, ping_reply, ipaddr_spoof, src_address, dst_address));
}

/*
* The private constructor
*/
bbheader_source_impl::bbheader_source_impl(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, dvbs2_rolloff_factor_t rolloff, dvbt2_inband_t inband, int fecblocks, int tsrate, char *mac_address, dvbt2_ping_reply_t ping_reply, dvbt2_ipaddr_spoof_t ipaddr_spoof, char *src_address, char *dst_address)
bbheader_source_impl::bbheader_source_impl(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, dvbs2_rolloff_factor_t rolloff, dvbt2_inband_t inband, int fecblocks, int tsrate, dvbt2_ping_reply_t ping_reply, dvbt2_ipaddr_spoof_t ipaddr_spoof, char *src_address, char *dst_address)
: gr::sync_block("bbheader_source",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(1, 1, sizeof(unsigned char)))
Expand All @@ -54,6 +54,10 @@ namespace gr {
char filter[50];
struct ifreq ifr;
int err;
int fdmac;
struct ifreq ifrmac;
unsigned char *mac;
char mac_address[18];

count = 0;
crc = 0x0;
Expand Down Expand Up @@ -313,6 +317,15 @@ namespace gr {
throw std::runtime_error("Error calling ioctl()\n");
}

fdmac = socket(AF_INET, SOCK_DGRAM, 0);
ifrmac.ifr_addr.sa_family = AF_INET;
strncpy(ifrmac.ifr_name , DEFAULT_IF , IFNAMSIZ-1);
ioctl(fdmac, SIOCGIFHWADDR, &ifrmac);
close(fdmac);

mac = (unsigned char *)ifrmac.ifr_hwaddr.sa_data;
snprintf(mac_address, sizeof(mac_address), "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x" , mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

strcpy(dev, DEFAULT_IF);
descr = pcap_create(dev, errbuf);
if (descr == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion lib/bbheader_source_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace gr {
inline void dump_packet(unsigned char *);

public:
bbheader_source_impl(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, dvbs2_rolloff_factor_t rolloff, dvbt2_inband_t inband, int fecblocks, int tsrate, char *mac_address, dvbt2_ping_reply_t ping_reply, dvbt2_ipaddr_spoof_t ipaddr_spoof, char *src_address, char *dst_address);
bbheader_source_impl(dvb_standard_t standard, dvb_framesize_t framesize, dvb_code_rate_t rate, dvbs2_rolloff_factor_t rolloff, dvbt2_inband_t inband, int fecblocks, int tsrate, dvbt2_ping_reply_t ping_reply, dvbt2_ipaddr_spoof_t ipaddr_spoof, char *src_address, char *dst_address);
~bbheader_source_impl();

int work(int noutput_items,
Expand Down

0 comments on commit a75faa6

Please sign in to comment.