Documentation |
Documentation -> Development Manual 3.6 -> BIN Interface APIThis page has been visited 162 times. Pages for other versions: devel 3.5 3.4 Older versions: 3.3 3.2 3.1
The Binary Internal Interface is an OpenSIPS core interface which offers an efficient way for communication between individual OpenSIPS instances.
For creating and sending a new event, the following methods are to be used : /** * bin_init - begins the construction of a new binary packet (header part): * * +-------------------+------------------------------------------------------+ * | 8-byte HEADER | BODY max 65535 bytes | * +-------------------+------------------------------------------------------+ * | PK_MARKER | CRC | LEN | MOD_NAME | CMD | LEN | FIELD | LEN | FIELD |...| * +-------------------+------------------------------------------------------+ * * @param: { LEN, MOD_NAME } + CMD */ int bin_init(str *mod_name, int cmd_type) /* * copies the given string at the 'cpos' position in the buffer * allows null strings (NULL content or NULL param) * * @return: 0 on success */ int bin_push_str(const str *info) /* * adds a new integer value at the 'cpos' position in the buffer * * @return: 0 on success */ int bin_push_int(int info) /** * bin_send - computes the checksum of the current packet and then * sends the packet over UDP to the @dest destination * * @return: number of bytes sent, or -1 on error */ int bin_send(union sockaddr_union *dest)
/** * bin_register_cb - registers a module handler for specific packets * @mod_name: used to classify the incoming packets * @cb: the handler function, called once for each matched packet * * @return: 0 on success */ int bin_register_cb(char *mod_name, void (*cb)(int))
/* * pops an str from the current position in the buffer * @info: pointer to store the result * * @return: 0 on success * * Note: The pointer returned in @info str is only valid for the duration of * the callback. Don't forget to copy the info into a safe buffer! */ int bin_pop_str(str *info) /* * pops an integer value from the current position in the buffer * @info: pointer to store the result * * @return: 0 on success */ int bin_pop_int(void *info)
|