upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/unit/stubs/lwip/ip4_addr.h
blob: 9d92ff0fef00f7b438d339bde9defca763642455 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef STUBS_LWIP_IP4_ADDR_H
#define STUBS_LWIP_IP4_ADDR_H

#include <stdint.h>

typedef uint32_t u32_t;
typedef uint16_t u16_t;

typedef struct {
    uint32_t addr;
} ip4_addr_t;

typedef ip4_addr_t esp_ip4_addr_t;

#define IPSTR "%d.%d.%d.%d"
#define IP2STR(ip) ((ip)->addr & 0xff), (((ip)->addr >> 8) & 0xff), (((ip)->addr >> 16) & 0xff), (((ip)->addr >> 24) & 0xff)

static inline void IP4_ADDR(esp_ip4_addr_t *ip, uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
    ip->addr = ((uint32_t)a) | ((uint32_t)b << 8) | ((uint32_t)c << 16) | ((uint32_t)d << 24);
}

#endif