Skip to content

UDPInterface_beginConnection returning a switch label across the RPC #117

Closed
wants to merge 1 commit into from

2 participants

@cyisfor
cyisfor commented Aug 20, 2012

No description provided.

@cjdelisle cjdelisle commented on the diff Aug 20, 2012
interface/UDPInterface_admin.c
+ switch (UDPInterface_beginConnection(address->bytes, pkBytes, password, udpif, &switchLabel)) {
+ case UDPInterface_beginConnection_OUT_OF_SPACE:
+ ERROR("no more space to register with the switch.");
+ break;
+ case UDPInterface_beginConnection_BAD_KEY:
+ ERROR("invalid cjdns public key.");
+ break;
+ case UDPInterface_beginConnection_BAD_ADDRESS:
+ ERROR("unable to parse ip address and port.");
+ break;
+ case UDPInterface_beginConnection_ADDRESS_MISMATCH:
+ ERROR("different address type than this socket is bound to.");
+ break;
+ case 0:
+ RESULT("none",
+ Dict_CONST(String_CONST("label"), Int_OBJ(switchLabel),
@cjdelisle
Owner
cjdelisle added a note Aug 20, 2012

switch labels are never represented as integers in the admin interface, if you give this to a user, they will not be able to call SwitchPinger_ping() with it or RouterModule_pingNode() or compare it to the result of a RouterModule_lookup() so it is useless. You need to use AddrTools_printPath().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@cjdelisle cjdelisle commented on the diff Aug 20, 2012
interface/test/UDPInterface_test.c
@@ -47,6 +48,8 @@ static void registerInterface(struct Interface* externalInterface,
registerInterfaceCalls++;
}
+#define STRCOMPP(ca,b) memcmp(ca,b,sizeof(ca)-1)
@cjdelisle
Owner
cjdelisle added a note Aug 20, 2012

what's the point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@cjdelisle cjdelisle commented on the diff Aug 20, 2012
interface/UDPInterface.c
@@ -173,7 +173,8 @@ static void handleEvent(evutil_socket_t socket, short eventType, void* vcontext)
int UDPInterface_beginConnection(const char* address,
uint8_t cryptoKey[32],
String* password,
- struct UDPInterface* udpif)
+ struct UDPInterface* udpif,
+ uint64_t* switchLabel)
@cjdelisle
Owner
cjdelisle added a note Aug 20, 2012

out of alignment with the other lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@cjdelisle cjdelisle commented on the diff Aug 20, 2012
interface/UDPInterface_admin.c
if (ctx->ifCount == 0) {
- error = String_CONST("no interfaces are setup, call UDPInterface_new() first");
+ ERROR("no interfaces are setup, call UDPInterface_new() first");
+
@cjdelisle
Owner
cjdelisle added a note Aug 20, 2012

why the empty line before the closing bracket?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@cjdelisle cjdelisle commented on the diff Aug 20, 2012
interface/UDPInterface_admin.c
uint8_t pkBytes[32];
+#define RESULT(message,next) { \
+ Dict out = Dict_CONST( \
+ String_CONST_SO("error"), \
+ String_OBJ(String_CONST_SO(message)), \
+ next); \
+ Admin_sendMessage(&out, txid, ctx->admin); \
+ return; \
+ }
+#define ERROR(error) RESULT(error,NULL)
@cjdelisle
Owner
cjdelisle added a note Aug 20, 2012

I know other projects do this but in cjdns all #defines have the same indentation as surrounding text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@cjdelisle
Owner

hasn't been worked on in a while, closing for now.

@cjdelisle cjdelisle closed this Nov 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.