+static int cleanup() {
+ int errors = 0;
+
+ if( ! si_ctx ) {
+ return 0;
+ }
+
+ SIconnect( si_ctx, "localhost:43086" ); // ensure context has a tp block to free on shutdown
+ SIshutdown( si_ctx );
+
+ return errors;
+}
+
+/*
+ Address related tests.
+*/
+static int addr() {
+ int errors = 0;
+ int l;
+ struct sockaddr* addr;
+ char buf1[4096];
+ char buf2[4096];
+ char* dest;
+
+ addr = (struct sockaddr *) malloc( sizeof( struct sockaddr ) );
+/*
+ l = SIgenaddr( " [ff02::4]:4567", PF_INET6, IPPROTO_TCP, SOCK_STREAM, &addr );
+
+ SIgenaddr( " [ff02::4]:4567", PF_INET6, IPPROTO_TCP, SOCK_STREAM, &addr );
+*/
+
+ dest = NULL;
+ snprintf( buf1, sizeof( buf1 ), " [ff02::5:4001" ); // invalid address, drive leading space eater too
+ l = SIaddress( buf1, &dest, AC_TOADDR6 );
+ errors += fail_if_true( l > 0, "to addr6 with bad addr convdersion returned valid len" );
+
+ snprintf( buf1, sizeof( buf1 ), "[ff02::5]:4002" ); // v6 might not be supported so failure is OK here
+ l=SIaddress( buf1, &dest, AC_TOADDR6 );
+ errors += fail_if_true( l < 1, "to addr convdersion failed" );
+
+ snprintf( buf1, sizeof( buf1 ), "localhost:43086" );
+ l = SIaddress( buf1, (void **) &dest, AC_TOADDR );
+ errors += fail_if_true( l < 1, "to addr convdersion failed" );
+
+ snprintf( buf1, sizeof( buf1 ), "localhost:4004" );
+ l = SIaddress( buf1, &dest, AC_TODOT );
+ errors += fail_if_true( l < 1, "to dot convdersion failed" );
+
+ return errors;
+
+}
+