netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
afpcmd_spotlight.c File Reference
`#include <stdio.h>`
`#include <stdint.h>`
`#include <string.h>`
`#include "afpcmd.h"`
`#include "afpclient.h"`
`#include <talloc.h>`
`#include <atalk/afp.h>`
`#include <atalk/spotlight.h>`
`#include <atalk/dalloc.h>`

## Macros
#define | SL_PACK_BUFLEN 65472
#define | TEST_SQ_TYPE_INT64 0x8400
#define | TEST_SQ_TYPE_TOC 0x8800

## Functions
static uint64_t | spotlight_test_pack_tag (uint16_t type, uint16_t size_or_count, uint32_t val)
static uint32_t | spotlight_test_get_le32 (const char *buf, size_t offset)
static void | spotlight_test_put_le32 (uint8_t *buf, size_t offset, uint32_t val)
static void | spotlight_test_put_le64 (uint8_t *buf, size_t offset, uint64_t val)
static int | spotlight_pack_fetch_properties_rpc (char *rpcbuf)
static unsigned int | spotlight_send (CONN *conn, uint16_t vid, uint32_t subcmd, const uint8_t *rpc_buf, size_t rpc_len)
| Wrap an AFP_SPOTLIGHT_PRIVATE request and ship it on the DSI.
unsigned int | FPSpotlightFetchPropertiesWithShrunkTOC (CONN *conn, uint16_t vid)
| Send an otherwise-valid fetchPropertiesForContext: request whose TOC tag claims no usable complex-object entries.
unsigned int | FPSpotlightFetchPropertiesWithLargeTOCIndex (CONN *conn, uint16_t vid)
| Send a valid fetchPropertiesForContext: request whose first complex tag references a far out-of-range TOC index.
unsigned int | FPSpotlightRPCWithLargeInt64Count (CONN *conn, uint16_t vid)
| Send the companion advisory PoC: one INT64 tag claiming a huge count.
unsigned int | FPSpotlightOpen (CONN *conn, uint16_t vid, char *vol_path_out, size_t vol_path_buflen)
| Send SPOTLIGHT_CMD_OPEN and optionally extract the volume path.
unsigned int | FPSpotlightOpenQuery (CONN *conn, uint16_t vid, const char *query_dsl, uint64_t ctx)
| Build and send an openQueryWithParams:forContext: Spotlight RPC.
unsigned int | FPSpotlightDrainResults (CONN *conn, uint16_t vid, uint64_t ctx, int *total_results_out)
| Drain Spotlight query results until the server reports complete.
unsigned int | FPSpotlightCloseQuery (CONN *conn, uint16_t vid, uint64_t ctx)
| Send a closeQueryForContext: Spotlight RPC for the given context.

## Variables
int | Quiet

## Macro Definition Documentation

## ◆ SL_PACK_BUFLEN

#define SL_PACK_BUFLEN 65472

## ◆ TEST_SQ_TYPE_INT64

#define TEST_SQ_TYPE_INT64 0x8400

## ◆ TEST_SQ_TYPE_TOC

#define TEST_SQ_TYPE_TOC 0x8800

## Function Documentation

## ◆ FPSpotlightCloseQuery()

unsigned int FPSpotlightCloseQuery | ( | CONN * | conn,
|  | uint16_t | vid,
|  | uint64_t | ctx )

Send a closeQueryForContext: Spotlight RPC for the given context.

## ◆ FPSpotlightDrainResults()

unsigned int FPSpotlightDrainResults | ( | CONN * | conn,
|  | uint16_t | vid,
|  | uint64_t | ctx,
|  | int * | total_results_out )

Drain Spotlight query results until the server reports complete.

Loops fetchQueryResultsForContext: until the embedded status field is 0 (search complete) or the loop guard expires. Sums the kMDQueryResultIndices array length from each reply.

The SPOTLIGHT_CMD_RPC reply envelope has 4 leading bytes before the marshalled DALLOC_CTX (matches the server's sl_pack(reply, rbuf+4)).

## ◆ FPSpotlightFetchPropertiesWithLargeTOCIndex()

unsigned int FPSpotlightFetchPropertiesWithLargeTOCIndex | ( | CONN * | conn,
|  | uint16_t | vid )

Send a valid fetchPropertiesForContext: request whose first complex tag references a far out-of-range TOC index.

## ◆ FPSpotlightFetchPropertiesWithShrunkTOC()

unsigned int FPSpotlightFetchPropertiesWithShrunkTOC | ( | CONN * | conn,
|  | uint16_t | vid )

Send an otherwise-valid fetchPropertiesForContext: request whose TOC tag claims no usable complex-object entries.

## ◆ FPSpotlightOpen()

unsigned int FPSpotlightOpen | ( | CONN * | conn,
|  | uint16_t | vid,
|  | char * | vol_path_out,
|  | size_t | vol_path_buflen )

Send SPOTLIGHT_CMD_OPEN and optionally extract the volume path.

On success the reply layout is vid (4) + zero (4) + NUL-terminated path starting at dsi->data + 8; if `vol_path_out` is non-NULL the path is copied via strlcpy bounded by `vol_path_buflen`.

## ◆ FPSpotlightOpenQuery()

unsigned int FPSpotlightOpenQuery | ( | CONN * | conn,
|  | uint16_t | vid,
|  | const char * | query_dsl,
|  | uint64_t | ctx )

Build and send an openQueryWithParams:forContext: Spotlight RPC.

Mirrors sl_rpc_openQuery's expectations exactly. The outer DALLOC_CTX holds one sl_array_t (outer_array) with two children: [0] args : sl_array_t with three elements [0] = "openQueryWithParams:forContext:" (char *) [1] = ctx1 (uint64_t) [2] = ctx2 (uint64_t) [1] params : sl_dict_t — key/value pairs (kMDQueryString → DSL, kMDAttributeArray → sl_array_t, kMDScopeArray → char *)

Stack-local scalars use dalloc_add_copy so the value is memcpy'd into a freshly-talloc'd chunk; dalloc_add only captures a pointer.

Both ctx values are needed because sl_rpc_openQuery dereferences both via dalloc_get(query, "DALLOC_CTX", 0, "DALLOC_CTX", 0, "uint64_t", 1) and "uint64_t", 2.

## ◆ FPSpotlightRPCWithLargeInt64Count()

unsigned int FPSpotlightRPCWithLargeInt64Count | ( | CONN * | conn,
|  | uint16_t | vid )

Send the companion advisory PoC: one INT64 tag claiming a huge count.

## ◆ spotlight_pack_fetch_properties_rpc()

int spotlight_pack_fetch_properties_rpc | ( | char * | rpcbuf | ) |
| static

## ◆ spotlight_send()

unsigned int spotlight_send | ( | CONN * | conn,
|  | uint16_t | vid,
|  | uint32_t | subcmd,
|  | const uint8_t * | rpc_buf,
|  | size_t | rpc_len )
| static

Wrap an AFP_SPOTLIGHT_PRIVATE request and ship it on the DSI.

Builds the 24-byte SPOTLIGHT_PRIVATE envelope (cmd byte, vid, reserved, subcmd, reserved, padding) and appends `rpc_buf`, then sends and receives the reply via the existing my_dsi_* helpers.

## ◆ spotlight_test_get_le32()

uint32_t spotlight_test_get_le32 | ( | const char * | buf,
|  | size_t | offset )
| static

## ◆ spotlight_test_pack_tag()

uint64_t spotlight_test_pack_tag | ( | uint16_t | type,
|  | uint16_t | size_or_count,
|  | uint32_t | val )
| static

## ◆ spotlight_test_put_le32()

void spotlight_test_put_le32 | ( | uint8_t * | buf,
|  | size_t | offset,
|  | uint32_t | val )
| static

## ◆ spotlight_test_put_le64()

void spotlight_test_put_le64 | ( | uint8_t * | buf,
|  | size_t | offset,
|  | uint64_t | val )
| static

## Variable Documentation

## ◆ Quiet

int Quiet
| extern