Skip to content

Commit

Permalink
Avoid hidden overloaded virtual functions
Browse files Browse the repository at this point in the history
Since the functions were hidden for the comiler, I specified every
function that was being hidden in the IPv*Header.h header files.
This allows us to use both overloaded functions and the original one
instead of having one being hidden by the others.
Here is the compiler warning output before the fix:

warning: 'file::function' hides overloaded virtual function
note: hidden overloaded virtual function 'file2::function' declared
here: different qualifiers
  • Loading branch information
vincent committed Jul 1, 2016
1 parent 900f015 commit 9703fea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions libnetutil/IPv4Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class IPv4Header : public NetworkLayerElement {
u8 getNextProto() const;
int setNextHeader(u8 val);
u8 getNextHeader() const;
virtual u8 getNextHeader(){return 0;}

/* Checksum */
int setSum();
Expand All @@ -261,16 +262,18 @@ class IPv4Header : public NetworkLayerElement {
int setDestinationAddress(struct in_addr d);
const u8 *getDestinationAddress() const;
struct in_addr getDestinationAddress(struct in_addr *result) const;

virtual u8 *getDestinationAddress(){return NULL;}

/* Source IP */
int setSourceAddress(u32 d);
int setSourceAddress(struct in_addr d);
const u8 *getSourceAddress() const;
struct in_addr getSourceAddress(struct in_addr *result) const;
virtual u8 *getSourceAddress(){return NULL;}

u16 getAddressLength() const;

virtual u16 getAddressLength(){return 0;}

/* IP Options */
int setOpts(const char *txt);
int setOpts(u8 *opts_buff, u32 opts_len);
Expand Down
8 changes: 6 additions & 2 deletions libnetutil/IPv6Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ class IPv6Header : public NetworkLayerElement {
int setNextHeader(u8 val);
int setNextHeader(const char *p);
u8 getNextHeader() const;

virtual u8 getNextHeader(){return 0;}

/* Hop Limit */
int setHopLimit(u8 val);
u8 getHopLimit() const;
Expand All @@ -223,14 +224,17 @@ class IPv6Header : public NetworkLayerElement {
int setSourceAddress(struct in6_addr val);
const u8 *getSourceAddress() const;
struct in6_addr getSourceAddress(struct in6_addr *result) const;

virtual u8 *getSourceAddress(){return NULL;}

/* Destination Address*/
int setDestinationAddress(u8 *val);
int setDestinationAddress(struct in6_addr val);
const u8 *getDestinationAddress() const;
struct in6_addr getDestinationAddress(struct in6_addr *result) const;
virtual u8 *getDestinationAddress(){return NULL;}

u16 getAddressLength() const;
virtual u16 getAddressLength(){return 0;}
};

#endif

0 comments on commit 9703fea

Please sign in to comment.