Aucune description

ethernet_packet.cpp 823B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "ethernet_packet.h"
  2. // These are the function members you will implement in
  3. // Exercise 2. You must implement ALL of the functions
  4. // whose prototypes are in the ethernet_packet class declaration
  5. ethernet_packet::ethernet_packet() {
  6. }
  7. void ethernet_packet::setEtherDHost(u_char dhost[]){
  8. }
  9. void ethernet_packet::setEtherSHost(u_char shost[]){
  10. }
  11. void ethernet_packet::setEtherType(u_short type){
  12. ethernet.ether_type = type ;
  13. }
  14. string ethernet_packet::mac2string(u_char srcmac[]){
  15. u_char mac[18] ;
  16. sprintf((char *)mac, "%02X:%02X:%02X:%02X:%02X:%02X", srcmac[0],
  17. srcmac[1],srcmac[2],srcmac[3], srcmac[4],srcmac[5]) ;
  18. string macstr((char *) mac) ;
  19. return macstr ;
  20. }
  21. // We intentionally left out some of the function headers
  22. // so that you deduce them from the .h file.