update more

This commit is contained in:
JamesonHuang
2015-06-13 22:34:38 +08:00
parent a9b5bfb8a0
commit f95d9f5b55
115 changed files with 11274 additions and 0 deletions

View File

@ -0,0 +1,29 @@
CC=gcc
CFLAGS=-g -fPIC
OBJS=$(patsubst %.proto,%.o,$(wildcard *.proto))
OBJS+=nebula_proto.o
TARGET=libnebula_proto.a
all: $(TARGET)
$(TARGET):$(OBJS)
@echo "LD $(TARGET)"
@ar -cr $@ $^
%.o:%.proto
@echo "make $@"
@protoc-c $< --c_out=.
@$(CC) $(CFLAGS) -g $(patsubst %.o,%.pb-c.c,$@) -c -o $@
%.o:%.c
@echo "make $@"
@$(CC) $(CFLAGS) -g $< -c -o $@
.PHONY: clean echo
clean:
rm *.o *.a -f
echo:
@echo "TARGET=$(TARGET)"
@echo "OBJS=$(OBJS)"

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,979 @@
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
#ifndef PROTOBUF_C_message_2eproto__INCLUDED
#define PROTOBUF_C_message_2eproto__INCLUDED
#include <google/protobuf-c/protobuf-c.h>
PROTOBUF_C_BEGIN_DECLS
typedef struct _Nebula__Param Nebula__Param;
typedef struct _Nebula__AccountUpdateRequest Nebula__AccountUpdateRequest;
typedef struct _Nebula__AccountUpdateResponse Nebula__AccountUpdateResponse;
typedef struct _Nebula__AuthRequest Nebula__AuthRequest;
typedef struct _Nebula__AuthResponse Nebula__AuthResponse;
typedef struct _Nebula__Message Nebula__Message;
typedef struct _Nebula__Message__Content Nebula__Message__Content;
typedef struct _Nebula__MessageSeq Nebula__MessageSeq;
typedef struct _Nebula__MessageSeq__Content Nebula__MessageSeq__Content;
typedef struct _Nebula__MessageKievAck Nebula__MessageKievAck;
typedef struct _Nebula__SubscribeRequest Nebula__SubscribeRequest;
typedef struct _Nebula__SubscribeResponse Nebula__SubscribeResponse;
typedef struct _Nebula__SubscribeResponse__Content Nebula__SubscribeResponse__Content;
typedef struct _Nebula__NotifyBody Nebula__NotifyBody;
typedef struct _Nebula__SmsRequest Nebula__SmsRequest;
typedef struct _Nebula__SmsRequest__FileInfo Nebula__SmsRequest__FileInfo;
typedef struct _Nebula__SmsResponse Nebula__SmsResponse;
typedef struct _Nebula__PresenceNotify Nebula__PresenceNotify;
typedef struct _Nebula__PresenceNotify__Content Nebula__PresenceNotify__Content;
typedef struct _Nebula__PresenceRequest Nebula__PresenceRequest;
typedef struct _Nebula__PresenceResponse Nebula__PresenceResponse;
typedef struct _Nebula__AccountStatusRequest Nebula__AccountStatusRequest;
typedef struct _Nebula__AccountStatusResponse Nebula__AccountStatusResponse;
typedef struct _Nebula__AccountStatusResponse__AccountStatus Nebula__AccountStatusResponse__AccountStatus;
typedef struct _Nebula__Address Nebula__Address;
typedef struct _Nebula__DialogRequest Nebula__DialogRequest;
typedef struct _Nebula__DialogResponse Nebula__DialogResponse;
/* --- enums --- */
typedef enum _Nebula__AuthRequest__Algorithm {
NEBULA__AUTH_REQUEST__ALGORITHM__MD5_MEIZU = 0,
NEBULA__AUTH_REQUEST__ALGORITHM__MD5_DAA = 1,
NEBULA__AUTH_REQUEST__ALGORITHM__MD5_FLYME = 2
} Nebula__AuthRequest__Algorithm;
typedef enum _Nebula__Message__Content__MsgType {
NEBULA__MESSAGE__CONTENT__MSG_TYPE__ePushMessage = 0,
NEBULA__MESSAGE__CONTENT__MSG_TYPE__ePresenceMessage = 1,
NEBULA__MESSAGE__CONTENT__MSG_TYPE__eSmsMessage = 2
} Nebula__Message__Content__MsgType;
typedef enum _Nebula__Message__Flag {
NEBULA__MESSAGE__FLAG__MESSAGE_ACK = 1,
NEBULA__MESSAGE__FLAG__MESSAGE_END = 2
} Nebula__Message__Flag;
typedef enum _Nebula__SmsRequest__SmsType {
NEBULA__SMS_REQUEST__SMS_TYPE__eShortMessage = 0,
NEBULA__SMS_REQUEST__SMS_TYPE__eMultimediaMessage = 1,
NEBULA__SMS_REQUEST__SMS_TYPE__eReportMessage = 2
} Nebula__SmsRequest__SmsType;
typedef enum _Nebula__SmsRequest__ReportType {
NEBULA__SMS_REQUEST__REPORT_TYPE__eSMSReport = 0,
NEBULA__SMS_REQUEST__REPORT_TYPE__eMMSReport = 1
} Nebula__SmsRequest__ReportType;
typedef enum _Nebula__PresenceType {
NEBULA__PRESENCE_TYPE__eIncrementSubscribe = 0,
NEBULA__PRESENCE_TYPE__eFullSubscribe = 1,
NEBULA__PRESENCE_TYPE__eUnSubscribe = 2
} Nebula__PresenceType;
/* --- messages --- */
struct _Nebula__Param
{
ProtobufCMessage base;
char *name;
char *value;
};
#define NEBULA__PARAM__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__param__descriptor) \
, NULL, NULL }
struct _Nebula__AccountUpdateRequest
{
ProtobufCMessage base;
char *flyme_uid;
char *phone;
protobuf_c_boolean has_capability;
int32_t capability;
};
#define NEBULA__ACCOUNT_UPDATE_REQUEST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__account_update_request__descriptor) \
, NULL, NULL, 0,0 }
struct _Nebula__AccountUpdateResponse
{
ProtobufCMessage base;
int32_t status;
char *flyme_uid;
char *imsi;
char *phone;
protobuf_c_boolean has_capability;
int32_t capability;
};
#define NEBULA__ACCOUNT_UPDATE_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__account_update_response__descriptor) \
, 0, NULL, NULL, NULL, 0,0 }
struct _Nebula__AuthRequest
{
ProtobufCMessage base;
char *uid;
char *username;
char *nonce;
char *realm;
char *token;
protobuf_c_boolean has_algorithm;
Nebula__AuthRequest__Algorithm algorithm;
size_t n_other_info;
Nebula__Param **other_info;
};
#define NEBULA__AUTH_REQUEST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__auth_request__descriptor) \
, NULL, NULL, NULL, NULL, NULL, 0,0, 0,NULL }
struct _Nebula__AuthResponse
{
ProtobufCMessage base;
protobuf_c_boolean has_status;
int32_t status;
char *nonce;
char *realm;
};
#define NEBULA__AUTH_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__auth_response__descriptor) \
, 0,0, NULL, NULL }
struct _Nebula__Message__Content
{
ProtobufCMessage base;
Nebula__Message__Content__MsgType type;
char *account;
uint32_t seq;
protobuf_c_boolean has_body;
ProtobufCBinaryData body;
};
#define NEBULA__MESSAGE__CONTENT__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__message__content__descriptor) \
, 0, NULL, 0, 0,{0,NULL} }
struct _Nebula__Message
{
ProtobufCMessage base;
size_t n_content;
Nebula__Message__Content **content;
protobuf_c_boolean has_flag;
Nebula__Message__Flag flag;
};
#define NEBULA__MESSAGE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__message__descriptor) \
, 0,NULL, 0,0 }
struct _Nebula__MessageSeq__Content
{
ProtobufCMessage base;
char *account;
uint32_t seq;
};
#define NEBULA__MESSAGE_SEQ__CONTENT__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__message_seq__content__descriptor) \
, NULL, 0 }
struct _Nebula__MessageSeq
{
ProtobufCMessage base;
size_t n_content;
Nebula__MessageSeq__Content **content;
};
#define NEBULA__MESSAGE_SEQ__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__message_seq__descriptor) \
, 0,NULL }
struct _Nebula__MessageKievAck
{
ProtobufCMessage base;
Nebula__MessageSeq *seqs;
uint32_t index;
};
#define NEBULA__MESSAGE_KIEV_ACK__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__message_kiev_ack__descriptor) \
, NULL, 0 }
struct _Nebula__SubscribeRequest
{
ProtobufCMessage base;
size_t n_app;
char **app;
};
#define NEBULA__SUBSCRIBE_REQUEST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__subscribe_request__descriptor) \
, 0,NULL }
struct _Nebula__SubscribeResponse__Content
{
ProtobufCMessage base;
protobuf_c_boolean has_status;
int32_t status;
char *app;
char *pushid;
};
#define NEBULA__SUBSCRIBE_RESPONSE__CONTENT__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__subscribe_response__content__descriptor) \
, 0,0, NULL, NULL }
struct _Nebula__SubscribeResponse
{
ProtobufCMessage base;
int32_t status;
size_t n_content;
Nebula__SubscribeResponse__Content **content;
};
#define NEBULA__SUBSCRIBE_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__subscribe_response__descriptor) \
, 0, 0,NULL }
struct _Nebula__NotifyBody
{
ProtobufCMessage base;
char *app;
char *body;
};
#define NEBULA__NOTIFY_BODY__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__notify_body__descriptor) \
, NULL, NULL }
struct _Nebula__SmsRequest__FileInfo
{
ProtobufCMessage base;
char *mimetype;
int32_t size;
char *filename;
char *url;
};
#define NEBULA__SMS_REQUEST__FILE_INFO__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__sms_request__file_info__descriptor) \
, NULL, 0, NULL, NULL }
struct _Nebula__SmsRequest
{
ProtobufCMessage base;
Nebula__SmsRequest__SmsType type;
char *msgid;
char *src;
size_t n_dst;
char **dst;
protobuf_c_boolean has_body;
ProtobufCBinaryData body;
protobuf_c_boolean has_report_flag;
protobuf_c_boolean report_flag;
protobuf_c_boolean has_report_type;
Nebula__SmsRequest__ReportType report_type;
char *report_status;
char *time;
char *expires;
char *pdu;
protobuf_c_boolean has_size;
int32_t size;
char *ver;
size_t n_fileinfos;
Nebula__SmsRequest__FileInfo **fileinfos;
};
#define NEBULA__SMS_REQUEST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__sms_request__descriptor) \
, 0, NULL, NULL, 0,NULL, 0,{0,NULL}, 0,0, 0,0, NULL, NULL, NULL, NULL, 0,0, NULL, 0,NULL }
struct _Nebula__SmsResponse
{
ProtobufCMessage base;
char *msgid;
int32_t status;
};
#define NEBULA__SMS_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__sms_response__descriptor) \
, NULL, 0 }
struct _Nebula__PresenceNotify__Content
{
ProtobufCMessage base;
char *account;
protobuf_c_boolean has_capability;
int32_t capability;
protobuf_c_boolean has_status;
int32_t status;
};
#define NEBULA__PRESENCE_NOTIFY__CONTENT__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__presence_notify__content__descriptor) \
, NULL, 0,0, 0,0 }
struct _Nebula__PresenceNotify
{
ProtobufCMessage base;
size_t n_content;
Nebula__PresenceNotify__Content **content;
};
#define NEBULA__PRESENCE_NOTIFY__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__presence_notify__descriptor) \
, 0,NULL }
struct _Nebula__PresenceRequest
{
ProtobufCMessage base;
protobuf_c_boolean has_type;
Nebula__PresenceType type;
protobuf_c_boolean has_sequence;
uint32_t sequence;
size_t n_account;
char **account;
};
#define NEBULA__PRESENCE_REQUEST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__presence_request__descriptor) \
, 0,0, 0,0, 0,NULL }
struct _Nebula__PresenceResponse
{
ProtobufCMessage base;
int32_t status;
protobuf_c_boolean has_type;
Nebula__PresenceType type;
protobuf_c_boolean has_sequence;
uint32_t sequence;
size_t n_account;
char **account;
};
#define NEBULA__PRESENCE_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__presence_response__descriptor) \
, 0, 0,0, 0,0, 0,NULL }
struct _Nebula__AccountStatusRequest
{
ProtobufCMessage base;
size_t n_account;
char **account;
};
#define NEBULA__ACCOUNT_STATUS_REQUEST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__account_status_request__descriptor) \
, 0,NULL }
struct _Nebula__AccountStatusResponse__AccountStatus
{
ProtobufCMessage base;
char *account;
protobuf_c_boolean has_status;
int32_t status;
protobuf_c_boolean has_capability;
int32_t capability;
};
#define NEBULA__ACCOUNT_STATUS_RESPONSE__ACCOUNT_STATUS__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__account_status_response__account_status__descriptor) \
, NULL, 0,0, 0,0 }
struct _Nebula__AccountStatusResponse
{
ProtobufCMessage base;
int32_t status;
size_t n_result;
Nebula__AccountStatusResponse__AccountStatus **result;
};
#define NEBULA__ACCOUNT_STATUS_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__account_status_response__descriptor) \
, 0, 0,NULL }
struct _Nebula__Address
{
ProtobufCMessage base;
char *host;
int32_t port;
};
#define NEBULA__ADDRESS__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__address__descriptor) \
, NULL, 0 }
struct _Nebula__DialogRequest
{
ProtobufCMessage base;
char *src;
char *dst;
Nebula__Address *dialog;
protobuf_c_boolean has_body;
ProtobufCBinaryData body;
};
#define NEBULA__DIALOG_REQUEST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__dialog_request__descriptor) \
, NULL, NULL, NULL, 0,{0,NULL} }
struct _Nebula__DialogResponse
{
ProtobufCMessage base;
int32_t status;
char *src;
char *dst;
Nebula__Address *dialog;
protobuf_c_boolean has_body;
ProtobufCBinaryData body;
};
#define NEBULA__DIALOG_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__dialog_response__descriptor) \
, 0, NULL, NULL, NULL, 0,{0,NULL} }
/* Nebula__Param methods */
void nebula__param__init
(Nebula__Param *message);
size_t nebula__param__get_packed_size
(const Nebula__Param *message);
size_t nebula__param__pack
(const Nebula__Param *message,
uint8_t *out);
size_t nebula__param__pack_to_buffer
(const Nebula__Param *message,
ProtobufCBuffer *buffer);
Nebula__Param *
nebula__param__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__param__free_unpacked
(Nebula__Param *message,
ProtobufCAllocator *allocator);
/* Nebula__AccountUpdateRequest methods */
void nebula__account_update_request__init
(Nebula__AccountUpdateRequest *message);
size_t nebula__account_update_request__get_packed_size
(const Nebula__AccountUpdateRequest *message);
size_t nebula__account_update_request__pack
(const Nebula__AccountUpdateRequest *message,
uint8_t *out);
size_t nebula__account_update_request__pack_to_buffer
(const Nebula__AccountUpdateRequest *message,
ProtobufCBuffer *buffer);
Nebula__AccountUpdateRequest *
nebula__account_update_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__account_update_request__free_unpacked
(Nebula__AccountUpdateRequest *message,
ProtobufCAllocator *allocator);
/* Nebula__AccountUpdateResponse methods */
void nebula__account_update_response__init
(Nebula__AccountUpdateResponse *message);
size_t nebula__account_update_response__get_packed_size
(const Nebula__AccountUpdateResponse *message);
size_t nebula__account_update_response__pack
(const Nebula__AccountUpdateResponse *message,
uint8_t *out);
size_t nebula__account_update_response__pack_to_buffer
(const Nebula__AccountUpdateResponse *message,
ProtobufCBuffer *buffer);
Nebula__AccountUpdateResponse *
nebula__account_update_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__account_update_response__free_unpacked
(Nebula__AccountUpdateResponse *message,
ProtobufCAllocator *allocator);
/* Nebula__AuthRequest methods */
void nebula__auth_request__init
(Nebula__AuthRequest *message);
size_t nebula__auth_request__get_packed_size
(const Nebula__AuthRequest *message);
size_t nebula__auth_request__pack
(const Nebula__AuthRequest *message,
uint8_t *out);
size_t nebula__auth_request__pack_to_buffer
(const Nebula__AuthRequest *message,
ProtobufCBuffer *buffer);
Nebula__AuthRequest *
nebula__auth_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__auth_request__free_unpacked
(Nebula__AuthRequest *message,
ProtobufCAllocator *allocator);
/* Nebula__AuthResponse methods */
void nebula__auth_response__init
(Nebula__AuthResponse *message);
size_t nebula__auth_response__get_packed_size
(const Nebula__AuthResponse *message);
size_t nebula__auth_response__pack
(const Nebula__AuthResponse *message,
uint8_t *out);
size_t nebula__auth_response__pack_to_buffer
(const Nebula__AuthResponse *message,
ProtobufCBuffer *buffer);
Nebula__AuthResponse *
nebula__auth_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__auth_response__free_unpacked
(Nebula__AuthResponse *message,
ProtobufCAllocator *allocator);
/* Nebula__Message__Content methods */
void nebula__message__content__init
(Nebula__Message__Content *message);
/* Nebula__Message methods */
void nebula__message__init
(Nebula__Message *message);
size_t nebula__message__get_packed_size
(const Nebula__Message *message);
size_t nebula__message__pack
(const Nebula__Message *message,
uint8_t *out);
size_t nebula__message__pack_to_buffer
(const Nebula__Message *message,
ProtobufCBuffer *buffer);
Nebula__Message *
nebula__message__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__message__free_unpacked
(Nebula__Message *message,
ProtobufCAllocator *allocator);
/* Nebula__MessageSeq__Content methods */
void nebula__message_seq__content__init
(Nebula__MessageSeq__Content *message);
/* Nebula__MessageSeq methods */
void nebula__message_seq__init
(Nebula__MessageSeq *message);
size_t nebula__message_seq__get_packed_size
(const Nebula__MessageSeq *message);
size_t nebula__message_seq__pack
(const Nebula__MessageSeq *message,
uint8_t *out);
size_t nebula__message_seq__pack_to_buffer
(const Nebula__MessageSeq *message,
ProtobufCBuffer *buffer);
Nebula__MessageSeq *
nebula__message_seq__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__message_seq__free_unpacked
(Nebula__MessageSeq *message,
ProtobufCAllocator *allocator);
/* Nebula__MessageKievAck methods */
void nebula__message_kiev_ack__init
(Nebula__MessageKievAck *message);
size_t nebula__message_kiev_ack__get_packed_size
(const Nebula__MessageKievAck *message);
size_t nebula__message_kiev_ack__pack
(const Nebula__MessageKievAck *message,
uint8_t *out);
size_t nebula__message_kiev_ack__pack_to_buffer
(const Nebula__MessageKievAck *message,
ProtobufCBuffer *buffer);
Nebula__MessageKievAck *
nebula__message_kiev_ack__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__message_kiev_ack__free_unpacked
(Nebula__MessageKievAck *message,
ProtobufCAllocator *allocator);
/* Nebula__SubscribeRequest methods */
void nebula__subscribe_request__init
(Nebula__SubscribeRequest *message);
size_t nebula__subscribe_request__get_packed_size
(const Nebula__SubscribeRequest *message);
size_t nebula__subscribe_request__pack
(const Nebula__SubscribeRequest *message,
uint8_t *out);
size_t nebula__subscribe_request__pack_to_buffer
(const Nebula__SubscribeRequest *message,
ProtobufCBuffer *buffer);
Nebula__SubscribeRequest *
nebula__subscribe_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__subscribe_request__free_unpacked
(Nebula__SubscribeRequest *message,
ProtobufCAllocator *allocator);
/* Nebula__SubscribeResponse__Content methods */
void nebula__subscribe_response__content__init
(Nebula__SubscribeResponse__Content *message);
/* Nebula__SubscribeResponse methods */
void nebula__subscribe_response__init
(Nebula__SubscribeResponse *message);
size_t nebula__subscribe_response__get_packed_size
(const Nebula__SubscribeResponse *message);
size_t nebula__subscribe_response__pack
(const Nebula__SubscribeResponse *message,
uint8_t *out);
size_t nebula__subscribe_response__pack_to_buffer
(const Nebula__SubscribeResponse *message,
ProtobufCBuffer *buffer);
Nebula__SubscribeResponse *
nebula__subscribe_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__subscribe_response__free_unpacked
(Nebula__SubscribeResponse *message,
ProtobufCAllocator *allocator);
/* Nebula__NotifyBody methods */
void nebula__notify_body__init
(Nebula__NotifyBody *message);
size_t nebula__notify_body__get_packed_size
(const Nebula__NotifyBody *message);
size_t nebula__notify_body__pack
(const Nebula__NotifyBody *message,
uint8_t *out);
size_t nebula__notify_body__pack_to_buffer
(const Nebula__NotifyBody *message,
ProtobufCBuffer *buffer);
Nebula__NotifyBody *
nebula__notify_body__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__notify_body__free_unpacked
(Nebula__NotifyBody *message,
ProtobufCAllocator *allocator);
/* Nebula__SmsRequest__FileInfo methods */
void nebula__sms_request__file_info__init
(Nebula__SmsRequest__FileInfo *message);
/* Nebula__SmsRequest methods */
void nebula__sms_request__init
(Nebula__SmsRequest *message);
size_t nebula__sms_request__get_packed_size
(const Nebula__SmsRequest *message);
size_t nebula__sms_request__pack
(const Nebula__SmsRequest *message,
uint8_t *out);
size_t nebula__sms_request__pack_to_buffer
(const Nebula__SmsRequest *message,
ProtobufCBuffer *buffer);
Nebula__SmsRequest *
nebula__sms_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__sms_request__free_unpacked
(Nebula__SmsRequest *message,
ProtobufCAllocator *allocator);
/* Nebula__SmsResponse methods */
void nebula__sms_response__init
(Nebula__SmsResponse *message);
size_t nebula__sms_response__get_packed_size
(const Nebula__SmsResponse *message);
size_t nebula__sms_response__pack
(const Nebula__SmsResponse *message,
uint8_t *out);
size_t nebula__sms_response__pack_to_buffer
(const Nebula__SmsResponse *message,
ProtobufCBuffer *buffer);
Nebula__SmsResponse *
nebula__sms_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__sms_response__free_unpacked
(Nebula__SmsResponse *message,
ProtobufCAllocator *allocator);
/* Nebula__PresenceNotify__Content methods */
void nebula__presence_notify__content__init
(Nebula__PresenceNotify__Content *message);
/* Nebula__PresenceNotify methods */
void nebula__presence_notify__init
(Nebula__PresenceNotify *message);
size_t nebula__presence_notify__get_packed_size
(const Nebula__PresenceNotify *message);
size_t nebula__presence_notify__pack
(const Nebula__PresenceNotify *message,
uint8_t *out);
size_t nebula__presence_notify__pack_to_buffer
(const Nebula__PresenceNotify *message,
ProtobufCBuffer *buffer);
Nebula__PresenceNotify *
nebula__presence_notify__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__presence_notify__free_unpacked
(Nebula__PresenceNotify *message,
ProtobufCAllocator *allocator);
/* Nebula__PresenceRequest methods */
void nebula__presence_request__init
(Nebula__PresenceRequest *message);
size_t nebula__presence_request__get_packed_size
(const Nebula__PresenceRequest *message);
size_t nebula__presence_request__pack
(const Nebula__PresenceRequest *message,
uint8_t *out);
size_t nebula__presence_request__pack_to_buffer
(const Nebula__PresenceRequest *message,
ProtobufCBuffer *buffer);
Nebula__PresenceRequest *
nebula__presence_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__presence_request__free_unpacked
(Nebula__PresenceRequest *message,
ProtobufCAllocator *allocator);
/* Nebula__PresenceResponse methods */
void nebula__presence_response__init
(Nebula__PresenceResponse *message);
size_t nebula__presence_response__get_packed_size
(const Nebula__PresenceResponse *message);
size_t nebula__presence_response__pack
(const Nebula__PresenceResponse *message,
uint8_t *out);
size_t nebula__presence_response__pack_to_buffer
(const Nebula__PresenceResponse *message,
ProtobufCBuffer *buffer);
Nebula__PresenceResponse *
nebula__presence_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__presence_response__free_unpacked
(Nebula__PresenceResponse *message,
ProtobufCAllocator *allocator);
/* Nebula__AccountStatusRequest methods */
void nebula__account_status_request__init
(Nebula__AccountStatusRequest *message);
size_t nebula__account_status_request__get_packed_size
(const Nebula__AccountStatusRequest *message);
size_t nebula__account_status_request__pack
(const Nebula__AccountStatusRequest *message,
uint8_t *out);
size_t nebula__account_status_request__pack_to_buffer
(const Nebula__AccountStatusRequest *message,
ProtobufCBuffer *buffer);
Nebula__AccountStatusRequest *
nebula__account_status_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__account_status_request__free_unpacked
(Nebula__AccountStatusRequest *message,
ProtobufCAllocator *allocator);
/* Nebula__AccountStatusResponse__AccountStatus methods */
void nebula__account_status_response__account_status__init
(Nebula__AccountStatusResponse__AccountStatus *message);
/* Nebula__AccountStatusResponse methods */
void nebula__account_status_response__init
(Nebula__AccountStatusResponse *message);
size_t nebula__account_status_response__get_packed_size
(const Nebula__AccountStatusResponse *message);
size_t nebula__account_status_response__pack
(const Nebula__AccountStatusResponse *message,
uint8_t *out);
size_t nebula__account_status_response__pack_to_buffer
(const Nebula__AccountStatusResponse *message,
ProtobufCBuffer *buffer);
Nebula__AccountStatusResponse *
nebula__account_status_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__account_status_response__free_unpacked
(Nebula__AccountStatusResponse *message,
ProtobufCAllocator *allocator);
/* Nebula__Address methods */
void nebula__address__init
(Nebula__Address *message);
size_t nebula__address__get_packed_size
(const Nebula__Address *message);
size_t nebula__address__pack
(const Nebula__Address *message,
uint8_t *out);
size_t nebula__address__pack_to_buffer
(const Nebula__Address *message,
ProtobufCBuffer *buffer);
Nebula__Address *
nebula__address__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__address__free_unpacked
(Nebula__Address *message,
ProtobufCAllocator *allocator);
/* Nebula__DialogRequest methods */
void nebula__dialog_request__init
(Nebula__DialogRequest *message);
size_t nebula__dialog_request__get_packed_size
(const Nebula__DialogRequest *message);
size_t nebula__dialog_request__pack
(const Nebula__DialogRequest *message,
uint8_t *out);
size_t nebula__dialog_request__pack_to_buffer
(const Nebula__DialogRequest *message,
ProtobufCBuffer *buffer);
Nebula__DialogRequest *
nebula__dialog_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__dialog_request__free_unpacked
(Nebula__DialogRequest *message,
ProtobufCAllocator *allocator);
/* Nebula__DialogResponse methods */
void nebula__dialog_response__init
(Nebula__DialogResponse *message);
size_t nebula__dialog_response__get_packed_size
(const Nebula__DialogResponse *message);
size_t nebula__dialog_response__pack
(const Nebula__DialogResponse *message,
uint8_t *out);
size_t nebula__dialog_response__pack_to_buffer
(const Nebula__DialogResponse *message,
ProtobufCBuffer *buffer);
Nebula__DialogResponse *
nebula__dialog_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__dialog_response__free_unpacked
(Nebula__DialogResponse *message,
ProtobufCAllocator *allocator);
/* --- per-message closures --- */
typedef void (*Nebula__Param_Closure)
(const Nebula__Param *message,
void *closure_data);
typedef void (*Nebula__AccountUpdateRequest_Closure)
(const Nebula__AccountUpdateRequest *message,
void *closure_data);
typedef void (*Nebula__AccountUpdateResponse_Closure)
(const Nebula__AccountUpdateResponse *message,
void *closure_data);
typedef void (*Nebula__AuthRequest_Closure)
(const Nebula__AuthRequest *message,
void *closure_data);
typedef void (*Nebula__AuthResponse_Closure)
(const Nebula__AuthResponse *message,
void *closure_data);
typedef void (*Nebula__Message__Content_Closure)
(const Nebula__Message__Content *message,
void *closure_data);
typedef void (*Nebula__Message_Closure)
(const Nebula__Message *message,
void *closure_data);
typedef void (*Nebula__MessageSeq__Content_Closure)
(const Nebula__MessageSeq__Content *message,
void *closure_data);
typedef void (*Nebula__MessageSeq_Closure)
(const Nebula__MessageSeq *message,
void *closure_data);
typedef void (*Nebula__MessageKievAck_Closure)
(const Nebula__MessageKievAck *message,
void *closure_data);
typedef void (*Nebula__SubscribeRequest_Closure)
(const Nebula__SubscribeRequest *message,
void *closure_data);
typedef void (*Nebula__SubscribeResponse__Content_Closure)
(const Nebula__SubscribeResponse__Content *message,
void *closure_data);
typedef void (*Nebula__SubscribeResponse_Closure)
(const Nebula__SubscribeResponse *message,
void *closure_data);
typedef void (*Nebula__NotifyBody_Closure)
(const Nebula__NotifyBody *message,
void *closure_data);
typedef void (*Nebula__SmsRequest__FileInfo_Closure)
(const Nebula__SmsRequest__FileInfo *message,
void *closure_data);
typedef void (*Nebula__SmsRequest_Closure)
(const Nebula__SmsRequest *message,
void *closure_data);
typedef void (*Nebula__SmsResponse_Closure)
(const Nebula__SmsResponse *message,
void *closure_data);
typedef void (*Nebula__PresenceNotify__Content_Closure)
(const Nebula__PresenceNotify__Content *message,
void *closure_data);
typedef void (*Nebula__PresenceNotify_Closure)
(const Nebula__PresenceNotify *message,
void *closure_data);
typedef void (*Nebula__PresenceRequest_Closure)
(const Nebula__PresenceRequest *message,
void *closure_data);
typedef void (*Nebula__PresenceResponse_Closure)
(const Nebula__PresenceResponse *message,
void *closure_data);
typedef void (*Nebula__AccountStatusRequest_Closure)
(const Nebula__AccountStatusRequest *message,
void *closure_data);
typedef void (*Nebula__AccountStatusResponse__AccountStatus_Closure)
(const Nebula__AccountStatusResponse__AccountStatus *message,
void *closure_data);
typedef void (*Nebula__AccountStatusResponse_Closure)
(const Nebula__AccountStatusResponse *message,
void *closure_data);
typedef void (*Nebula__Address_Closure)
(const Nebula__Address *message,
void *closure_data);
typedef void (*Nebula__DialogRequest_Closure)
(const Nebula__DialogRequest *message,
void *closure_data);
typedef void (*Nebula__DialogResponse_Closure)
(const Nebula__DialogResponse *message,
void *closure_data);
/* --- services --- */
/* --- descriptors --- */
extern const ProtobufCEnumDescriptor nebula__presence_type__descriptor;
extern const ProtobufCMessageDescriptor nebula__param__descriptor;
extern const ProtobufCMessageDescriptor nebula__account_update_request__descriptor;
extern const ProtobufCMessageDescriptor nebula__account_update_response__descriptor;
extern const ProtobufCMessageDescriptor nebula__auth_request__descriptor;
extern const ProtobufCEnumDescriptor nebula__auth_request__algorithm__descriptor;
extern const ProtobufCMessageDescriptor nebula__auth_response__descriptor;
extern const ProtobufCMessageDescriptor nebula__message__descriptor;
extern const ProtobufCMessageDescriptor nebula__message__content__descriptor;
extern const ProtobufCEnumDescriptor nebula__message__content__msg_type__descriptor;
extern const ProtobufCEnumDescriptor nebula__message__flag__descriptor;
extern const ProtobufCMessageDescriptor nebula__message_seq__descriptor;
extern const ProtobufCMessageDescriptor nebula__message_seq__content__descriptor;
extern const ProtobufCMessageDescriptor nebula__message_kiev_ack__descriptor;
extern const ProtobufCMessageDescriptor nebula__subscribe_request__descriptor;
extern const ProtobufCMessageDescriptor nebula__subscribe_response__descriptor;
extern const ProtobufCMessageDescriptor nebula__subscribe_response__content__descriptor;
extern const ProtobufCMessageDescriptor nebula__notify_body__descriptor;
extern const ProtobufCMessageDescriptor nebula__sms_request__descriptor;
extern const ProtobufCMessageDescriptor nebula__sms_request__file_info__descriptor;
extern const ProtobufCEnumDescriptor nebula__sms_request__sms_type__descriptor;
extern const ProtobufCEnumDescriptor nebula__sms_request__report_type__descriptor;
extern const ProtobufCMessageDescriptor nebula__sms_response__descriptor;
extern const ProtobufCMessageDescriptor nebula__presence_notify__descriptor;
extern const ProtobufCMessageDescriptor nebula__presence_notify__content__descriptor;
extern const ProtobufCMessageDescriptor nebula__presence_request__descriptor;
extern const ProtobufCMessageDescriptor nebula__presence_response__descriptor;
extern const ProtobufCMessageDescriptor nebula__account_status_request__descriptor;
extern const ProtobufCMessageDescriptor nebula__account_status_response__descriptor;
extern const ProtobufCMessageDescriptor nebula__account_status_response__account_status__descriptor;
extern const ProtobufCMessageDescriptor nebula__address__descriptor;
extern const ProtobufCMessageDescriptor nebula__dialog_request__descriptor;
extern const ProtobufCMessageDescriptor nebula__dialog_response__descriptor;
PROTOBUF_C_END_DECLS
#endif /* PROTOBUF_message_2eproto__INCLUDED */

View File

@ -0,0 +1,248 @@
package Nebula;
option java_package = "com.meizu.push.proto";
option java_outer_classname = "ProtoMessages";
message Param
{
optional string name = 1;
optional string value = 2;
};
message AccountUpdateRequest
{
optional string flyme_uid = 1;
optional string phone = 2;
optional int32 capability = 3; //能力值
};
message AccountUpdateResponse
{
//200 OK
//4XX 检验错误 携带相应的正确值
//5XX 其他错误
required int32 status = 1; //账号绑定的结果 200 OK
optional string flyme_uid = 2; //正确的flyme_uid
optional string imsi = 3; //正确的imsi
optional string phone = 4; //正确的电话号码
optional int32 capability = 5; //能力值
};
//鉴权请求
message AuthRequest
{
enum Algorithm
{
MD5_MEIZU = 0;
MD5_DAA = 1;
MD5_FLYME = 2;
};
required string uid = 1; //用户的唯一标识
optional string username = 2; //鉴权使用
optional string nonce = 3; //鉴权使用
optional string realm = 4; //鉴权使用
optional string token = 5; //鉴权使用
optional Algorithm algorithm = 6; //鉴权使用
repeated Param other_info = 7; //用户的其他信息 比如 手机型号 OS版本等
};
//鉴权应答
message AuthResponse
{
optional int32 status = 1;
optional string nonce = 2;
optional string realm = 3;
};
//服务端向下推送的消息
message Message
{
message Content
{
enum MsgType
{
ePushMessage = 0; //push消息
ePresenceMessage = 1; //presence消息
eSmsMessage = 2; //短信消息
};
required MsgType type = 1; //消息类型
required string account = 2;
required uint32 seq = 3; //消息序列号
optional bytes body = 4; //消息内容 使用protobuf编码
};
enum Flag
{
MESSAGE_ACK = 1;
MESSAGE_END = 2;
};
repeated Content content = 1;
optional Flag flag = 2;
}
//ACK SYNC FIN 3种消息
message MessageSeq
{
message Content
{
required string account = 1;
required uint32 seq = 2;
};
repeated Content content = 1; //需要同步的消息编号
};
message MessageKievAck
{
required MessageSeq seqs = 1;
required uint32 index = 2;
};
//订阅请求消息
message SubscribeRequest
{
repeated string app = 1; //订阅的app
};
//订阅应答消息
message SubscribeResponse
{
message Content {
optional int32 status = 1; //订阅状态 200 ok
optional string app = 2; //订阅的app
optional string pushid = 3; //返回的pushid
};
required int32 status = 1; //应答消息的状态
repeated Content content = 2; //订阅结果
};
////////////////MessageSend的body定义/////////////////////
message NotifyBody
{
optional string app = 1;
optional string body = 2;
};
//短信消息
message SmsRequest
{
enum SmsType
{
eShortMessage = 0;
eMultimediaMessage = 1;
eReportMessage = 2;
};
message FileInfo
{
required string mimetype = 1;
required int32 size = 2;
optional string filename = 3;
optional string url = 4;
};
enum ReportType
{
eSMSReport = 0;
eMMSReport = 1;
};
required SmsType type = 1; //消息类型
required string msgid = 2; //消息ID
required string src = 3;
repeated string dst = 4; //接收者
optional bytes body = 5;
optional bool report_flag = 6; //sms或者mms消息使用 report标志
optional ReportType report_type = 7;
optional string report_status = 8; //report消息使用
optional string time = 9;
optional string expires = 10;
optional string pdu = 11;
optional int32 size = 12;
optional string ver = 13;
repeated FileInfo fileinfos = 14;
};
//Message应答消息的内容
message SmsResponse
{
required string msgid = 1;
required int32 status = 2;
};
//presence推送内容格式
message PresenceNotify
{
message Content
{
optional string account = 1;
optional int32 capability = 2;
optional int32 status = 3; //在线状态
};
repeated Content content = 1;
};
/////////////////////////MessageSend body end///////////////////////////
enum PresenceType
{
eIncrementSubscribe = 0; //增量订阅
eFullSubscribe = 1; //全量订阅
eUnSubscribe = 2; //取消订阅
};
//presence订阅或取消订阅格式
message PresenceRequest
{
optional PresenceType type = 1;
optional uint32 sequence = 2;
repeated string account = 3;
};
message PresenceResponse
{
required int32 status = 1;
optional PresenceType type = 2;
optional uint32 sequence = 3;
repeated string account = 4; // Return the legal account
};
//查询账号在线状态格式
message AccountStatusRequest
{
repeated string account = 1;
};
message AccountStatusResponse
{
message AccountStatus
{
optional string account = 1;
optional int32 status = 2; //查询在线状态
optional int32 capability = 3; //能力值
};
required int32 status = 1;
repeated AccountStatus result = 2;
};
/////////////////对话协议定义////////////////////////////
message Address
{
required string host = 1;
required int32 port = 2;
};
message DialogRequest
{
required string src = 1;
required string dst = 2;
optional Address dialog = 3; //dialog服务器地址
optional bytes body = 4;
};
message DialogResponse
{
required int32 status = 1;
required string src = 2;
required string dst = 3;
optional Address dialog = 4; //dialog服务器地址
optional bytes body = 5;
};

Binary file not shown.

View File

@ -0,0 +1,102 @@
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
/* Do not generate deprecated warnings for self */
#ifndef PROTOBUF_C_NO_DEPRECATED
#define PROTOBUF_C_NO_DEPRECATED
#endif
#include "nebula.pb-c.h"
void nebula__nebula_msg__init
(Nebula__NebulaMsg *message)
{
static Nebula__NebulaMsg init_value = NEBULA__NEBULA_MSG__INIT;
*message = init_value;
}
size_t nebula__nebula_msg__get_packed_size
(const Nebula__NebulaMsg *message)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &nebula__nebula_msg__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t nebula__nebula_msg__pack
(const Nebula__NebulaMsg *message,
uint8_t *out)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &nebula__nebula_msg__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t nebula__nebula_msg__pack_to_buffer
(const Nebula__NebulaMsg *message,
ProtobufCBuffer *buffer)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &nebula__nebula_msg__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
Nebula__NebulaMsg *
nebula__nebula_msg__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (Nebula__NebulaMsg *)
protobuf_c_message_unpack (&nebula__nebula_msg__descriptor,
allocator, len, data);
}
void nebula__nebula_msg__free_unpacked
(Nebula__NebulaMsg *message,
ProtobufCAllocator *allocator)
{
PROTOBUF_C_ASSERT (message->base.descriptor == &nebula__nebula_msg__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
static const ProtobufCFieldDescriptor nebula__nebula_msg__field_descriptors[2] =
{
{
"msgid",
1,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
PROTOBUF_C_OFFSETOF(Nebula__NebulaMsg, msgid),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"body",
2,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BYTES,
PROTOBUF_C_OFFSETOF(Nebula__NebulaMsg, has_body),
PROTOBUF_C_OFFSETOF(Nebula__NebulaMsg, body),
NULL,
NULL,
0, /* packed */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned nebula__nebula_msg__field_indices_by_name[] = {
1, /* field[1] = body */
0, /* field[0] = msgid */
};
static const ProtobufCIntRange nebula__nebula_msg__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 2 }
};
const ProtobufCMessageDescriptor nebula__nebula_msg__descriptor =
{
PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
"Nebula.NebulaMsg",
"NebulaMsg",
"Nebula__NebulaMsg",
"Nebula",
sizeof(Nebula__NebulaMsg),
2,
nebula__nebula_msg__field_descriptors,
nebula__nebula_msg__field_indices_by_name,
1, nebula__nebula_msg__number_ranges,
(ProtobufCMessageInit) nebula__nebula_msg__init,
NULL,NULL,NULL /* reserved[123] */
};

View File

@ -0,0 +1,66 @@
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
#ifndef PROTOBUF_C_nebula_2eproto__INCLUDED
#define PROTOBUF_C_nebula_2eproto__INCLUDED
#include <google/protobuf-c/protobuf-c.h>
PROTOBUF_C_BEGIN_DECLS
typedef struct _Nebula__NebulaMsg Nebula__NebulaMsg;
/* --- enums --- */
/* --- messages --- */
struct _Nebula__NebulaMsg
{
ProtobufCMessage base;
char *msgid;
protobuf_c_boolean has_body;
ProtobufCBinaryData body;
};
#define NEBULA__NEBULA_MSG__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&nebula__nebula_msg__descriptor) \
, NULL, 0,{0,NULL} }
/* Nebula__NebulaMsg methods */
void nebula__nebula_msg__init
(Nebula__NebulaMsg *message);
size_t nebula__nebula_msg__get_packed_size
(const Nebula__NebulaMsg *message);
size_t nebula__nebula_msg__pack
(const Nebula__NebulaMsg *message,
uint8_t *out);
size_t nebula__nebula_msg__pack_to_buffer
(const Nebula__NebulaMsg *message,
ProtobufCBuffer *buffer);
Nebula__NebulaMsg *
nebula__nebula_msg__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void nebula__nebula_msg__free_unpacked
(Nebula__NebulaMsg *message,
ProtobufCAllocator *allocator);
/* --- per-message closures --- */
typedef void (*Nebula__NebulaMsg_Closure)
(const Nebula__NebulaMsg *message,
void *closure_data);
/* --- services --- */
/* --- descriptors --- */
extern const ProtobufCMessageDescriptor nebula__nebula_msg__descriptor;
PROTOBUF_C_END_DECLS
#endif /* PROTOBUF_nebula_2eproto__INCLUDED */

View File

@ -0,0 +1,9 @@
package Nebula;
option java_package = "com.meizu.push.proto";
message NebulaMsg
{
required string msgid = 1; //消息id不加密不压缩
optional bytes body = 2; //消息内容(可能加密和压缩)
};

View File

@ -0,0 +1,112 @@
#include "nebula_proto.h"
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <uuid/uuid.h>
#include <string.h>
static const char* StrRequestType[] = {
"REQ PING",
"REQ AUTH",
"REQ MSGSYNC",
"REQ MSGPSH",
"REQ MSG",
"REQ MSGACK",
"REQ MSGFIN",
"REQ SUB",
"REQ SMS",
"REQ PRES",
"REQ ACCSTATUS",
"REQ INVITE",
"REQ ACK",
"REQ BYE",
"REQ UPDATE",
"REQ ACCUPDATE"
};
static const char* StrResponseType[] = {
"RSP PING",
"RSP AUTH",
"RSP MSGSYNC",
"RSP MSGPSH",
"RSP MSG",
"RSP MSGACK",
"RSP MSGFIN",
"RSP SUB",
"RSP SMS",
"RSP PRES",
"RSP ACCSTATUS",
"RSP INVITE",
"RSP ACK",
"RSP BYE",
"RSP UPDATE",
"RSP ACCUPDATE"
};
const char* MsgType2Str(uint8_t type)
{
uint8_t request_flag = (type >> 7 & 0x01);
uint8_t msg_type = type & 0x7F;
switch (msg_type) { //内部服务使用的协议
case NEBULA_KIEV_ACCOFFLINE:
return (request_flag ? "REQ ACCOFFLINE" : "RSP ACCOFFLINE");
case NEBULA_KIEV_ACCONLINE:
return (request_flag ? "REQ ACCONLINE" : "RSP ACCONLINE");
case NEBULA_KIEV_MSGACK:
return (request_flag ? "REQ KIEVACK" : "RSP KIEVACK");
default:
break;
}
if (!IS_VALID_TYPE(type)) {
return (request_flag ? "REQ UnKnown": "RSP UnKnown");
}
if (request_flag) {
return StrRequestType[msg_type - 1];
}
return StrResponseType[msg_type-1];
}
uint32_t CreateMachineId()
{
uuid_t uuid = {0};
char str[37];
uint32_t hash = 5381;
memset(str, 0, sizeof(str));
uuid_generate(uuid);
uuid_unparse(uuid, str);
int i;
for(i=0; i<36; i++) {
hash = ((hash << 5) + hash) + str[i];
}
return hash;
}
void CreateMsgid(char *msgid)
{
static uint32_t machine_id;
static uint32_t ref_cnt = 0;
if (ref_cnt == 0) {
machine_id = CreateMachineId();
}
struct MsgId {
uint32_t timestamp;
uint32_t hash:24;
uint16_t pid;
uint32_t cnt:24;
}__attribute__((packed));
struct MsgId id;
id.timestamp = time(0);
id.hash = machine_id;
id.pid = getpid();
id.cnt = ref_cnt++;
sprintf(msgid, "%08x%06x%04x%06x", id.timestamp, id.hash, id.pid, id.cnt);
msgid[24] = '\0';
}

View File

@ -0,0 +1,69 @@
/******************************************************************************
* FileName:
* Description:
* Version:
* History:
* yuxiaobo 2014-12-23 1.0 created
*
*****************************************************************************/
#ifndef __NEBULA_PROTO_H__
#define __NEBULA_PROTO_H__
#include <stdint.h>
struct _NebulaHeader
{
uint8_t magic;
uint8_t ver;
uint8_t flag;
uint8_t type;
uint16_t len;
}__attribute__((packed));
typedef struct _NebulaHeader NebulaHeader;
#define NEBULA_MSG_PING 0x01
#define NEBULA_MSG_AUTH 0x02
#define NEBULA_MSG_SYNC 0x03
#define NEBULA_MSG_PSH 0x04
#define NEBULA_MSG_MSG 0x05
#define NEBULA_MSG_ACK 0x06
#define NEBULA_MSG_FIN 0x07
#define NEBULA_MSG_SUB 0x08
#define NEBULA_MSG_SMS 0x09
#define NEBULA_MSG_PRES 0x0A
#define NEBULA_MSG_ACCSTATUS 0x0B
#define NEBULA_MSG_INVITE 0x0C
#define NEBULA_MSG_DIALOGACK 0x0D
#define NEBULA_MSG_BYE 0x0E
#define NEBULA_MSG_UPDATE 0x0F
#define NEBULA_MSG_ACCUPDATE 0x10
#define NEBULA_KIEV_ACCOFFLINE 0x7D
#define NEBULA_KIEV_ACCONLINE 0x7E
#define NEBULA_KIEV_MSGACK 0x7F
#define MSG_IS_REQUEST(head) (((head)->type >> 7) & 0x01)
#define MSG_SET_REQUEST(type) (0x80 | type)
const char* MsgType2Str(uint8_t type);
#define IS_VALID_TYPE(type) (((type) & 0x7F) > 0 && ((type) & 0x7F) <= 0x10)
#define HEAD_INIT(h,t) \
do { \
(h)->magic = 0xF8; \
(h)->ver = 0x01; \
(h)->flag = 0x00; \
(h)->type = (t); \
(h)->len = 0; \
}while(0)
#define MSG_ID_LEN 24
/*
* 生成msgid
* @param msgid 长度必须是MSG_ID_LEN+1
*/
void CreateMsgid(char *msgid);
#endif

Binary file not shown.