master/module.c
changeset 758 8fa6f825eb7d
parent 700 a6b61f1a062d
child 792 3778920f61e4
equal deleted inserted replaced
757:6210c4260899 758:8fa6f825eb7d
    73 static uint8_t macs[MAX_MASTERS][2][ETH_ALEN]; /**< MAC addresses */
    73 static uint8_t macs[MAX_MASTERS][2][ETH_ALEN]; /**< MAC addresses */
    74 
    74 
    75 static dev_t device_number; /**< XML character device number */
    75 static dev_t device_number; /**< XML character device number */
    76 ec_xmldev_t xmldev; /**< XML character device */
    76 ec_xmldev_t xmldev; /**< XML character device */
    77 
    77 
    78 char *ec_master_version_str = EC_MASTER_VERSION;
    78 char *ec_master_version_str = EC_MASTER_VERSION; /**< master version string */
    79 
    79 
    80 /*****************************************************************************/
    80 /*****************************************************************************/
    81 
    81 
    82 /** \cond */
    82 /** \cond */
    83 
    83 
   205 
   205 
   206 /*****************************************************************************
   206 /*****************************************************************************
   207  * MAC address functions
   207  * MAC address functions
   208  ****************************************************************************/
   208  ****************************************************************************/
   209 
   209 
       
   210 /**
       
   211  * \return true, if two MAC addresses are equal.
       
   212  */
       
   213 
   210 int ec_mac_equal(const uint8_t *mac1, const uint8_t *mac2)
   214 int ec_mac_equal(const uint8_t *mac1, const uint8_t *mac2)
   211 {
   215 {
   212     unsigned int i;
   216     unsigned int i;
   213     
   217     
   214     for (i = 0; i < ETH_ALEN; i++)
   218     for (i = 0; i < ETH_ALEN; i++)
   218     return 1;
   222     return 1;
   219 }
   223 }
   220                 
   224                 
   221 /*****************************************************************************/
   225 /*****************************************************************************/
   222 
   226 
   223 ssize_t ec_mac_print(const uint8_t *mac, char *buffer)
   227 /**
       
   228  * Print a MAC address to a buffer.
       
   229  * \return number of bytes written.
       
   230  */
       
   231 
       
   232 ssize_t ec_mac_print(
       
   233         const uint8_t *mac, /**< MAC address */
       
   234         char *buffer /**< target buffer */
       
   235         )
   224 {
   236 {
   225     off_t off = 0;
   237     off_t off = 0;
   226     unsigned int i;
   238     unsigned int i;
   227     
   239     
   228     for (i = 0; i < ETH_ALEN; i++) {
   240     for (i = 0; i < ETH_ALEN; i++) {
   233     return off;
   245     return off;
   234 }
   246 }
   235 
   247 
   236 /*****************************************************************************/
   248 /*****************************************************************************/
   237 
   249 
       
   250 /**
       
   251  * \return true, if the MAC address is all-zero.
       
   252  */
       
   253 
   238 int ec_mac_is_zero(const uint8_t *mac)
   254 int ec_mac_is_zero(const uint8_t *mac)
   239 {
   255 {
   240     unsigned int i;
   256     unsigned int i;
   241     
   257     
   242     for (i = 0; i < ETH_ALEN; i++)
   258     for (i = 0; i < ETH_ALEN; i++)
   246     return 1;
   262     return 1;
   247 }
   263 }
   248 
   264 
   249 /*****************************************************************************/
   265 /*****************************************************************************/
   250 
   266 
       
   267 /**
       
   268  * \return true, if the given MAC address is the broadcast address.
       
   269  */
       
   270 
   251 int ec_mac_is_broadcast(const uint8_t *mac)
   271 int ec_mac_is_broadcast(const uint8_t *mac)
   252 {
   272 {
   253     unsigned int i;
   273     unsigned int i;
   254     
   274     
   255     for (i = 0; i < ETH_ALEN; i++)
   275     for (i = 0; i < ETH_ALEN; i++)
   258 
   278 
   259     return 1;
   279     return 1;
   260 }
   280 }
   261 
   281 
   262 /*****************************************************************************/
   282 /*****************************************************************************/
       
   283 
       
   284 /**
       
   285  * Parse a MAC address from a string.
       
   286  * The MAC address must follow the regexp
       
   287  * "([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}".
       
   288    \return 0 on success, else < 0
       
   289  */
   263 
   290 
   264 static int ec_mac_parse(uint8_t *mac, const char *src, int allow_empty)
   291 static int ec_mac_parse(uint8_t *mac, const char *src, int allow_empty)
   265 {
   292 {
   266     unsigned int i, value;
   293     unsigned int i, value;
   267     const char *orig = src;
   294     const char *orig = src;