version 1.2.2.3, 2012/04/27 10:07:51
|
version 1.2.2.4, 2012/04/27 16:41:56
|
Line 54 Subscribe(int sock, FILE *lf)
|
Line 54 Subscribe(int sock, FILE *lf)
|
{ |
{ |
int siz; |
int siz; |
u_char *qoses; |
u_char *qoses; |
u_short mid; | u_short mid[2]; |
|
|
siz = mqtt_msgSUBSCRIBE(args->msg, args->subscr, AIT_GET_U16(&args->ConnID), args->Dup, args->QoS); | srandomdev(); |
| mid[0] = random() % USHRT_MAX; |
| |
| siz = mqtt_msgSUBSCRIBE(args->msg, args->subscr, mid[0], args->Dup, args->QoS); |
if (siz == -1) { |
if (siz == -1) { |
printf("Error:: in msgSUBSCRIBE #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
printf("Error:: in msgSUBSCRIBE #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
return -1; |
return -1; |
Line 68 Subscribe(int sock, FILE *lf)
|
Line 71 Subscribe(int sock, FILE *lf)
|
siz = RecvFrom(sock); |
siz = RecvFrom(sock); |
if (siz == -1) |
if (siz == -1) |
return -1; |
return -1; |
siz = mqtt_readSUBACK(args->msg, &mid, &qoses); | siz = mqtt_readSUBACK(args->msg, &mid[1], &qoses); |
if (siz == -1) { |
if (siz == -1) { |
printf("Error:: in readSUBACK #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
printf("Error:: in readSUBACK #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
return -1; |
return -1; |
} |
} |
if (mid != AIT_GET_U16(&args->ConnID)) { | if (mid[1] != mid[0]) { |
printf("Error:: received different connection ID %d != %d\n", | printf("Error:: received different connection ID %d != %d\n", mid[1], mid[0]); |
mid, AIT_GET_U16(&args->ConnID)); | |
return -1; |
return -1; |
} |
} |
|
|
|
free(qoses); |
return 0; |
return 0; |
} |
} |
|
|
Line 113 main(int argc, char **argv)
|
Line 116 main(int argc, char **argv)
|
return 1; |
return 1; |
} |
} |
|
|
|
AIT_SET_STR(&args->ConnID, ""); |
AIT_SET_STR(&args->User, ""); |
AIT_SET_STR(&args->User, ""); |
AIT_SET_STR(&args->Pass, ""); |
AIT_SET_STR(&args->Pass, ""); |
|
|
Line 203 main(int argc, char **argv)
|
Line 207 main(int argc, char **argv)
|
free(args); |
free(args); |
Usage(); |
Usage(); |
return 1; |
return 1; |
} else | } else { |
AIT_SET_U16(&args->ConnID, strtol(argv[1], NULL, 0)); | AIT_FREE_VAL(&args->ConnID); |
| AIT_SET_STR(&args->ConnID, argv[1]); |
| } |
if (argc > 2) { |
if (argc > 2) { |
AIT_FREE_VAL(&args->Value); |
AIT_FREE_VAL(&args->Value); |
AIT_SET_STR(&args->Value, argv[2]); |
AIT_SET_STR(&args->Value, argv[2]); |