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

Function fromwire_wireaddr_internal

common/wireaddr.c:126–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126bool fromwire_wireaddr_internal(const u8 **cursor, size_t *max,
127 struct wireaddr_internal *addr)
128{
129 addr->itype = fromwire_u8(cursor, max);
130 switch (addr->itype) {
131 case ADDR_INTERNAL_SOCKNAME:
132 fromwire_u8_array(cursor, max, (u8 *)addr->u.sockname,
133 sizeof(addr->u.sockname));
134 /* Must be NUL terminated */
135 if (!memchr(addr->u.sockname, 0, sizeof(addr->u.sockname)))
136 fromwire_fail(cursor, max);
137 return *cursor != NULL;
138 case ADDR_INTERNAL_ALLPROTO:
139 addr->u.allproto.is_websocket = fromwire_bool(cursor, max);
140 addr->u.allproto.port = fromwire_u16(cursor, max);
141 return *cursor != NULL;
142 case ADDR_INTERNAL_AUTOTOR:
143 if (fromwire_wireaddr(cursor, max, &addr->u.torservice.address) != FROMWIREADDR_OK)
144 fromwire_fail(cursor, max);
145 addr->u.torservice.port = fromwire_u16(cursor, max);
146 return *cursor != NULL;
147 case ADDR_INTERNAL_STATICTOR:
148 if (fromwire_wireaddr(cursor, max, &addr->u.torservice.address) != FROMWIREADDR_OK)
149 fromwire_fail(cursor, max);
150 fromwire_u8_array(cursor, max, (u8 *)addr->u.torservice.blob,
151 sizeof(addr->u.torservice.blob));
152 addr->u.torservice.port = fromwire_u16(cursor, max);
153 return *cursor != NULL;
154 case ADDR_INTERNAL_WIREADDR:
155 addr->u.wireaddr.is_websocket = fromwire_bool(cursor, max);
156 return fromwire_wireaddr(cursor, max, &addr->u.wireaddr.wireaddr) == FROMWIREADDR_OK;
157 case ADDR_INTERNAL_FORPROXY:
158 fromwire_u8_array(cursor, max, (u8 *)addr->u.unresolved.name,
159 sizeof(addr->u.unresolved.name));
160 /* Must be NUL terminated */
161 if (!memchr(addr->u.unresolved.name, 0,
162 sizeof(addr->u.unresolved.name)))
163 fromwire_fail(cursor, max);
164 addr->u.unresolved.port = fromwire_u16(cursor, max);
165 return *cursor != NULL;
166 }
167 fromwire_fail(cursor, max);
168 return false;
169}
170
171void wireaddr_from_ipv4(struct wireaddr *addr,
172 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