master/module.c
branchredundancy
changeset 2129 78efdac9ee87
parent 1930 59a50053ccc6
child 2156 71425e6120d8
equal deleted inserted replaced
2124:c4afc5fede19 2129:78efdac9ee87
   287 
   287 
   288 /*****************************************************************************/
   288 /*****************************************************************************/
   289 
   289 
   290 /** Parse a MAC address from a string.
   290 /** Parse a MAC address from a string.
   291  *
   291  *
   292  * The MAC address must follow the regexp
   292  * The MAC address must match the regular expression
   293  * "([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}".
   293  * "([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}".
   294  *
   294  *
   295  * \return 0 on success, else < 0
   295  * \return 0 on success, else < 0
   296  */
   296  */
   297 static int ec_mac_parse(uint8_t *mac, const char *src, int allow_empty)
   297 static int ec_mac_parse(uint8_t *mac, const char *src, int allow_empty)
   301     char *rem;
   301     char *rem;
   302 
   302 
   303     if (!strlen(src)) {
   303     if (!strlen(src)) {
   304         if (allow_empty){
   304         if (allow_empty){
   305             return 0;
   305             return 0;
   306         }
   306         } else {
   307         else {
       
   308             EC_ERR("MAC address may not be empty.\n");
   307             EC_ERR("MAC address may not be empty.\n");
   309             return -EINVAL;
   308             return -EINVAL;
   310         }
   309         }
   311     }
   310     }
   312 
   311 
   317                 || (i < ETH_ALEN - 1 && *rem != ':')) {
   316                 || (i < ETH_ALEN - 1 && *rem != ':')) {
   318             EC_ERR("Invalid MAC address \"%s\".\n", orig);
   317             EC_ERR("Invalid MAC address \"%s\".\n", orig);
   319             return -EINVAL;
   318             return -EINVAL;
   320         }
   319         }
   321         mac[i] = value;
   320         mac[i] = value;
   322         if (i < ETH_ALEN - 1)
   321         if (i < ETH_ALEN - 1) {
   323             src = rem + 1; // skip colon
   322             src = rem + 1; // skip colon
       
   323         }
   324     }
   324     }
   325 
   325 
   326     return 0;
   326     return 0;
   327 }
   327 }
   328 
   328 
   500 
   500 
   501     return NULL; // offer declined
   501     return NULL; // offer declined
   502 }
   502 }
   503 
   503 
   504 /******************************************************************************
   504 /******************************************************************************
   505  *  Realtime interface
   505  * Application interface
   506  *****************************************************************************/
   506  *****************************************************************************/
   507 
   507 
   508 /** Request a master.
   508 /** Request a master.
   509  *
   509  *
   510  * Same as ecrt_request_master(), but with ERR_PTR() return value.
   510  * Same as ecrt_request_master(), but with ERR_PTR() return value.