int at_cnmi(int mode, int i1, int i2, int i3, int i4) { char buffer[256]; zsnprintf(buffer, "AT+CNMI=%d,%d,%d,%d,%d", mode, i1, i2, i3, i4); writefd(buffer); return checkok(); }
int at_cmgf(int mode) { char buffer[256]; zsnprintf(buffer, "AT+CMGF=%d", mode); writefd(buffer); return checkok(); }
int at_cpms(char *s1, char *s2, char *s3) { char buffer[256]; zsnprintf(buffer, "AT+CPMS=\"%s\",\"%s\",\"%s\"", s1, s2, s3); writefd(buffer); return checkok(); }
int at_echo(int value) { char buffer[64]; zsnprintf(buffer, "ATE%d", value); writefd(buffer); return checkok(); }
int at_curc(int value) { char buffer[256]; zsnprintf(buffer, "AT^CURC=%d", value); writefd(buffer); return checkok(); }
int at_cmgd(int index, int mode) { char buffer[256]; zsnprintf(buffer, "AT+CMGD=%d,%d", index, mode); writefd(buffer); return checkok(); }
void Game:: sell (int count, int cost) { char str [80]; sprintf (str, "sell %d %d", count, cost); q.sendstr (str); checkok (); }
char *tls_data_fprint(const char *buf, int len, const char *mdalg) { EVP_MD_CTX *mdctx; const EVP_MD *md; unsigned char md_buf[EVP_MAX_MD_SIZE]; unsigned int md_len; int ok = 1; /* Previously available in "init" routine. */ if ((md = EVP_get_digestbyname(mdalg)) == 0) msg_panic("digest algorithm \"%s\" not found", mdalg); mdctx = EVP_MD_CTX_create(); checkok(EVP_DigestInit_ex(mdctx, md, NULL)); digest_data(buf, len); checkok(EVP_DigestFinal_ex(mdctx, md_buf, &md_len)); EVP_MD_CTX_destroy(mdctx); if (!ok) msg_fatal("error computing %s message digest", mdalg); return (tls_digest_encode(md_buf, md_len)); }
void Game:: prod (int count) { char str[20]; sprintf (str, "prod %d", count); q.sendstr (str); checkok (); Player * player = lp->find (nick); player->money -= count * prod_creating_cost; player->raw -= count; player->prod += count; }
void sendlocation(unsigned char *num) { int k; stringuart1("AT"); uart_1_Transmit('+'); stringuart1("CMGF"); uart_1_Transmit('='); uart_1_Transmit('1'); uart_1_Transmit(13); if (checkok()==1) { stringuart1("AT+CMGS="); uart_1_Transmit('"'); while(*num) uart_1_Transmit(*num++); uart_1_Transmit('"'); uart_1_Transmit(13); while(USART1_Recieve()!='>'); stringuart1("accident happened at"); uart_1_Transmit(13); stringuart1("longi="); for(k=0;k<12;k++) uart_1_Transmit(longi[k]); uart_1_Transmit(13); stringuart1("latti="); for(k=0;k<11;k++) uart_1_Transmit(lati[k]); uart_1_Transmit(13); stringuart1("time="); for(k=0;k<11;k++) uart_1_Transmit(time[k]); uart_1_Transmit(26); } }
char *tls_serverid_digest(const TLS_CLIENT_START_PROPS *props, long protomask, const char *ciphers) { EVP_MD_CTX *mdctx; const EVP_MD *md; const char *mdalg; unsigned char md_buf[EVP_MAX_MD_SIZE]; unsigned int md_len; int ok = 1; int i; long sslversion; VSTRING *result; /* * Try to use sha256: our serverid choice should be strong enough to * resist 2nd-preimage attacks with a difficulty comparable to that of * DANE TLSA digests. Failing that, we compute serverid digests with the * default digest, but DANE requires sha256 and sha512, so if we must * fall back to our default digest, DANE support won't be available. We * panic if the fallback algorithm is not available, as it was verified * available in tls_client_init() and must not simply vanish. */ if ((md = EVP_get_digestbyname(mdalg = "sha256")) == 0 && (md = EVP_get_digestbyname(mdalg = props->mdalg)) == 0) msg_panic("digest algorithm \"%s\" not found", mdalg); /* Salt the session lookup key with the OpenSSL runtime version. */ sslversion = SSLeay(); mdctx = EVP_MD_CTX_create(); checkok(EVP_DigestInit_ex(mdctx, md, NULL)); digest_string(props->helo ? props->helo : ""); digest_object(&sslversion); digest_object(&protomask); digest_string(ciphers); /* * All we get from the session cache is a single bit telling us whether * the certificate is trusted or not, but we need to know whether the * trust is CA-based (in that case we must do name checks) or whether it * is a direct end-point match. We mustn't confuse the two, so it is * best to process only TA trust in the verify callback and check the EE * trust after. This works since re-used sessions always have access to * the leaf certificate, while only the original session has the leaf and * the full trust chain. * * Only the trust anchor matchlist is hashed into the session key. The end * entity certs are not used to determine whether a certificate is * trusted or not, rather these are rechecked against the leaf cert * outside the verification callback, each time a session is created or * reused. * * Therefore, the security context of the session does not depend on the EE * matching data, which is checked separately each time. So we exclude * the EE part of the DANE structure from the serverid digest. * * If the security level is "dane", we send SNI information to the peer. * This may cause it to respond with a non-default certificate. Since * certificates for sessions with no or different SNI data may not match, * we must include the SNI name in the session id. */ if (props->dane) { int mixed = (props->dane->flags & TLS_DANE_FLAG_MIXED); digest_object(&mixed); digest_dane(props->dane, ta); #if 0 digest_dane(props->dane, ee); /* See above */ #endif digest_string(props->tls_level == TLS_LEV_DANE ? props->host : ""); } checkok(EVP_DigestFinal_ex(mdctx, md_buf, &md_len)); EVP_MD_CTX_destroy(mdctx); if (!ok) msg_fatal("error computing %s message digest", mdalg); /* Check for OpenSSL contract violation */ if (md_len > EVP_MAX_MD_SIZE) msg_panic("unexpectedly large %s digest size: %u", mdalg, md_len); /* * Append the digest to the serverid. We don't compare this digest to * any user-specified fingerprints. Therefore, we don't need to use a * colon-separated format, which saves space in the TLS session cache and * makes logging of session cache lookup keys more readable. * * This does however duplicate a few lines of code from the digest encoder * for colon-separated cert and pkey fingerprints. If that is a * compelling reason to consolidate, we could use that and append the * result. */ result = vstring_alloc(strlen(props->serverid) + 1 + 2 * md_len); vstring_strcpy(result, props->serverid); VSTRING_ADDCH(result, '&'); for (i = 0; i < md_len; i++) { VSTRING_ADDCH(result, hexcodes[(md_buf[i] & 0xf0) >> 4U]); VSTRING_ADDCH(result, hexcodes[(md_buf[i] & 0x0f)]); } VSTRING_TERMINATE(result); return (vstring_export(result)); }
int at_single() { at_commit(); writefd("AT"); return checkok(); }