Lines Matching refs:sock
856 static int recv_code(int sock, int8_t* code) {
857 return recv(sock, code, 1, 0) == 1;
860 static int recv_message(int sock, uint8_t* message, int length) {
862 if (recv(sock, &bytes[0], 1, 0) != 1 ||
863 recv(sock, &bytes[1], 1, 0) != 1) {
873 int n = recv(sock, &message[offset], length - offset, 0);
883 static int recv_end_of_file(int sock) {
885 return recv(sock, &byte, 1, 0) == 0;
888 static void send_code(int sock, int8_t code) {
889 send(sock, &code, 1, 0);
892 static void send_message(int sock, const uint8_t* message, int length) {
894 send(sock, &bytes, 2, 0);
895 send(sock, message, length, 0);
942 static ResponseCode get(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*, Value*) {
950 send_code(sock, NO_ERROR);
951 send_message(sock, keyBlob.getValue(), keyBlob.getLength());
983 static ResponseCode saw(KeyStore*, int sock, uid_t uid, Value* keyPrefix, Value*, Value*) {
990 send_code(sock, NO_ERROR);
997 send_message(sock, keyPrefix->value, keyPrefix->length);
1055 static ResponseCode unlock(KeyStore* keyStore, int sock, uid_t uid, Value* pw, Value* unused,
1057 return password(keyStore, sock, uid, pw, unused, unused2);
1117 static ResponseCode get_pubkey(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*, Value*) {
1145 send_code(sock, NO_ERROR);
1146 send_message(sock, data, dataLength);
1177 static ResponseCode sign(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value* data,
1213 send_code(sock, NO_ERROR);
1214 send_message(sock, signedData, signedDataLength);
1296 ResponseCode (*run)(KeyStore* keyStore, int sock, uid_t uid, Value* param1, Value* param2,
1338 static ResponseCode process(KeyStore* keyStore, int sock, uid_t uid, int8_t code) {
1363 params[i].length = recv_message(sock, params[i].value, action->lengths[i]);
1368 if (!recv_end_of_file(sock)) {
1371 return action->run(keyStore, sock, uid, ¶ms[0], ¶ms[1], ¶ms[2]);
1404 int sock;
1405 while ((sock = accept(controlSocket, NULL, 0)) != -1) {
1408 setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
1409 setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
1413 int credResult = getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &cred, &size);
1418 if (recv_code(sock, &request)) {
1420 ResponseCode response = process(&keyStore, sock, cred.uid, request);
1424 send_code(sock, response);
1433 close(sock);