agileRTOS (zrtos)  Version 0.8.0 (ghostbuster)
network.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 ykat UG (haftungsbeschraenkt) - All Rights Reserved
3  *
4  * Permission for non-commercial use is hereby granted,
5  * free of charge, without warranty of any kind.
6  */
7 #ifndef ZRTOS_VFS_MODULE_NETWORK_H
8 #define ZRTOS_VFS_MODULE_NETWORK_H
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include <zrtos/types.h>
14 
15 
16 typedef struct{
17  uint8_t data[6];
18 }__attribute__((packed))zrtos_vfs_module_network_mac_t;
19 
20 typedef struct{
21  uint8_t data[4];
22 }__attribute__((packed))zrtos_vfs_module_network_ip4_t;
23 
24 typedef struct{
25  uint8_t data[4];
26 }__attribute__((packed))zrtos_vfs_module_network_subnet_mask_t;
27 
30  ,const char *src
31 ){
32  char ch;
33  uint16_t val = 0;
34  size_t pos = 0;
35 
36  while(true){
37  ch = *src++;
38  if(zrtos_types__is_digit(ch)){
39  val += (ch - '0') * 10;
40  }else if(
41  (ch == '.' || ch == '\0')
42  && pos < 4
43  && val < 2560
44  ){
45  thiz->data[pos++] = val/10;
46  val = 0;
47  if(ch == '\0'){
48  break;
49  }
50  }else{
51  break;
52  }
53  }
54 
55  return pos == 4;
56 }
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 #endif
bool zrtos_vfs_module_network_ip4__init(zrtos_vfs_module_network_ip4_t *thiz, const char *src)
Definition: network.h:28
bool zrtos_types__is_digit(char c)
Definition: types.h:264
static uint8_t
Definition: mcp2515.h:159