/[mac2eui64]/trunk/mac2eui64.c
ViewVC logotype

Diff of /trunk/mac2eui64.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

  Revision 4 by trond, 2015-09-29T08:31:02Z
vs.
  Revision 5 by trond, 2015-09-29T09:12:20Z
*** trunk/mac2eui64.c	2015/09/29 08:31:02	4
--- trunk/mac2eui64.c	2015/09/29 09:12:20	5
***************
*** 1,10 ****
  /*
   mac2eui64.c 
  
!  Conversion from the IEEE 802 MAC format to the IEEE EUI-64 format.
!  Displays values suitable for use as a 64 bit interface ID in A6 RRs.
!  Also displayed are labels suitable for use with PTR RRs in the
!  reverse zone ip6.arpa.
  
   Updated in 2015 to conform to ISO C 2011.
  
--- 1,10 ----
  /*
   mac2eui64.c 
  
!  Conversion from the IEEE 802 MAC format to the (modified) IEEE EUI-64 format.
!  Displays values suitable for use as a 64 bit interface ID in AAAA and A6 RRs.
!  Also displays labels suitable for use with PTR RRs in the reverse zone
!  ip6.arpa.
  
   Updated in 2015 to conform to ISO C 2011.
  
***************
*** 101,110 ****
  {
    printf("%s version 1.0\n\n"
  
!          "Conversion from the IEEE 802 MAC format to the IEEE EUI-64 format.\n"
!          "Displays values suitable for use as a 64 bit interface ID in A6 RRs.\n"
!          "Also displayed are labels suitable for use with PTR RRs in the\n"
!          "reverse zone ip6.arpa.\n\n"
  
           "Updated in 2015 to conform to ISO C 2011.\n\n"
  
--- 101,110 ----
  {
    printf("%s version 1.0\n\n"
  
!          "Conversion from the IEEE 802 MAC format to the (modified) IEEE EUI-64 format.\n"
!          "Displays values suitable for use as a 64 bit interface ID in AAAA and A6 RRs.\n"
!          "Also displays labels suitable for use with PTR RRs in the reverse zone\n"
!          "ip6.arpa.\n\n"
  
           "Updated in 2015 to conform to ISO C 2011.\n\n"
  
***************
*** 130,146 ****
  
  int ConstructMAC(const char *argvi, unsigned char *MAC);
  void ConstructEUI64(const unsigned char * const MAC, unsigned char * const EUI64);
! void InvertUniversalLocalBit(unsigned char * const EUI64);
  
  void PrintMAC(const unsigned char * const MAC);
  void PrintEUI64(const unsigned char * const EUI64);
  void PrintEUI64_InterfaceID(const unsigned char * const EUI64);
  void PrintEUI64_IP6_ARPA(const unsigned char * const EUI64);
  //void PrintEUI64_IP6_INT(const unsigned char * const EUI64);
  
  void TransformMAC(const char * const argv0, const char * const argvi)
  {
!   unsigned char MAC[6], EUI64[8];
  
    if (ConstructMAC(argvi, MAC)) {
      fprintf(stderr, "%s: invalid MAC address: %s\n", argv0, argvi);
--- 130,147 ----
  
  int ConstructMAC(const char *argvi, unsigned char *MAC);
  void ConstructEUI64(const unsigned char * const MAC, unsigned char * const EUI64);
! void ConstructModEUI64(const unsigned char * const EUI64, unsigned char * const ModEUI64);
  
  void PrintMAC(const unsigned char * const MAC);
  void PrintEUI64(const unsigned char * const EUI64);
+ void PrintModEUI64(const unsigned char * const EUI64);
  void PrintEUI64_InterfaceID(const unsigned char * const EUI64);
  void PrintEUI64_IP6_ARPA(const unsigned char * const EUI64);
  //void PrintEUI64_IP6_INT(const unsigned char * const EUI64);
  
  void TransformMAC(const char * const argv0, const char * const argvi)
  {
!   unsigned char MAC[6], EUI64[8], ModEUI64[8];
  
    if (ConstructMAC(argvi, MAC)) {
      fprintf(stderr, "%s: invalid MAC address: %s\n", argv0, argvi);
***************
*** 148,165 ****
      }
  
    ConstructEUI64(MAC, EUI64);
  
    PrintMAC(MAC);
    PrintEUI64(EUI64);
! 
!   /* Transform the EUI-64 address into
!      the Modified EUI-64 address for use as
!      the value for the interface ID */
!   InvertUniversalLocalBit(EUI64);
! 
!   PrintEUI64_InterfaceID(EUI64);
!   PrintEUI64_IP6_ARPA(EUI64);
!   //PrintEUI64_IP6_INT(EUI64);
  } /* TransformMAC() */
  
  int ConstructMAC(const char *argvi, unsigned char * MAC)
--- 149,162 ----
      }
  
    ConstructEUI64(MAC, EUI64);
+   ConstructModEUI64(EUI64, ModEUI64);
  
    PrintMAC(MAC);
    PrintEUI64(EUI64);
!   PrintModEUI64(ModEUI64);
!   PrintEUI64_InterfaceID(ModEUI64);
!   PrintEUI64_IP6_ARPA(ModEUI64);
!   //PrintEUI64_IP6_INT(ModEUI64);
  } /* TransformMAC() */
  
  int ConstructMAC(const char *argvi, unsigned char * MAC)
***************
*** 228,239 ****
    EUI64[1] = MAC[1];
    EUI64[2] = MAC[2];
    EUI64[3] = 0xFF;
!   EUI64[4] = 0xFE;
    EUI64[5] = MAC[3];
    EUI64[6] = MAC[4];
    EUI64[7] = MAC[5];
  } /* ConstructEUI64() */
  
  void InvertUniversalLocalBit(unsigned char * const EUI64)
  {
    if (EUI64[0] & 0x02)
--- 225,252 ----
    EUI64[1] = MAC[1];
    EUI64[2] = MAC[2];
    EUI64[3] = 0xFF;
!   EUI64[4] = 0xFF;
    EUI64[5] = MAC[3];
    EUI64[6] = MAC[4];
    EUI64[7] = MAC[5];
  } /* ConstructEUI64() */
  
+ void InvertUniversalLocalBit(unsigned char * const EUI64);
+ 
+ void ConstructModEUI64(const unsigned char * const EUI64, unsigned char * const ModEUI64)
+ {
+   ModEUI64[0] = EUI64[0];
+   ModEUI64[1] = EUI64[1];
+   ModEUI64[2] = EUI64[2];
+   ModEUI64[3] = EUI64[3];
+   ModEUI64[4] = 0xFE;
+   ModEUI64[5] = EUI64[5];
+   ModEUI64[6] = EUI64[6];
+   ModEUI64[7] = EUI64[7];
+ 
+   InvertUniversalLocalBit(ModEUI64);
+ } /* ConstructModEUI64() */
+ 
  void InvertUniversalLocalBit(unsigned char * const EUI64)
  {
    if (EUI64[0] & 0x02)
***************
*** 254,259 ****
--- 267,279 ----
           EUI64[0], EUI64[1], EUI64[2], EUI64[3],
           EUI64[4], EUI64[5], EUI64[6], EUI64[7]);
  } /* PrintEUI64() */
+ 
+ void PrintModEUI64(const unsigned char * const EUI64)
+ {
+   printf("Mod. EUI-64:\t%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
+          EUI64[0], EUI64[1], EUI64[2], EUI64[3],
+          EUI64[4], EUI64[5], EUI64[6], EUI64[7]);
+ } /* PrintModEUI64() */
  
  void PrintEUI64_InterfaceID(const unsigned char * const EUI64)
  {


 

svn@ximalas.info
ViewVC Help
Powered by ViewVC 1.3.0-beta1