MCPcopy Create free account
hub / github.com/ElementsProject/lightning / fromwire_wireaddr_internal

Function fromwire_wireaddr_internal

common/wireaddr.c:142–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142bool fromwire_wireaddr_internal(const u8 **cursor, size_t *max,
143 struct wireaddr_internal *addr)
144{
145 addr->itype = fromwire_u8(cursor, max);
146 switch (addr->itype) {
147 case ADDR_INTERNAL_SOCKNAME:
148 fromwire_u8_array(cursor, max, (u8 *)addr->u.sockname,
149 sizeof(addr->u.sockname));
150 /* Must be NUL terminated */
151 if (!memchr(addr->u.sockname, 0, sizeof(addr->u.sockname)))
152 fromwire_fail(cursor, max);
153 return *cursor != NULL;
154 case ADDR_INTERNAL_ALLPROTO:
155 addr->u.allproto.is_websocket = fromwire_bool(cursor, max);
156 addr->u.allproto.port = fromwire_u16(cursor, max);
157 return *cursor != NULL;
158 case ADDR_INTERNAL_AUTOTOR:
159 if (fromwire_wireaddr(cursor, max, &addr->u.torservice.address) != FROMWIREADDR_OK)
160 fromwire_fail(cursor, max);
161 addr->u.torservice.port = fromwire_u16(cursor, max);
162 return *cursor != NULL;
163 case ADDR_INTERNAL_STATICTOR:
164 if (fromwire_wireaddr(cursor, max, &addr->u.torservice.address) != FROMWIREADDR_OK)
165 fromwire_fail(cursor, max);
166 fromwire_u8_array(cursor, max, (u8 *)addr->u.torservice.blob,
167 sizeof(addr->u.torservice.blob));
168 addr->u.torservice.port = fromwire_u16(cursor, max);
169 return *cursor != NULL;
170 case ADDR_INTERNAL_WIREADDR:
171 addr->u.wireaddr.is_websocket = fromwire_bool(cursor, max);
172 return fromwire_wireaddr(cursor, max, &addr->u.wireaddr.wireaddr) == FROMWIREADDR_OK;
173 case ADDR_INTERNAL_FORPROXY:
174 fromwire_u8_array(cursor, max, (u8 *)addr->u.unresolved.name,
175 sizeof(addr->u.unresolved.name));
176 /* Must be NUL terminated */
177 if (!memchr(addr->u.unresolved.name, 0,
178 sizeof(addr->u.unresolved.name)))
179 fromwire_fail(cursor, max);
180 addr->u.unresolved.port = fromwire_u16(cursor, max);
181 return *cursor != NULL;
182 }
183 fromwire_fail(cursor, max);
184 return false;
185}
186
187void wireaddr_from_ipv4(struct wireaddr *addr,
188 const struct in_addr *ip4,

Callers

nothing calls this directly

Calls 6

fromwire_wireaddrFunction · 0.85
fromwire_u8Function · 0.50
fromwire_u8_arrayFunction · 0.50
fromwire_failFunction · 0.50
fromwire_boolFunction · 0.50
fromwire_u16Function · 0.50

Tested by

no test coverage detected