Home | History | Annotate | Download | only in keystore

Lines Matching refs:sock

512 static int recv_code(int sock, int8_t* code) {
513 return recv(sock, code, 1, 0) == 1;
516 static int recv_message(int sock, uint8_t* message, int length) {
518 if (recv(sock, &bytes[0], 1, 0) != 1 ||
519 recv(sock, &bytes[1], 1, 0) != 1) {
529 int n = recv(sock, &message[offset], length - offset, 0);
539 static int recv_end_of_file(int sock) {
541 return recv(sock, &byte, 1, 0) == 0;
544 static void send_code(int sock, int8_t code) {
545 send(sock, &code, 1, 0);
548 static void send_message(int sock, uint8_t* message, int length) {
550 send(sock, &bytes, 2, 0);
551 send(sock, message, length, 0);
564 static ResponseCode test(KeyStore* keyStore, int sock, uid_t uid, Value*, Value*) {
568 static ResponseCode get(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*) {
576 send_code(sock, NO_ERROR);
577 send_message(sock, keyBlob.getValue(), keyBlob.getLength());
581 static ResponseCode insert(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value* val) {
588 static ResponseCode del(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*) {
594 static ResponseCode exist(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*) {
603 static ResponseCode saw(KeyStore* keyStore, int sock, uid_t uid, Value* keyPrefix, Value*) {
610 send_code(sock, NO_ERROR);
617 send_message(sock, keyPrefix->value, keyPrefix->length);
624 static ResponseCode reset(KeyStore* keyStore, int sock, uid_t uid, Value*, Value*) {
634 static ResponseCode password(KeyStore* keyStore, int sock, uid_t uid, Value* pw, Value*) {
652 static ResponseCode lock(KeyStore* keyStore, int sock, uid_t uid, Value*, Value*) {
657 static ResponseCode unlock(KeyStore* keyStore, int sock, uid_t uid, Value* pw, Value* unused) {
658 return password(keyStore, sock, uid, pw, unused);
661 static ResponseCode zero(KeyStore* keyStore, int sock, uid_t uid, Value*, Value*) {
686 ResponseCode (*run)(KeyStore* keyStore, int sock, uid_t uid, Value* param1, Value* param2);
718 static ResponseCode process(KeyStore* keyStore, int sock, uid_t uid, int8_t code) {
743 params[i].length = recv_message(sock, params[i].value, action->lengths[i]);
748 if (!recv_end_of_file(sock)) {
751 return action->run(keyStore, sock, uid, &params[0], &params[1]);
777 int sock;
778 while ((sock = accept(controlSocket, NULL, 0)) != -1) {
781 setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
782 setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
786 int credResult = getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &cred, &size);
791 if (recv_code(sock, &request)) {
793 ResponseCode response = process(&keyStore, sock, cred.uid, request);
797 send_code(sock, response);
806 close(sock);